OWASP 5/07/09. The OWASP Foundation OWASP Static Analysis (SA) Track Session 1: Intro to Static Analysis

Similar documents
Kishin Fatnani. Founder & Director K-Secure. Workshop : Application Security: Latest Trends by Cert-In, 30 th Jan, 2009

Application Security through a Hacker s Eyes James Walden Northern Kentucky University

W e b A p p l i c a t i o n S e c u r i t y : T h e D e v i l i s i n t h e D e t a i l s

Attacks Against Websites 3 The OWASP Top 10. Tom Chothia Computer Security, Lecture 14

Students should have an understanding and a working knowledge in the following topics, or attend these courses as a pre-requisite:

NET 311 INFORMATION SECURITY

Course 834 EC-Council Certified Secure Programmer Java (ECSP)

Static Vulnerability Analysis

Finding Vulnerabilities in Web Applications

Solutions Business Manager Web Application Security Assessment

Web Application Security. Philippe Bogaerts

Attacks Against Websites. Tom Chothia Computer Security, Lecture 11

Discover Best of Show März 2016, Düsseldorf

Application Security. Doug Ashbaugh CISSP, CISA, CSSLP. Solving the Software Quality Puzzle

C1: Define Security Requirements

Mobile Malfeasance. Exploring Dangerous Mobile Code. Jason Haddix, Director of Penetration Testing

WEB APPLICATION SCANNERS. Evaluating Past the Base Case

GUI based and very easy to use, no security expertise required. Reporting in both HTML and RTF formats - Click here to view the sample report.

OWASP Thailand. Proxy Caches and Web Application Security. OWASP AppSec Asia October 21, Using the Recent Google Docs 0-Day as an Example

Students should have an understanding and a working knowledge in the following topics, or attend these courses as a pre-requisite:

DEFENSIVE PROGRAMMING. Lecture for EDA 263 Magnus Almgren Department of Computer Science and Engineering Chalmers University of Technology

Important Points to Note

Certified Secure Web Application Engineer

OWASP TOP Release. Andy Willingham June 12, 2018 OWASP Cincinnati

Andromeda: XSS Accurate and Scalable Security Analysis of Web Applications. OWASP* Top Ten Security Vulnerabilities. SQL Injection.

Web Applications (Part 2) The Hackers New Target

Web Application & Web Server Vulnerabilities Assessment Pankaj Sharma

SECURITY TESTING. Towards a safer web world

CSE 565 Computer Security Fall 2018

Application Security Introduction. Tara Gu IBM Product Security Incident Response Team

Development*Process*for*Secure* So2ware

F5 Application Security. Radovan Gibala Field Systems Engineer

Application. Security. on line training. Academy. by Appsec Labs

OWASP Top 10 Risks. Many thanks to Dave Wichers & OWASP

Your Turn to Hack the OWASP Top 10!

Web Application Penetration Testing

Frameworks & Security How web applications frameworks kill your security scanning

Secure Coding, some simple steps help. OWASP EU Tour 2013

Some Facts Web 2.0/Ajax Security

Hacking 102 Integrating Web Application Security Testing into Development

CHAPTER 8 CONCLUSION AND FUTURE ENHANCEMENTS

OPEN WEB APPLICATION SECURITY PROJECT OWASP TOP 10 VULNERABILITIES

Secure Programming Techniques

Managed Application Security trends and best practices in application security

Large Scale Generation of Complex and Faulty PHP Test Cases

CSWAE Certified Secure Web Application Engineer

Building Security Into Applications

"Charting the Course to Your Success!" Securing.Net Web Applications Lifecycle Course Summary

Application vulnerabilities and defences

Securing Your Web Application against security vulnerabilities. Alvin Wong, Brand Manager IBM Rational Software

Application security : going quicker

Lecture 4 September Required reading materials for this class

ShiftLeft. Real-World Runtime Protection Benchmarking

RBS NetGain Enterprise Manager Multiple Vulnerabilities of 11

Generating String Attack Inputs Using Constrained Symbolic Execution. presented by Kinga Dobolyi

Advanced Web Technology 10) XSS, CSRF and SQL Injection

CSCE 548 Building Secure Software SQL Injection Attack

OWASP Top 10 The Ten Most Critical Web Application Security Risks

Simplifying Application Security and Compliance with the OWASP Top 10

gfuzz: An instrumented Web application fuzzing environment Ezequiel D. Gutesman Corelabs Core Security Technologies

David Rook. Agnitio Security code review swiss army knife. Hack in Paris, Paris

Web Application Vulnerabilities: OWASP Top 10 Revisited

GOING WHERE NO WAFS HAVE GONE BEFORE

Evaluating Bug Finders

Fortify Security Report. Sep 30, 2010 Aleks

Improving Security in the Application Development Life-cycle

Welcome to the OWASP TOP 10

Secure DevOps: A Puma s Tail

Excerpts of Web Application Security focusing on Data Validation. adapted for F.I.S.T. 2004, Frankfurt

Frameworks & Security

Aguascalientes Local Chapter. Kickoff

ISSA: EXPLOITATION AND SECURITY OF SAAS APPLICATIONS. Waqas Nazir - CEO - DigitSec, Inc.

Micro Focus Fortify Application Security

Andrew Muller, Canberra Managing Director, Ionize, Canberra The challenges of Security Testing. Security Testing. Taming the Wild West

Web Application Threats and Remediation. Terry Labach, IST Security Team

Securing Apache Tomcat. AppSec DC November The OWASP Foundation

Sichere Software vom Java-Entwickler

Finding Vulnerabilities in Source Code

Client Side Security And Testing Tools

IronWASP (Iron Web application Advanced Security testing Platform)

CYSE 411/AIT681 Secure Software Engineering Topic #12. Secure Coding: Formatted Output

2/9/18. CYSE 411/AIT681 Secure Software Engineering. Readings. Secure Coding. This lecture: String management Pointer Subterfuge

CNIT 129S: Securing Web Applications. Ch 10: Attacking Back-End Components

Simple Overflow. #include <stdio.h> int main(void){ unsigned int num = 0xffffffff;

Certified Secure Web Application Security Test Checklist

Taking White Hats to the Laundry: How to Strengthen Testing in Common Criteria

WEB SECURITY WORKSHOP TEXSAW Presented by Solomon Boyd and Jiayang Wang

Continuously Discover and Eliminate Security Risk in Production Apps

Perslink Security. Perslink Security. Eleonora Petridou Pascal Cuylaerts. System And Network Engineering University of Amsterdam.

Secure coding practices

Threat Modeling. Bart De Win Secure Application Development Course, Credits to

SAP Security. BIZEC APP/11 Version 2.0 BIZEC TEC/11 Version 2.0

Top 10 Web Application Vulnerabilities

Information Security. Gabriel Lawrence Director, IT Security UCSD

Non conventional attacks Some things your security scanner won t find OWASP 23/05/2011. The OWASP Foundation.

Secure Programming. Input Validation. Learning objectives Code Injection: Outline. 4 Code Injection

Protect your apps and your customers against application layer attacks

EasyCrypt passes an independent security audit

1 About Web Security. What is application security? So what can happen? see [?]

The Business Case for Security in the SDLC

Transcription:

Static Analysis (SA) Track Session 1: Intro to Static Analysis Eric Dalci Cigital edalci at cigital dot com 5/07/09 Copyright The Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the License. The Foundation http://www.owasp.org

SA Track: Goals Cover the ins and outs of Static Analysis Who, What, When, Where, How, Why Provide hands-on experience using commercially available tools Provide hands-on tool customization guidance Provide guidance on organizational adoption and integration of SA into your SDLC

SA Track Roadmap SESSION 1 2 TOPIC Intro To Static Analysis Tool Assisted Code Reviews Fortify SCA Ounce Labs Lecture 2 hours Lab w/ Expert 2-3 hours 3 Customization Lab Fortify SCA Lab w/ Expert 3 hours 4 Customization Lab Ounce Labs Lab w/ Expert 3 hours 5 Tool Adoption and Deployment Lecture 2-3 hours

Background Work at Cigital Inc. And previously at NIST National Institute of Standards and Technology Software Quality Group Software Security Group I save the ugly baby

Objectives Understand why you should be using a Static Analysis tool to perform secure code review. Know what type of vulnerabilities you can scan for with a Static Analysis tool. Know the limits and strengths of Static Analysis Tools

Agenda Automated Secure Code Review Exercise Manual Code Review Static Analysis

Catching a bug: Opportunities SA: STATIC ANALYSIS TOOLS

Bug vs. Flaw Implementation bug 50%-50% Architecture flaw Source: http://www.flickr.com/photos/sensechange/521943309 Source: http://www.flickr.com/photos/savetheclocktower/172724622

Attacks on the Application Layer According to Gartner and CERT, 75 percent of security breaches occur at the Application layer. And from 2005 to 2007 alone, the U.S. Air Force says application hacks have increased from 2 percent to 33 percent of the total number of attempts to break into its systems. Source: Gartner IT Services Forecast, 2007

What s in the code? Assumptions Ex : This function call will never fail Function calls Ex : X calls Y which calls Z which calls System.exit() Settings Ex: Forward requests from www.blah.com/admin to the servlet userrequest Input data handling Ex: Hello ${userinput.name}! Error handling Ex: Catch(Exception err) { System.out.println( Something bad happened: + err.printstacktrace() ) } Vulnerabilities?

Type of automated code analysis Type checking Style checking Property Checking Program understanding Bug finding (Quality) Security Review

Automated Code Review Automated Code Review (Pros and Cons) [+] Relatively Fast [+] Can be very efficient (high number of findings) [+] Integrated with IDE trace analysis, bug information, etc. [+] Bring Security knowledge to the developers Propose remediation to bugs [+] Consistent badnessometer [-] Require human intervention to discriminate false/true positive [-] High level of false positives [-] Many false negatives remain (depending on the tool s coverage) [-] False sense of security

Static Analysis Internals How does it work? Auditor s inputs Incremental Analysis Build Model Perform Analysis Source Code Notes : The Incremental analysis is not possible with all SA tools Findings Security Knowledge

Code review : Let s find some bugs EXERCISES

Exercise: Security Review - 1/5 What s wrong with this code? #define MAXSIZE 40 int main(int argc, char **argv) { char buf[maxsize]; if(gets(buf)) printf("result: %s\n", buf); return 0; } The problems could be found with Semantic analysis Data flow analysis

Exercise: Security Review - 2/5 The following XML configuration file setup the session timeout for a web application. What s wrong with this setting? <web-app> <session-config> <session-timeout>180</session-timeout><!-- time in minutes --> </session-config> </web-app> This could be discovered with a configuration analysis (Xpath)

Exercise: Security Review - 3/5 What s wrong with this code? char* ptr = (char*)malloc (SIZE); if (abrt) { } free(ptr); free(ptr); This could be found with a control flow analysis

Exercise: Security Review - 4/5 What s wrong with this code? Public static boolean getuserssn(string Id) { Connection con = null; Try{ // instantiate Connection Statement st = con.createstatement(); ResultSet rs = st.executequery( Select ssn FROM tuserssn WHERE id = + Id); While (rs.next()) { // Process the query results} } This could be found with data flow analysis

Exercise: Security Review - 5/5 What s wrong with this code? public class RegisterUser extends HttpServlet { String UserName; protected void dopost (HttpServletRequest req, HttpServletResponse res) { UserName = req.getparameter(" UserName "); //process UserName out.println(username + ", thanks for visiting!"); } } This could be found with structural analysis

STATIC ANALYSIS

Code level analysis by Static Analysis tools Examples Data Flow Track user data. Great for spotting SQL injection, XSS, etc. Control Flow State machine (Safe State, Error State, etc.) Structural Identifies vulnerable code structure Semantic Analyzer Glorified grep Configuration Scan XML and.properties files Etc.

Data Flow Analysis Data flow analysis tracks data from its source to its consumption site. For a web application, data flow analysis is probably the most relevant as it is able to follow untrusted user input. Data originates from Source type of function Data is being consumed (e.g. interpreted) in Sink type of function. Entry points are directly accepting user controlled data (i.e. Inbound taint) Data flow analysis uses taint propagation techniques.

The Data-Flow Model Taint can have different origin (user input, property files, database, etc.) Tainted Data flows between Sources and Sinks.

Control flow The control flow analysis is the analysis of state and transition. We can represent a control flow using a state machine. Control flow analysis is good for finding race condition type of problem where sequence of calls matters. Examples: Open and close a resource Validate and invalidate a session ID

Control Flow Model : A State Machine Rule : Call setsecure if new Cookie is created. Start State new Cookie( name, value ); New Cookie State Cookie.setSecure(true); Secure State State machine for Secure Cookie Flag Error State

Structural analysis Structural analysis refers to a particular code construct The structural analysis can involve relation between Classes (e.g. inheritance, Class type, etc.) Language specific code construct could be analyzed for vulnerabilities or quality issues. For instance in Java, code construct such as try/ catch blocks, member field assignment, method with specific signature, return statements, etc. would be recognized.

Semantic Analysis The Semantic of code relate to the meaning of a particular code within its context. Ex: The Class Animal.Insect.Bug is different from the Class Software.Security.Bug The ancestor of semantic analysis is grep Example: In C code, a semantic analysis would find all instance of gets()

Configuration A configuration analysis applies to XML or property files. Typically properties are set in deployment descriptor. It is possible to overload/create a property at runtime, but then we will need other type of analysis to handle that code.

Exercise : What type of analysis would you apply? Check that the code always call produce() before consume() Check that there are no clear text password encoding in property files Check that no User controlled data ends up in the variable command : Runtime.getRuntime().exec(command) Check that unsafeencrypt() never get used. Check that all the finally blocks have the necessary clean up code buffer.flush().

top 10 & possible corresponding analysis 1. Cross Site Scripting (XSS) 2. Injection Flaws 3. Malicious File Execution 4. Insecure Direct Object Reference 5. Cross Site Request Forgery (CSRF) 6. Information Leakage and Improper Error Handling 7. Broken Authentication and Session Management 8. Insecure Cryptographic Storage 9. Insecure Communications 10. Failure to Restrict URL Access 1. Data Flow Analysis 2. Data Flow Analysis 3. Data Flow Analysis 4. Data Flow Analysis 5. NA 6. All 5 analysis 7. Control Flow 8. Structural, Semantic 9. Structural, Semantic 10. Configuration

SA tools Dirty little secret Without special engineering, SA tools can t follow the flow of control or data when it s not explicit in the code. For Web 2.0 and mashup don t even ask the news is even worse. Resources: Spring Framework s vulnerability www.springsource.com/securityadvisory

More examples of SA tools limits Ignore what you do well and their impact to the rest of the findings Ex..NET Request Validation is turned on, but the tool ignore it and report injection type of problems. No bridge between declarative and programmatic security Ex: XML, <Property secure= true /> Ex: Code, Property.set( secure, false )

And more We talked about what you can t cheaply detect business logic problems Flaws Just because it was detected, doesn t mean it s exploitable (or discoverable, externally)

Tool coverage Visible in the Code Visible in the design Generic defects SA tools sweet spot. Tools built-in rules should find those issues. Ex: Buffer Overflow Most likely found through Architecture analysis Ex: The program sends credentials in clear text Context- Specific defects The tools needs to be customized to understand context specific functions and rules. Ex: Processing of Trade order Require understanding of general security principles and context specific knowledge Ex: Trading data not sanitized properly for Personal information and visible to third party

How to improve a tool s results? Customize (Rules, Engines, Filters, etc.) Extend the tool s coverage: Write custom rules Access the engine API Use given rule grammar to write new rules Feed information to the model (dynamic model change) Example: defining validation functions

Future evolution SA Tool should help code understanding SA Tools should help manual code review (Hybrid code review). They should point to interesting part of the code (e.g. Point of Interests ) Rule extension should be easier Code visualization should help architecture review Querying the SA Model should almost be like natural languages (maybe like a search engine.google you code!?)

Q/A Thank you!