Manage Learn to apply best practices and optimize your operations.

HTTP attacks: Strategies for prevention

Examine how hackers manipulate HTTP requests to solicit an attack, and learn various guidelines developers should follow to mitigate this threat.

To run a Web site, your Web server must at least have port 80 open to process HTTP requests for Web pages. Unfortunately, attackers can modify or manipulate these requests to cause the server problems or to trick it into revealing valuable information. By using an HTTP request, an attacker has a legitimate path to your Web server and therefore can easily bypass firewalls and other security measures to initiate an attack.

There are two common HTTP attacks. One involves sending a long URL to a Web server with the goal of triggering a buffer overflow. The other attack is the SQL injection, which is the process of sending appended SQL commands to a URL to gain access to the backend database. Attackers often use forms to perform these attacks, as they both look to exploit poorly-written applications using unexpected, user-submitted data to initiate the attack. This means all user input data needs to be checked before being sent to another process. For example, if input data is used to build a Web page or is retrieved from a database, it must be checked before being published to ensure that any erroneous data is removed and the code runs correctly.

To prevent these types of attack, your organization's application security strategy should include the following:

  • Continual testing for technical and logical vulnerabilities during the development cycle. Two approaches to this are dynamic analysis and static analysis. Dynamic analysis involves actually running the software. Static analysis involves analyzing the software without executing it, which offers the benefit of performing the test earlier in the development cycle.

  • Develop procedures for completing component-level integration testing, system integration testing, and application function and deployment testing. While this may seem onerous, Gartner estimates that the cost of removing a vulnerability during testing is less than 2% of the cost of removing it from a production system.

  • Make sure you include change management, because the change rate in Web application code is normally high, which rapidly reduces the relevance of existing security reviews. In order to evaluate the impacts of any changes on overall system application security, the security assessment process should always be repeated when the business logic in the application changes.

  • Ensure proper training of developers. While training developers to write secure code doesn't necessarily mean the code they write will be secure, the more they understand how Web servers and browsers interact, and the protocols used in Internet communications, the more likely they are to build applications that aren't vulnerable to these attacks. Microsoft, in partnership with SPI Dynamics, is running an application development security awareness campaign and is providing free webcasts and workshops.

Here are 11 rules that developers should follow during any Web application development cycle:

  1. Never trust user supplied data
  2. Clean and validate all user input
  3. Validate data on the server
  4. Use taint checking or .NET validation controls
  5. Use POST instead of GET
  6. Avoid the use of HIDDEN form fields
  7. Only use cookies to store a session ID
  8. Locate different file types in separate directories
  9. Use absolute path and filenames
  10. Open files as read-only where possible
  11. Keep up to date on the latest attack methods

More on this topic

  • Visit our Web Security School to learn how to harden a Web server and how to prevent hackers from breaking into a network.
  • Read this tip to learn ten dos and don'ts for secure coding.
  • Visit our resource center for news, tips and expert advice on how to combat SQL injection, buffer overflows and other application attacks.

About the author:
Michael Cobb, CISSP-ISSAP is the founder and managing director of Cobweb Applications Ltd., a consultancy that offers IT training and support in data security and analysis. He co-authored the book IIS Security and has written numerous technical articles for leading IT publications. Mike is the guest instructor for SearchSecurity's Web Security School and, as a site expert, answers user questions on application and platform security.

This was last published in April 2006

Dig Deeper on Web application and API security best practices