An Efficient Black-box Technique for Defeating Web Application Attacks



Similar documents
Protection, Usability and Improvements in Reflected XSS Filters

Cross Site Scripting Prevention

CHAPTER 5 INTELLIGENT TECHNIQUES TO PREVENT SQL INJECTION ATTACKS

Document Structure Integrity: A Robust Basis for Cross-Site Scripting Defense

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

Web Application Security

XSS-GUARD : Precise Dynamic Prevention of Cross Site Scripting (XSS) Attacks

3. Broken Account and Session Management. 4. Cross-Site Scripting (XSS) Flaws. Web browsers execute code sent from websites. Account Management

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

Development and Industrial Application of Multi-Domain Security Testing Technologies. Innovation Sheet Model Inference Assisted Evolutionary Fuzzing

How To Prevent An Sql Injection Attack

A Tale of the Weaknesses of Current Client-Side XSS Filtering

Finding Your Way in Testing Jungle. A Learning Approach to Web Security Testing.

Webapps Vulnerability Report

Cross Site Scripting (XSS) and PHP Security. Anthony Ferrara NYPHP and OWASP Security Series June 30, 2011

Java Program Vulnerabilities

Detect and Sanitise Encoded Cross-Site Scripting and SQL Injection Attack Strings Using a Hash Map

Towards More Security in Data Exchange

How I hacked PacketStorm ( )

Web Application Security

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

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

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

Web applications. Web security: web basics. HTTP requests. URLs. GET request. Myrto Arapinis School of Informatics University of Edinburgh

Watch What You Write: Preventing Cross-Site Scripting by Observing Program Output

What is Web Security? Motivation

Application Security Testing. Erez Metula (CISSP), Founder Application Security Expert

Web Application Attacks And WAF Evasion

Check list for web developers

RIPS - A static source code analyser for vulnerabilities in PHP scripts

External Network & Web Application Assessment. For The XXX Group LLC October 2012

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

Defending against Injection Attacks through Context-Sensitive String Evaluation

An Effective Approach for Detecting and Preventing Sqlinjection Attacks

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

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

Automating Security Testing. Mark Fallon Senior Release Manager Oracle

SECURE APPLICATION DEVELOPMENT CODING POLICY OCIO TABLE OF CONTENTS

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

SANS Dshield Webhoneypot Project. OWASP November 13th, The OWASP Foundation Jason Lam

Using Foundstone CookieDigger to Analyze Web Session Management

OWASP and OWASP Top 10 (2007 Update) OWASP. The OWASP Foundation. Dave Wichers. The OWASP Foundation. OWASP Conferences Chair

Magento Security and Vulnerabilities. Roman Stepanov

Precise client-side protection against DOM-based Cross-Site Scripting

Detection and mitigation of Web Services Attacks using Markov Model

EVALUATING COMMERCIAL WEB APPLICATION SECURITY. By Aaron Parke

Automatic vs. Manual Code Analysis

Web application security

Out of the Fire - Adding Layers of Protection When Deploying Oracle EBS to the Internet

Playing with Web Application Firewalls

Advanced Administration for Citrix NetScaler 9.0 Platinum Edition

A Server and Browser-Transparent CSRF Defense for Web 2.0 Applications. Slides by Connor Schnaith

SQL Injection Attack. David Jong hoon An

Detection of SQL Injection Attacks by Combining Static Analysis and Runtime Validation

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

Columbia University Web Security Standards and Practices. Objective and Scope

A Tale of the Weaknesses of Current Client-side XSS Filtering

Homeland Security Red Teaming

FINAL DoIT v.8 APPLICATION SECURITY PROCEDURE

elearning for Secure Application Development

Detection and Prevention of SQL Injection Attacks

Using Nessus In Web Application Vulnerability Assessments

Systematically Enhancing Black-Box Web Vulnerability Scanners

Agenda. SQL Injection Impact in the Real World Attack Scenario (1) CHAPTER 8 SQL Injection

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

Security Test s i t ng Eileen Donlon CMSC 737 Spring 2008

Where every interaction matters.

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

Bayesian Classification for SQL Injection Detection

Swaddler: An Approach for the Anomaly-based Detection of State Violations in Web Applications

Put a Firewall in Your JVM Securing Java Applications!

Sania: Syntactic and Semantic Analysis for Automated Testing against SQL Injection

Generating Effective Attacks for Efficient and Precise Penetration Testing against SQL Injection

Robust Defence against XSS through Context Free Grammar

Web Intrusion Detection with ModSecurity. Ivan Ristic

Web Application Security

Common Criteria Web Application Security Scoring CCWAPSS

Integrating VoltDB with Hadoop

Acunetix Website Audit. 5 November, Developer Report. Generated by Acunetix WVS Reporter (v8.0 Build )

Introduction to Computer Security

Input Validation Vulnerabilities, Encoded Attack Vectors and Mitigations OWASP. The OWASP Foundation. Marco Morana & Scott Nusbaum

A Multi agent Scanner to Detect Stored XSS Vulnerabilities

Perl In Secure Web Development

Basic & Advanced Administration for Citrix NetScaler 9.2

Hardening Joomla 1. HARDENING PHP. 1.1 Installing Suhosin. 1.2 Disable Remote Includes. 1.3 Disable Unneeded Functions & Classes

INTRUSION PROTECTION AGAINST SQL INJECTION ATTACKS USING REVERSE PROXY

WSF: An HTTP-level Firewall for Hardening Web Servers

Web Application Report

HOD of Dept. of CSE & IT. Asst. Prof., Dept. Of CSE AIET, Lko, India. AIET, Lko, India

Web Application Security Assessment and Vulnerability Mitigation Tests

Application Design and Development

EC-Council CAST CENTER FOR ADVANCED SECURITY TRAINING. CAST 619 Advanced SQLi Attacks and Countermeasures. Make The Difference CAST.

Web Application Firewall Bypassing

Transcription:

2/9/2009 An Efficient Black-box Technique for Defeating Web Application Attacks R. Sekar Stony Brook University (Research supported by DARPA, NSF and ONR)

Example: SquirrelMail Command Injection Attack: use maliciously crafted input to exert unintended control over $send_to_list = output operations $_GET[ sendto ] Detect exertion of control Based on taint: $command degree = gpg to -r $send_to_list which output depends on 2>&1 input Detect if control is intended: Requires policies popen($command) Application-independent policies are preferable Incoming Request (Untrusted input) Program sendto= nobody; rm rf * $command= gpg r nobody; rm rf * 2>&1 popen($command) Attack: Removes files Outgoing Request/Response (Security-sensitive operations) (To databases, backend servers, command interpreters, files, ) 2/9/2009 2

Attack Space of Interest (CVE 2006-07) Others 24% Config/Race errors 1% Format string 1% Memory errors 10% SQL injection 14% Input validation/ DoS 9% Directory traversal 4% Cross-site scripting 19% Command injection 18% Generalized Injection Attacks 2/9/2009 3

Drawbacks of Taint-Tracking and Motivation for Our Approach Intrusive instrumentation Transform every statement in target application Can potentially impact stability and robustness High performance overheads Often slow down programs by 2x or more Language dependence E.g., they apply either to Java or C/C++ 2/9/2009 4

Approach Overview Internet Web Server (IIS/ Apache) Protected System Web App (PHP, Java, C, C++, ) Database/ Backend server Syntax Analysis Decode HTTP parameters, cookies, Construct parse trees for SQL, HTML, Taint Inference Based on approximate substring matching Interceptors System Libraries Attack Detection Syntax and taint-aware policy enforcement Efficient, language-neutral, and non-intrusive Consists of 2/9/2009 5 Taint-inference: Black-box technique to infer taint by observing inputs and outputs of protected apps Syntax- and Taint-aware policies for detecting unintended use of tainted data

Syntax Analysis: Input Parsing Inputs: Parse into components Request type, URL, form parameters, cookies, Exposes more of protocol semantics to other phases All information mapped to (name, value) pairs Normalize formats to avoid effect of various encoding schemes To cope with evasion techniques To ensure accuracy of taint-inference Our implementation uses ModSecurity code 2/9/2009 6

Syntax Tree Construction Outputs: Pluggable architecture to parse different output languages HTML, SQL, Shell scripts, Use rough parsing, since accurate parsers are: time-consuming to write may not gracefully handle: errors (especially common in HTML), or language extensions and variations (different shells, different flavors of SQL) Map to a language-neutral representation Implemented using standard tools (Flex/Bison) 2/9/2009 7

Taint Inference Infer taint by observing inputs and outputs Allow for simple transformations that are common in web applications Space removal (or replacement with _ ) Upper-to-lower case transformation, quoting or unescaping, Other application-specific changes SquirrelMail, when given the to field value alice, bob; touch /tmp/a produces an output -r alice@ -r bob; touch /tmp/a Solution: use approximate substring matching 2/9/2009 8

Taint Inference Algorithm Standard approximate substring matching algorithms have quadratic time and space complexity Too high, since inputs and outputs can be quite large Our contribution A linear-time coarse-filtering algorithm More expensive edit-distance algorithm invoked on substrings selected by coarse-filtering algorithm The combination is effectively linear-time Ensures taint identification if distance between two strings is below a user-specified threshold d Contrast with biological computing tools that provide speed up heuristics, but no such guarantee 2/9/2009 9

Coarse-filtering to speed up Taint Inference Definition of taint: A substring u of t is tainted if ED(s, u) < d Here, ED denotes the edit-distance Key idea for coarse-filtering: Approximate ED by ED #, defined on length s substrings of t Let U (and V) denote a multiset of characters in u (resp., v) ED # (u, v) = min( U-V, V-U ) Slide a window of size s over t, compute ED # incrementally Prove: ED(s, r) < d ED # (s, r) < d for all substrings r of t Result: O( s 2 ) space in worst-case performs like a linear-time algorithm in practice 2/9/2009 10

Overview of Syntax+Taint-aware Policies Leverage structure+taint to simplify/generalize policy Policy structure mirrors that of syntax trees And-Or trees (possibly with cycles) Can specify constraints on values (using regular expressions) and taint associated with a parse tree node ELEMENT NAME = script OR PARAM ELEM_BODY PARAM_NAME= src PARAM_VALUE 1. Policy for detecting XSS 2/9/2009 11

Injection attacks and Syntax-aware policies root root cmd cmd cmd name param param name param param separator name param param gpg -r sekar@ abc.com gpg -r nobody ; rm -rf * (2) SpanNodes policy: captures lexical confinement tainted data to be contained within a single tree node (3) StraddleTrees policy: captures overflows Both are default deny policies Tainted data begins in the middle of one syntactic structure (subtree), then flows into next subtree 2/9/2009 12

Further Optimization: Pruning Policies Most inputs are benign, and cannot lead to violation of policies Policies constrain tainted content, which comes from input Thus, policies implicitly constrain inputs Approach: Define pruning policies that make these implicit constraints explicit Pruning policies identify subset of inputs that can possibly lead to policy violation For other inputs, we can skip taint inference as well as policy checking algorithms 2/9/2009 13

Evaluation: Applications and Policies Application Language LOC (Size) Environment Attacks Notes phpbb PHP/C 34K Apache or IIS w/mysql SquirrelMail PHP/C 35K/42K Apache or IIS XMLRPC (library) PHP/C 2K Apache or IIS Apps from gotocode.com Java/C 30K Apache+Tomcat w/ MySQL WebGoat Java/C Tomcat DARPA RedTeam App SQL inj Shell command inj, XSS PHP command inj SQL inj (21K attacks. 4K legitimate) command inj, HTTP response splitting PHP 2K Apache SQL inj Popular realworld apps. Exploits from the wild. Attacks by [Halfond et al] App developed by Red Team We used the 3 policies described earlier in the talk

False Negatives (and Detection Results) Occur due to Complex application-specific data transformations Protocol/language-specific transformations handled Second-order attacks (data written into persistent store, read back subsequently, and used in security-sensitive operations) A limitation common to taint-based approaches Experimental results: Detected all attacks in experiments with the exception of a single second-order injection attack in Red Team evaluation Shell and PHP command injections and XSS on ~21K SQL injection attacks on 5 moderate-size JSP applications (AMNESIA [Halfond et al] dataset) HTTP response splitting on WebGoat 2/9/2009 15

False Positives Result of coincidental matches (in taint-inference) Can be controlled by setting the distance threshold d based on the desired false positive probability Likelihood small even for short strings No false positives reported in experiments Implication Can use large distances for moderate-size strings (len > 10), thus tolerating significant input transformations 1.E+00 1.E-01 1.E-02 1.E-03 1.E-04 1.E-05 1.E-06 1.E-07 0 10 20 30 40 50 60 70 d=0, a=40 d=0.3, a=40 d=0.7,a=70 d=0.7,a=40 2/9/2009 16

Taint inference overhead Coarse filtering optimization 10x to 20x improvement in speed in experiments 50x to 1000x reduction in space time spent in coarse filtering (linear-time algorithm) exceeds time spent inside edit-distance algorithm performance decreases with large values of distance When coincidental probability increases beyond 10-6 2/9/2009 17

Overhead of different phases 60% spent in taint inference After coarse-filtering optimization 20% in parsing 20% in policy checking Overhead of interposition not measured but assumed to be relatively small because of reliance on library interposition 2/9/2009 18

End-to-end Performance Overhead Measured using AMNESIA [Halfond et al] dataset on utility applications from gotocode.com Performance measured with pruning filters deployed ~5x performance improvement due to pruning Application Size # of Response Overhead (LOC) Requests time (sec) Bookstore 9552 605 20.7 1.7% Empldir 3028 660 17.3 3.4% Portal 8775 1080 31.7 5.1% Classifieds 5726 576 18.0 4.3% Events 3805 900 23.0 3.1% Total 30886 3821 110.7 3.5% 2/9/2009 19

Related Work Su and Wasserman [2006] Focus on formal characterization of SQL injection Our contributions A robust, application-independent technique to infer taint propagation Policies decoupled from grammar Applicable to many languages Dataflow anomaly detection [Bhatkar et al 2006] Flow inference algorithms tuned for simpler data (file names, file descriptors, ) Program transformations for taint-tracking And related approaches (AMNESIA, CANDID, ) Require deep analysis/instrumentation of applications 2/9/2009 20

Summary A black-box alternative for taint-tracking on web applications A simple, language-neutral policy framework Ability to detect a wide range of exploits across different languages (Java, C, PHP, ) and platforms (Apache, Tomcat, IIS, ) with just a few general policies Low performance overheads (below 5%) 2/9/2009 21