Static Analysis Techniques for Testing Application Security. OWASP San Antonio January 31 st, 2008



Similar documents
Static Analysis Techniques for Testing Application Security. OWASP Austin March 25 th, 2008

IBM Rational Software

Static Analysis, Dynamic Analysis and How to Use Them Together. ROOTS 2008 April 29 th, 2008

Introduction to Web Application Security. Microsoft CSO Roundtable Houston, TX. September 13 th, 2006

Web Application Remediation. OWASP San Antonio. March 28 th, 2007

Vulnerability Management in an Application Security World. January 29 th, 2009

Using Sprajax to Test AJAX. OWASP AppSec Seattle Oct The OWASP Foundation

An Introduction to Application Security In ASP.NET Environments. Houston.NET User Group. February 23 rd, 2006

Vulnerability Management in an Application Security World. AppSec DC November 12 th, The OWASP Foundation

Benchmarking Web Application Scanners for YOUR Organization

Hybrid Analysis Mapping: Making Security and Development Tools Play Nice Together. Dan Cornell. CTO, Denim

Introduction. Secure Software Development 9/03/2015. Matias starts. Daan takes over. Matias takes over. Who are we? Round of introductions

Vulnerability Management in an Application Security World. March 16 th, 2009

How To Ensure That Your Computer System Is Safe

Secure Programming with Static Analysis. Jacob West

Iron Chef: John Henry Challenge

Application Code Development Standards

Integrating Tools Into the SDLC

Application Security and the SDLC. Dan Cornell Denim Group, Ltd.

Passing PCI Compliance How to Address the Application Security Mandates

Automating Security Testing. Mark Fallon Senior Release Manager Oracle

Streamlining Application Vulnerability Management: Communication Between Development and Security Teams

Do You Have a Scanner or a Scanning Program?

Adobe Systems Incorporated

An Introduction to Application Security in J2EE Environments

Securing SharePoint (TRISC) March 24 th, 2009

Security Tools - Hands On

Turning the Battleship: How to Build Secure Software in Large Organizations. Dan Cornell May 11 th, 2006

WHITEPAPER. Nessus Exploit Integration

Source Code Review Using Static Analysis Tools

D. Best Practices D.1. Assurance The 5 th A

EVALUATING COMMERCIAL WEB APPLICATION SECURITY. By Aaron Parke

Web Application Security. Vulnerabilities, Weakness and Countermeasures. Massimo Cotelli CISSP. Secure

Client vs. Server Implementations of Mitigating XSS Security Threats on Web Applications

Comparing Application Security Tools

Hacking the EULA: Reverse Benchmarking Web Application Security Scanners

How I Learned to Stop Fuzzing and Find More Bugs

Is Drupal secure? A high-level perspective on web vulnerabilities, Drupal s solutions, and how to maintain site security

Stories From the Front Lines: Deploying an Enterprise Code Scanning Program

Integrating Security into the Application Development Process. Jerod Brennen, CISSP CTO & Principal Security Consultant, Jacadis

DEVELOPING SECURE SOFTWARE

How To Protect Your Data From Attack

Learning objectives for today s session

Threat Modeling. Categorizing the nature and severity of system vulnerabilities. John B. Dickson, CISSP

elearning for Secure Application Development

Check list for web developers

Braindumps.C questions

SAF: Static Analysis Improved Fuzzing

How to start a software security initiative within your organization: a maturity based and metrics driven approach OWASP

Security Code Review- Identifying Web Vulnerabilities

Black Box versus White Box: Different App Testing Strategies John B. Dickson, CISSP

Bug hunting. Vulnerability finding methods in Windows 32 environments compared. FX of Phenoelit

Still Aren't Doing. Frank Kim

Enterprise Application Security Workshop Series

A framework for creating custom rules for static analysis tools

Web Application Threats and Vulnerabilities Web Server Hacking and Web Application Vulnerability

Secure Web Development Teaching Modules 1. Threat Assessment

TOOL EVALUATION REPORT: FORTIFY

How I hacked PacketStorm ( )

Java Web Application Security

Securing Network Software using Static Analysis

Secure Web Application Coding Team Introductory Meeting December 1, :00 2:00PM Bits & Pieces Room, Sansom West Room 306 Agenda

Advanced Web Technology 10) XSS, CSRF and SQL Injection 2

WHITE PAPER. FortiWeb and the OWASP Top 10 Mitigating the most dangerous application security threats

Application Security and the SDLC. Dan Cornell Denim Group, Ltd.

The Top Web Application Attacks: Are you vulnerable?

SAFECode Security Development Lifecycle (SDL)

STATIC CODE ANALYSIS Alexandru G. Bardas 1

Recon and Mapping Tools and Exploitation Tools in SamuraiWTF Report section Nick Robbins

Toward A Taxonomy of Techniques to Detect Cross-site Scripting and SQL Injection Vulnerabilities

Application Vulnerability Management

CSUSB Web Application Security Standard CSUSB, Information Security & Emerging Technologies Office

Client Side Cross Site Scripting

From Rivals to BFF: WAF & VA Unite OWASP The OWASP Foundation

Agile and Secure: OWASP AppSec Seattle Oct The OWASP Foundation

Application security testing: Protecting your application and data

Creating Stronger, Safer, Web Facing Code. JPL IT Security Mary Rivera June 17, 2011

Managing Your Application Security Program with the ThreadFix Ecosystem!! Dan

Abstract. Introduction. Summary

IBM Rational AppScan: Application security and risk management

A Strategic Approach to Web Application Security The importance of a secure software development lifecycle

CSE598i - Web 2.0 Security OWASP Top 10: The Ten Most Critical Web Application Security Vulnerabilities

FINAL DoIT v.4 PAYMENT CARD INDUSTRY DATA SECURITY STANDARDS APPLICATION DEVELOPMENT AND MAINTENANCE PROCEDURES

Course Modules for Software Security

An Eclipse Plug-In for Visualizing Java Code Dependencies on Relational Databases

Agile Security Successful Application Security Testing for Agile Development

Agile and Secure Can We Be Both? Chicago OWASP. June 20 th, 2007

Detecting Web Application Vulnerabilities Using Open Source Means. OWASP 3rd Free / Libre / Open Source Software (FLOSS) Conference 27/5/2008

1. Introduction. 2. Web Application. 3. Components. 4. Common Vulnerabilities. 5. Improving security in Web applications

Secure in 2010? Broken in 2011!

Automatic vs. Manual Code Analysis

WebGoat for testing your Application Security tools

Interactive Application Security Testing (IAST)

X05. An Overview of Source Code Scanning Tools. Loulwa Salem. Las Vegas, NV. IBM Corporation IBM System p, AIX 5L & Linux Technical University

Seven Practical Steps to Delivering More Secure Software. January 2011

Web Application Firewall Policy File Specification

Ruby on Rails Secure Coding Recommendations

Measuring the Effect of Code Complexity on Static Analysis Results

Early Vulnerability Detection for Supporting Secure Programming

Remediation Statistics: What Does Fixing Application Vulnerabilities Cost?

Transcription:

Static Analysis Techniques for Testing Application Security OWASP San Antonio January 31 st, 2008 Dan Cornell dan@denimgroup.com

Agenda What is Application Security? What is Static Analysis? Static versus Dynamic Overview Different Approaches Examples of Static Analysis Tools FindBugs (Java) PMD (Java) FxCop (.NET) XSSDetect (.NET) Process Implications Questions

What is Application Security? Ensuring that applications behave as expected under the entire range of possible inputs Really a subset of software correctness/qa however More typically focused on what an application is NOT supposed to do rather than what it IS supposed to do

What is Static Analysis? Analyzing software artifacts in order to gain information about the software Source code Binaries Configuration files Analyzing software at rest Also called white box testing and source code review PLEASE NOTE: Unless otherwise discussed, Static Analysis will refer to Static Analysis being performed by an automated tool

Dynamic Analysis Examining running software to see how it behaves under different stimuli Analyzing request and response patterns Checking remotely-detectable configuration settings

Which to Use? Static Analysis Advantages Disadvantages Dynamic Analysis Advantages Disadvantages Actually Making a Decision

Static Analysis Advantages Have access to the actual instructions the software will be executing No need to guess or interpret behavior Full access to all of the software s possible behaviors

Static Analysis Disadvantages Require access to source code or at least binary code Typically need access to enough software artifacts to execute a build Typically require proficiency running software builds Will not find issues related to operational deployment environments

Dynamic Analysis Advantages Only requires a running system to perform a test No requirement to have access to source code or binary code No need to understand how to write software or execute builds Tools tend to be more fire and forget Tests a specific, operational deployment Can find infrastructure, configuration and patch errors that Static Analysis tools will miss

Dynamic Analysis Disadvantages Limited scope of what can be found Application must be footprinted to find the test area That can cause areas to be missed You can only test what you have found No access to actual instructions being executed Tool is exercising i the application Pattern matching on requests and responses

Actually Making a Decision No access to source or binaries? Dynamic Not a software developer, don t understand software builds? Dynamic Performing a pen test or other test of an operational environment? Dynamic None of the previous problems? Static Really want to do the job right? Both (and then some )

Actually Making a Decision In our experience: Information Security practitioners are more comfortable with the Dynamic Analysis tools Analog to scanners such as Nessus or ISS Software Development practitioners are comfortable with both Static and Dynamic Analysis tools, but can get the most value out of Static Analysis tools More complete view of the software Integration ti with IDEs is a plus Understand that there are things that tools can find, and things tools can t find. Running a tool doesn t make you secure

Overview General Approach Source or Binary?

General Approach

Source or Binary? Having access to source typically provides more information to the analysis tool than only having access to the binaries Some environments (Java,.NET) are easy to decompile Source is thus easily recoverable Most.NET tools actually use binaries and disassemble them into IL

Different Approaches Increasing the scope of analysis increases the capability of the tool to find potential errors As scope increases, tools must either effectively prioritize analysis options or risk having excessive runtimes

Scope and Capability 5 Scope of Analysis versus Capability of Tool 4 3 2 1 0 Line Function Module Program System

Line Focus Like using grep to identify banned or suspect function calls This was the approach taken by early tools Good way to make a quick pass for potential vulnerabilities Good for targeting manual review Challenging g to use on large codebases The more signatures that are included, the higher the noise to signal ratio will be Just looking for specific functions

Line Focus Example Rule: gets() is BAD Input: my_str = gets(); Result: Flag this line for review Pretty basic, but better than nothing

Line Focus: C/C++ Known bad APIs: strcpy() gets() scanf() sprintf()

Line Focus: Java SQL injection XSS [Connection].createStatement() <%= More general parameter tampering: [HttpServletRequest].getParameter() [HttpServletRequest].getParameterValue() [HttpServletRequest].getCookies() [HttpServletRequest].getHeader()

Line Focus:.NET SQL Injection: XSS SqlCommand <%= More general parameter tampering Request[ Request.Cookies[ Request.Headers[

Two (Crappy) Scripts I Wrote dotnetcheck.sh and javacheck.sh Implement the checks I mentioned above

Function and Module Focus At this point the tool needs to be acting as a compiler Parse into tokens, determine lexical structure This allows for much more sophisticated analysis State machines Control flow Data flow

Function and Module Focus Example Rule: Memory should only be freed once Input: void f() { } my_mem = malloc(256); free(my_mem); free(my_mem); Result: my_mem is marked as allocated my_mem is marked as freed Flag the second call to free(my_mem) as an issue

Program and System Focus Expanding the scope of inquiry allow tools to find more and more subtle flaws Also helps avoid false positives

Dataflow and Taint Tracking Track dataflows through the system Sources and Sinks Attach taint flags to inputs Web parameters and cookies Data read from files Environment variables Data read from databases Data read from web services What type of taint? From the network From a configuration setting From a database And so on Identify cleaning functions

Program and System Focus Example Rule: User-supplied data should never be included in a SQL query without being properly escaped

Program and System Focus Example (continued) Input: public void doget(httpservletreqest req, HttpServlet Response resp) { String user = req.getparameter( username ); logstuff(user, my_page ); // Render out HTML } private logstuff(string user, String location) { Connection con = getconnection(); Statement stmt = con createstatement(); Statement stmt = con.createstatement(); String sql = INSERT INTO log (user, location) VALUES ( + user +, + location + stmt.executeupdate(sql); }

Program and System Focus Example (continued) Result: Input from getparameter() call is marks user variable as tained (Source) Flow of data is traced into the logstuff() method sql variable is also marked as tainted when it is concatenated with username parameter executeupdate() is marked as a security issue because it received tainted data (Sink)

Examples of Static Analysis Tools FindBugs (Java) PMD (Java) FxCop (.NET) XSSDetect (.NET)

FindBugs (Java) Java-based static analysis tool LGPL-licensed Originally developed by Dr. Bill Pugh from the University of Maryland Intended to find correctness issues, also identifies some security issues findbugs.sourceforge.net

PMD (Java) Java-based static analysis tool BSD-licensed Lead developers are David Dixon- Peugh and Tom Copeland Intended to find correctness and complexity issues, also finds some security issues pmd.sourceforge.net

FxCop (.NET) Microsoft-provided tool for.net static analysis Freely available Enforces coding standards (variable naming, etc) Similar to FindBugs in its security capabilities www.gotdotnet.com/team/fxcop/

XSSDetect (.NET) Microsoft-provided tool for.net static analysis Freely available (BETA!) Performs data flow analysis to identify Cross Site Scripting (XSS) defects blogs.msdn.com/ace_team/archive/2007/10/22/xssdetect-public-beta-now-available.aspx Based on the Microsoft Research Phoenix framework For software analysis and optimization research.microsoft.com/phoenix/

Limitations Static Analysis tools are a starting point for code review. Not a complete solution. Static Analysis tools (like all automated tools) do not understand what your application is supposed to do Out of the box rules are for general classes of security defects Applications can still have issues with authorization and other trust issues Only cover 50% of security defects (Dr. Gary McGraw) False positives can be time consuming to address Solutions? Custom rules can help to add some application specific context

Process Implications Static Analysis tools can provide tremendous benefits It is easier to start a new project using a tool than to impose one on an existing system I have found that using a Static Analysis tool while developing helps to improve my coding skills Immediate feedback when mistakes are made Learn more about language and platform internals

Process Implications: Questions Who is going to run the tool? When is the tool going to be run? What will be done with the results? Until you can answer these questions you should not assume Until you can answer these questions, you should not assume that a Static Analysis tool will help you improve security

Additional Resources Book: Secure Programming With Static Analysis (Brian Chess and Jacob West) Blog: Microsoft Code Analysis and Code Metrics Team Blog blogs.msdn.com/fxcop/ Website: FindBugs publications page findbugs.sourceforge.net/publications.html Various commercial vendors

Questions Dan Cornell dan@denimgroup.com (210) 572-4400 Website: www.denimgroup.com Blog: denimgroup.typepad.com