Now that we’ve laid out the big picture for a web application security program, it’s time to dig into the individual details. In this part (see also Part 1, Part 2, Part 3, and Part 4) we’re going to discuss how to implement security during the development phases of the web application lifecycle, including which tools we recommend.

In web application security, process modification, education, and development tool choices are all typically undeserved. Security is frequently bolted on as an afterthought, rather than built in by design. The intention in this section is to illuminate your best options for integrating security during pre-deployment phases of application development (i.e., requirements gathering, design, implementation, and QA).

Web Application Security: Training and the SDLC

Most web applications today were designed, built, and deployed before web application security was considered. Secure coding practices are just now entering the consciousness of most web development teams, and usually only after a security ‘event’. Project Management and Assurance teams typically take on security only when a compliance requirement is dropped into their laps. News may have raised awareness of SQL injection attacks, but many developers remain unaware of how reflected Cross Site Scripting and Cross Site Request Forgeries are conducted, much less what can be done to protect against them. Secure Application Development practices, and what typically become part of a Secure Software Development Lifecycle, are in their infancy- in terms of both maturity and adoption.

Regardless of what drives your requirements, education and process modification are important first steps for producing secure web applications. Whether you are developing a new code base or retrofitting older applications, project managers, developers, and assurance personnel need to be educated about security challenges to address and secure design and coding techniques. The curriculum should cover both the general threats that need to be accounted for and the methods that hackers typically employ to subvert systems. Specialized training is necessary for each sub-discipline, including process modification options, security models for the deployment platform, security tools, and testing methodologies. Project management needs to be aware of what types of threats are relevant to the web application they are responsible for, and how to make trade-offs that minimize risk while still providing desired capabilities. Developers & QA need to understand how common exploits work, how to test for them, and how to address weaknesses. Whether your company creates its own internal training program, organizes peer educational events, or invests in third party classes, this is key for producing secure applications. Threat modeling, secure design principles, functional security requirements, secure coding practices, and security review/testing form the core of an effective secure SDLC, and are relatively straightforward to integrate into nearly all development processes.

Process also plays an important role in code development, and affects security in much the same way it affects employee productivity and product quality. If the product’s specification lacks security requirements, you can’t expect it to be secure. A product that doesn’t undergo security testing, just like a product that skips functional testing, will suffer from flaws and errors. Modification to the Software Development Lifecycle to include security considerations is called Secure-SDLC, and includes simple sanity checks throughout the process to help discover problems early. While Secure-SDLC is far too involved for any real discussion in this post, our goal is instead to highlight the need for development organizations to consider security as a requirement during each phase of development.

Tools and test cases, as we will discuss below, can be used to automate testing and assurance, but training and education are essential for taking advantage of them. Using them to augment the development and assurance process reduces overhead compared to ad hoc security adoption, and cuts down on vulnerabilities within the code. Team members educated on security issues are able to build libraries of tests that help catch typical flaws across all newer code. Extreme Programming techniques can be used to help certify that modules and components meet security requirements as part of unit testing, alongside non-security functional testing and regression sweeps provided by assurance teams. Remember- you are the vendor, and your team should know your code better than anyone, including how to break it.

Static Analysis Tools

There are a number of third party tools, built by organizations which understand the security challenges of web app development, to help with code review for security purposes. Static analysis examines the source code of a web application, looking for common vulnerabilities, errors, and omissions within the constructs of the language itself. This serves as an automated counterpart to peer review. Among other things, these tools generally scan for un-handled error conditions, object availability or scope, and potential buffer overflows. The concept is called “static analysis” because it examines the source code files, rather than either execution flow of a running program or executable object code.

These products run during the development phase to catch problems prior to more formalized testing procedures. The earlier a problem is found the easier (and cheaper) it is to fix. Static analysis supplements code review performed by developers, speeding up scans and finding bugs more quickly and cheaply than humans. The tools can hook into source code management for automated execution on a periodic basis, which again helps with early identification of issues.

Static analysis is effective at discovering ‘wetware’ problems, or problems in the code that are directly attributable to programmer error. The better tools integrate well with various development environments (providing educational feedback and suggesting corrective actions to programmers); can prioritize discovered vulnerabilities based on included or user-provided criteria; and include robust reporting to keep management informed, track trends, and engage the security team in the development process without requiring them double as programmers.

Static analysis tools are only moderately effective against buffer overruns, SQL injection, and code misuse. They do not account for all of the pathways within the code, and are blind to certain types of vulnerabilities and problems that are only apparent at runtime. To fill this gap, dynamic analysis tools have emerged over the last few years, as well as hybrid tools which combine both static and dynamic analysis.

Dynamic Analysis Tools

Dynamic analysis is intended to identify problems which cannot be detected from source code, or those more easily seen during execution. One type is fuzzers, which send intentionally bogus or harmful inputs to the application, and look for unintended results or crashes. There are many variations in this space, but three basic variables across the tools.

White Box vs. Black Box: The test application that ‘exercises’ the application may not have any prior knowledge, probing the application as a Black Box, and testing for exploits as it navigates the application. In most cases, the tests are a white box derivative of the functional tests, traversing the known pathways and substituting in malicious or garbage input values. The former is more typical of how a hacker will act, and is unburdened by assumptions, but takes longer to run and is more likely to miss key functional areas. For web applications, it’s also important to test credentialed vs. non-credentialed access. Some vulnerabilities may not be visible to a random attacker, but show up when logging in as a credentialed user.

Input Values: Input values may be random, they may be deduced on the fly based upon input type, or they may be targeted. Providing random inputs is a good way to verify basic integrity checking and finds generic issues across the code, while targeted inputs are helpful for checking against known vulnerabilities in the code.

Output and Behavior: With either White Box or Black box testing, human examination of the results is required to determine if there is a problem. Error conditions are easily reported, and most dynamic test tools discover and report on these. Some monitor resource usage and detect not only error conditions but resource allocation issues. Similarly to the way debuggers work, dynamic analyzers can monitor the internal resources of an application while it is under test- monitoring memory, pointers, message queues, and input variables. The tests can both highlight specific effects of system usage patterns, and identify areas of concern. The former is easy to use and understand, and works with any web application, while the later requires specific knowledge of the application.

Because of these variables, dynamic analysis tools vary in their speed, effectiveness, and level of automation. As they focus on application behavior and results, they provide tangible results for ‘what-if’ scenarios that static analysis cannot. Dynamic and static analysis are complimentary technologies, with different strengths, and intended for slightly different audiences. Some vendors provide both tools together, which allows them to share results and provide common reporting.

A well-structured web application security program starts with good education and integration of security into the SDLC- with threat modeling, secure design, functional security requirements, appropriate use of static and dynamic analysis security testing tools, secure coding practices, ongoing security education, and formalized security testing.

In our next post we’ll expand this as we enter the pre-deployment phase, where we add vulnerability assessments and penetration testing.