Context-Sensitive Auto-Sanitization In Web Templating Languages Using Type Qualifiers Prateek Saxena UC Berkeley Mike Samuel Google Dawn Song UC Berkeley.

Slides:



Advertisements
Similar presentations
Copyright 2001, ActiveState. XSLT and Scripting Languages or…XSLT: what is everyone so hot and bothered about?
Advertisements

Ben Livshits and Úlfar Erlingsson Microsoft Research.
Appeared in 30 th IEEE Symposium on Security and Privacy, May Authors: Mike Ter Louw and V.N. Venkatakrishnan Dept. of Computer Science: University.
Microsoft Research March 20, 2000 A Programming Language for Developing Interactive Web Services Claus Brabrand BRICS, University of Aarhus, Denmark.
Session ID: Session Classification: Romain Gaucher Coverity ASEC-F42 Intermediate Why Haven’t We Stamped Out SQL Injection and XSS Yet?
Java Script Session1 INTRODUCTION.
THE BROKEN WEB A Systematic Analysis of XSS Sanitization in Web Application Frameworks.
0 The Past, Present and Future of XSS Defense Jim Manico 2011 OWASP Brussels.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
GATEKEEPER MOSTLY STATIC ENFORCEMENT OF SECURITY AND RELIABILITY PROPERTIES FOR JAVASCRIPT CODE Salvatore Guarnieri & Benjamin Livshits Presented by Michael.
1 Yinzhi Cao, Zhichun Li *, Vaibhav Rastogi, Yan Chen, and Xitao Wen Labs of Internet Security and Technology Northwestern University * NEC Labs America.
The XSS Files Find, Exploit, and Eliminate. Josh Little Security Engineer at global vertical market business intelligence company. 9 years in application.
Web Server Programming
Presented by Vaibhav Rastogi.  Advent of Web 2.0 and Mashups  Inclusion of untrusted third party content a necessity  Need to restrict the functionality.
An Evaluation of the Google Chrome Extension Security Architecture
SOFTWARE SECURITY JORINA VAN MALSEN 1 FLAX: Systematic Discovery of Client-Side Validation Vulnerabilities in Rich Web Applications.
S CRIPT G ARD Automatic Context-Sensitive Sanitization for Large-Scale Legacy Web Applications Prateek Saxena UC Berkeley David Molnar Microsoft Research.
Server-Side vs. Client-Side Scripting Languages
Google Web Toolkit - Gufran Mohammed. Google Web Toolkit (GWT) is an open source Java software development framework that makes writing AJAX applications.
HTML Recall that HTML is static in that it describes how a page is to be displayed, but it doesn’t provide for interaction or animation. A page created.
1 Document Structure Integrity: A Robust Basis for Cross-Site Scripting Defense Prateek Saxena UC Berkeley Yacin Nadji Illinois Institute Of Technology.
TimeTracker 2, Take 1  Servlets Web Interface (jsp) Servlet (business logic and processing) App Engine Datastore Form Submit R/W.
Introduction to the OWASP Top 10. Cross Site Scripting (XSS)  Comes in several flavors:  Stored  Reflective  DOM-Based.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Workshop 3 Web Application Security Li Weichao March
4.1 JavaScript Introduction
Vulnerability-Specific Execution Filtering (VSEF) for Exploit Prevention on Commodity Software Authors: James Newsome, James Newsome, David Brumley, David.
JavaScript Teppo Räisänen LIIKE/OAMK HTML, CSS, JavaScript HTML defines the structure CSS defines the layout JavaScript is used for scripting It.
VEX: VETTING BROWSER EXTENSIONS FOR SECURITY VULNERABILITIES XIANG PAN.
SQL INJECTION COUNTERMEASURES &
Secure Web Applications via Automatic Partitioning Stephen Chong, Jed Liu, Andrew C. Meyers, Xin Qi, K. Vikram, Lantian Zheng, Xin Zheng. Cornell University.
Automatically Hardening Web Applications Using Precise Tainting Anh Nguyen-Tuong Salvatore Guarnieri Doug Greene Jeff Shirley David Evans University of.
BLUEPRINT: Robust Prevention of Cross-site Scripting Attacks for Existing Browsers Mike Ter Louw, V.N. Venkatakrishnan University of Illinois at Chicago.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JSP Java Server Pages Softsmith Infotech.
Java Server Pages Lecture July Java Server Pages Java Server Pages (JSPs) provide a way to separate the generation of dynamic content (java)
® IBM Software Group © 2007 IBM Corporation JSP Expression Language
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 1 RubyJax Brent Morris/
Fast and Precise Sanitizer Analysis with B EK Pieter Hooimeijer Ben Livshits David Molnar Prateek Saxena Margus Veanes USENIX Security.
VB and C# Programming Basics. Overview Basic operations String processing Date processing Control structures Functions and subroutines.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
JavaScript Syntax, how to use it in a HTML document
JDojo and Its Usage Te-Hsin Shih 04/30/2013. Dojo Dojo Toolkit is an open source JavaScript library designed to ease the rapid development of cross-platform,
PwC New Technologies New Risks. PricewaterhouseCoopers Technology and Security Evolution Mainframe Technology –Single host –Limited Trusted users Security.
Chapter 10 XML and Web Services. Topics Why a standards-compliant XML parser Why a standard (off the shelf) XML parser Validation. External references.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
Implementing and Using the SIRWEB Interface Setup of the CGI script and web procfile Connecting to your database using HTML Retrieving data using the CGI.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Javascript Static Code Analyzer
ASP. ASP is a powerful tool for making dynamic and interactive Web pages An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are.
Towards Client Side HTML Security Policies Joel Weinberger, Adam Barth, Dawn Song.
Google Web Toolkit for Mobile Applications Development INGENUITY AT ITS BEST……………….
Technologies For Creating Rich Internet Applications Presenter's name
Web Security (cont.) 1. Referral issues r HTTP referer (originally referrer) – HTTP header that designates calling resource  Page on which a link is.
Introduction to.
Test Web applications using Selenium
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Automatic Web Security Unit Testing: XSS Vulnerability Detection Mahmoud Mohammadi, Bill Chu, Heather Richter, Emerson Murphy-Hill Presenter:
Theodore Lawson CSCE548 Student Presentation, Topic #2
Google Web Toolkit - Gufran Mohammed
Michael Robertson Yuta Takayama Google Closure Tools.
JavaScript an introduction.
Joel Weinberger, Prateek Saxena, Devdatta Akhawe, Matthew Finifter,
Unit 6 part 3 Test Javascript Test.
Client-Server Model: Requesting a Web Page
Web Application Development Using PHP
Mike Ter Louw, V.N. Venkatakrishnan University of Illinois at Chicago
Presentation transcript:

Context-Sensitive Auto-Sanitization In Web Templating Languages Using Type Qualifiers Prateek Saxena UC Berkeley Mike Samuel Google Dawn Song UC Berkeley 1

Script Injection Vulnerabilities OWASP Top Ten Vulnerabilities – 2 nd in 2010 & 2011 Today Affects – Major Web Services – Client-side Libraries – Browser Extensions – Devices & Smartphones 2

Predominant Defense Practice Why Does it Fail? – Developers forget to Sanitize [ Pixy06, PhpTaint06,Cqual04, Merlin09,Securifly05, PhpAspis11 ] – Pick the wrong sanitizer [ CCS11 ] 3 String Div.Render () { print( ); print(userimg); print( ); } String Div.Render () { print( ); print(Sanitize(userimg)); print( ); } Sanitizer Library Sanitizer Library

Vision Eliminate Scripting Attacks – Make Applications Secure by Construction Developer Code Developer Code Application Code Application Code 4

Contributions A New "Push-Button" Defense Primitive – "Security By Construction" Approach Context-Sensitive Auto-Sanitization (CSAS) – New Challenge: Which Sanitizers To Place Where? – Targets Existing Web Templating Frameworks It is Practical Deployed Commercially – Google Closure Templates powers Google+ 5 FastAuditableCompatibleSecure

var o = new soy.StringBuilder(); imgRender({O: o, imglink: $_GET(extlink), name: [$_GET(name)] })); document.write(o); Web Templating Frameworks Templating Framework Compiler Java JS Application calls Target Language Code Template Application Code template imgRender($imgLink, $name) { print (<img src=\); print ($imglink); print \/>. $name. ; return; } Template Code Template Language does not have complex constructs 6 Explicitly Separates Untrusted Inputs

Talk Outline System Architecture & Features Challenges The CSAS Engine Design Implementation Evaluation & Deployment 7

CSAS System Architecture Compiler Java JS Application calls Instrumented Auto-Sanitization Template Sanitizer Library Sanitizer Library Static Error 8

CSAS Auditability & Compatibility Compiler Java JS Instrumented Auto- Sanitization Sanitizer Library Sanitizer Library Static Error Easily Auditable Compatibility – No Developer Involvement – Minimize Static Errors Security Performance 9

HtmlSanitizer URLSanitizer template ImgRender($imgLink, $name) {……………} Security & Correctness (I) Property C SAN: Context-Sensitive Sanitization <img src="/img?f="/> $name$imgLink$name HTML Tag Context URI START Context URI PATH Context URI QUERY Parameter Context HTML Tag Context Attacks Vary By Contexts! 10

Security & Correctness (II) Property N OS: No Over Sanitization <img src="//img?f="/> $name$imgLink$name Sanitize Only Untrusted Data Not Constant Strings 11

Security Assumptions Canonical HTML Parser – Flexible to recognize browser differences [GWT, CTemplates] Correct Sanitizers – Extensive Community Effort [OWASP, HtmlPurify, GWT, Django] – Research on Secure Sanitization Primitives [Bek11, Hampi09,Min06] – Already Used in Many Frameworks

Challenges Easily Auditable Compatibility Security Performance Security PerformanceCompatibility 13

Approach #1: Context-Insensitive Sanitization template ImgRender($imgLink, $name) { print (<img src=); x := $imgLink; print ($x); print />. $name. ; return; } template ImgRender($imgLink, $name) { print (<img src=); x := HtmlEncode($imgLink); print ($x); print />. HtmlEncode($name ). ; return; } javascript: bad(); Security PerformanceCompatibility False Sense of Security! 14

Approach #2: Context-Sensitive Runtime Parsing (CSRP) URI START Context URI Param Context template ImgRender($imgLink, $name) {……………} <img src="/img?f= $name$imgLink URLSanitizer URLParamSanitizer Security PerformanceCompatibility 15

Rich Language Features <img src='//img?f='/> $name$imgLink$name 16 template ImgRender($imgLink, $name) { print (<img src='); x := /. $name. /img?f=. $imgLink; print ($x); print '/>. $name. ; return; }

template ImgRender($imgLink, $name) { print (<img src='); if ($name != ) then x := /. $name. /img?f=. $imgLink; else x:= $imgLink; fi print ($x); print '/>. $name. ; return; } Rich Language Features: Control Flow <img src='//img?f='/> $name$imgLink$name Usage Contexts Statically Ambiguous: Sanitization Requirements vary by path! 17

Our Approach Type Inference Well-Typed IR Untyped Template Compilation Compiled Code 18 CSAS Engine – Context Type Qualifiers

Context Type Qualifiers Context Type Qualifier: – "Which contexts is a string safe to be rendered in" x:=<img src='. $imgLink; <img src=' $imgLink y:= UrlAttribSsanitize($imgLink) x:=<img src='. y; TERMSTYPES 19 Type Inference: Where To Place Sanitizers?

Ensuring Compatibility: Key Ideas Flow-sensitive Type Qualifiers 20 template StatAmb($imgLink, $name) { if ($name == ) then print (<img src=\); else print ( ); fi print ($imgLink); } DYN STATIC CSRP Approach (1%) Statically Sanitized (99%)

Implementation & Evaluation Google Closure Templates – Powers several Google products – 3045 LOC Java Evaluation Benchmarks: – 1035 templates from production Google code – Rich Features 2997 calls 1224 print/sink statements using 600 untrusted input variables 21

Evaluation: Compatibility All 1035 templates auto-sanitized! – No Developer Involvement – No Static Errors Compared to original sanitization – 21 cases differ out of 1224 – CSAS engine inferred a more accurate sanitizer 22

Evaluation: Security Context-Insensitive Approach Fails on 28% prints 23 UNSAFE

Java JavaScript Evaluation: Performance Overhead CICSRPCSAS Chrome 93.0%78.8%3.0% FF %425%9.6% Safari 52.5%189%3.1% CICSRPCSAS Java0%72%0% 24 Order Of Magnitude Faster Than CSRP Benchmarks – Templates Only, No Other Application Logic Base: No Sanitization Practical Performance: Upto 9.6%

Conclusion 25 CSAS: A New "Push-Button" Defense Primitive – Fast, Secure, Compatible and Auditable – Increasing Commercially Adoption Other Frameworks

Thanks 26 Questions?