|
|
To print: Select File and then Print from your browser's menu
-------------------------------------------------------------- This story was printed from ZDNet Australia. --------------------------------------------------------------
|
Develop applications that prevent intrusion By Robert L. Bogue, Special to ZDNet February 10, 2004 URL: http://www.zdnet.com.au/insight/software/soa/Develop-applications-that-prevent-intrusion/0,139023769,139116053,00.htm
Designing for application security is one thing; keeping someone out of your application is important; however, allowing someone to take control of a system through your application can be substantially worse. Designing your applications to prevent a system-level security breach is significantly different from preventing security vulnerabilities at the application level. In application security, you're looking for things that are entirely in your control. In designing applications for system security, you're trying to prevent security vulnerabilities from occurring in your own code as well as the code that your code uses.
Buffer overflows
Most people working in languages today take a relatively carefree attitude to buffer overflows. Working in Visual Basic, Visual Basic.Net, C#, Java, or one of a dozen other languages means that you don't have to worry about buffer overflows internally in your applications. Either the language itself or the underlying infrastructure automatically manages the amount of buffer space allocated for strings and other parameters. Because of this, for all practical purposes, it's impossible to overflow a buffer within the confines of an application. The challenge comes in when you utilise an API, a COM object, or some other component that was not designed in a language that automatically manages memory allocation and buffers for you. Most of the APIs available in Windows, including the core Windows APIs, were written in C or C++. Neither of these languages have automatic management for buffers. This leaves the possibility open that you could pass in a parameter that exceeds the internal buffer and allows the execution of someone else's code. Obviously, some consideration must be given to parameter lengths when calling outside "safe" languages. If you're taking input in directly from a user or external system and passing it along to an API, check the length of the parameter for the API. This will prevent your "safe" language from passing through an unsafe request. A few quick "sanity" checks for parameters can prevent real problems. A "sanity" check is one which simply checks for a reasonable value. The check isn't the same as checking to see whether the length of the string is larger than a database field -- when you may need to worry about the difference between 25 and 26 characters. Instead, sanity checks are ones where you check parameters for reasonable lengths. For instance, a person's name shouldn't typically be more than 255 characters in length. Every value should have some sort of a sanity check associated with it.
System account privileges
If you're an attacker trying to work your way into an organisation's systems, which user accounts are you going to go after? The users that have little rights and log in for a few hours each day or the systems that are constantly running, have high privileges, and can be tested hour after hour, day after day? Obviously, the system accounts used by applications are the ones which are the most desirable. The most classic way that applications are installed is that they are given administrative privileges. In effect, any code run by the application is run as an administrator. They have the capability of doing anything that they want with the system without restriction. These are the perfect kinds of accounts for a hacker to go after since they will have the keys to the entire network with relatively little effort. This leaves open the door that attackers can create their own user accounts to the system and enable services such as terminal services. If you can create an account and access terminal services, you have the ability to take complete control of the system. When developing applications and deploying them, it's important to consider what minimum rights the application must have and how those rights can be minimised. Developing for system security means minimising the potential options for an intruder if they do manage to get your application to do something it wasn't designed to do. One of the primary challenges with minimising permissions is understanding what the minimum permissions are. As I mentioned above, many applications are installed running an administrator-equivalent account. This is because, when debugging an application, this is the easiest way to determine if the problem is a permissions problem. Once a solution is found to the problem, the exact permission needed to complete the operation becomes of less concern and is all too often overlooked.
Misconfiguration
Developing error handling within the application to the point where it can detect configuration problems and report on them is a good first step. This allows the system to be configured in the most restrictive way first, and then, progressively, as errors are detected in the application, the system configuration can be gradually opened up. This helps to reduce the tendency to radically change the configuration to a completely open configuration.
Clean up
Another item that may need cleaning up is unnecessary source code on the server. If you are working with a language that has both source code and compiled code -- such as Java and the .NET languages -- then it's important to remove the source code from the servers. The source code can be used as a map to areas where you may not be protecting the application. It shows them exactly where they should focus their attacks.
Dress in layers
Planning from the outset to develop secure software generally results in a relatively secure application. However, even if you don't have the luxury of starting from scratch, you can apply the same techniques and thought processes to existing applications to make them better protect the systems they run on.
Copyright © 2009 CBS Interactive, a CBS Company. All Rights Reserved. |