The Dark Side of Ajax. Jacob West Fortify Software



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

WEB SECURITY CONCERNS THAT WEB VULNERABILITY SCANNING CAN IDENTIFY

Detecting and Defending Against Security Vulnerabilities for Web 2.0 Applications

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

Finding and Preventing Cross- Site Request Forgery. Tom Gallagher Security Test Lead, Microsoft

Introduction to Computer Security

Where every interaction matters.

Web-Application Security

Detecting and Exploiting XSS with Xenotix XSS Exploit Framework

Chapter 1 Web Application (In)security 1

Javascript Security, XSS, and Uncovered Topics. Pat Morin COMP 2405

Integrating Web Application Security into the IT Curriculum

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

Hack Proof Your Webapps

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

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

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

Exploiting Web 2.0 Next Generation Vulnerabilities

What is Web Security? Motivation

Magento Security and Vulnerabilities. Roman Stepanov

Web Application Worms & Browser Insecurity

White Paper. Understanding Web 2.0. Technologies, Risks, and Best Practices

Criteria for web application security check. Version

Security Research Advisory IBM inotes 9 Active Content Filtering Bypass

HTTPParameter Pollution. ChrysostomosDaniel

Recommended Practice Case Study: Cross-Site Scripting. February 2007

Web application testing

Security features of ZK Framework

Bug Report. Date: March 19, 2011 Reporter: Chris Jarabek

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

Security Products Development. Leon Juranic

WEB ATTACKS AND COUNTERMEASURES

Adobe Systems Incorporated

Ruby on Rails Secure Coding Recommendations

Sitefinity Security and Best Practices

AJAX Storage: A Look at Flash Cookies and Internet Explorer Persistence

Network Security Exercise #8

Cross Site Scripting Prevention

THE SMARTEST WAY TO PROTECT WEBSITES AND WEB APPS FROM ATTACKS

EVALUATING COMMERCIAL WEB APPLICATION SECURITY. By Aaron Parke

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

Introduction:... 1 Security in SDLC:... 2 Penetration Testing Methodology: Case Study... 3

The Prevalence of Flash Vulnerabilities on the Web

(WAPT) Web Application Penetration Testing

DNS Pinning and Web Proxies

Java Web Application Security

Web Application Security

Ethical Hacking as a Professional Penetration Testing Technique

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

Cross-Site Scripting

National Information Security Group The Top Web Application Hack Attacks. Danny Allan Director, Security Research

DNS REBINDING DENIS BARANOV, POSITIVE TECHNOLOGIES

Web Application Security 101

Sichere Webanwendungen mit Java

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

Web Application Security

The Top Web Application Attacks: Are you vulnerable?

STOPPING LAYER 7 ATTACKS with F5 ASM. Sven Müller Security Solution Architect

Blackbox Reversing of XSS Filters

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

Intrusion detection for web applications

CS 558 Internet Systems and Technologies

RTC-Web Security Considerations

IJMIE Volume 2, Issue 9 ISSN:

Security Model for the Client-Side Web Application Environments

Barracuda Web Application Firewall vs. Intrusion Prevention Systems (IPS) Whitepaper

5 Mistakes to Avoid on Your Drupal Website

Learn Ethical Hacking, Become a Pentester

Secure Programming with Static Analysis. Jacob West

Cracking the Perimeter via Web Application Hacking. Zach Grace, CISSP, CEH January 17, Mega Conference

OWASP AND APPLICATION SECURITY

OWASP Top Ten Tools and Tactics

Pwning Intranets with HTML5

Application Code Development Standards

Hacking Intranet Websites from the Outside (Take 2) Fun With & Without JavaScript Malware

Revisiting SQL Injection Will we ever get it right? Michael Sutton, Security Evangelist

AJAX. Gregorio López López Juan Francisco López Panea

Network Security Audit. Vulnerability Assessment (VA)

Application security testing: Protecting your application and data

AJAX and JSON Lessons Learned. Jim Riecken, Senior Software Engineer, Blackboard Inc.

Web Application Penetration Testing

Thomas Röthlisberger IT Security Analyst

Web Application Vulnerability Testing with Nessus

Developing ASP.NET MVC 4 Web Applications MOC 20486

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

Penetration Test Report

Information Supplement: Requirement 6.6 Code Reviews and Application Firewalls Clarified

Web Application Security

Course Content: Session 1. Ethics & Hacking

Network Security Web Security

elearning for Secure Application Development

SESSION IDENTIFIER ARE FOR NOW, PASSWORDS ARE FOREVER

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

Table of Contents. Open-Xchange Authentication & Session Handling. 1.Introduction...3

Integrated Network Vulnerability Scanning & Penetration Testing SAINTcorporation.com

Project 2: Web Security Pitfalls

Preparing for the Cross Site Request Forgery Defense

Gateway Apps - Security Summary SECURITY SUMMARY

Transcription:

The Dark Side of Ajax Jacob West Fortify Software

Mashup Pink Floyd Dark Side of the Moon AJAX all purpose cleaner

Ajax! " Fancier and easier-to-use web applications using: Asynchronous JavaScript And XML! " Matter of degree, not kind Server (smart) Web 1.0 Ajax Web page (dumb) Server (smart) Web page (smart)

Success is foreseeing failure Henry Petroski

Cross-Site Scripting <c:if test="${param.sayhello}"> Hello ${param.name}! </c:if> We never intended the code that's in there to actually be production-ready code. - Ryan Asleson

Reliving Past Mistakes! " Cross-site scripting looks more and more like buffer overflow Buffer Overflow! " Allows arbitrary code execution! " Easy mistake to make in C/C++! " Exploit is hard to write! " Well known problem for decades Cross-site Scripting! " Allows arbitrary code execution! " Easy mistake to make! " Exploit is easy to write! " Well known problem for a decade

What s Wrong with Ajax?! " Today s rage or tomorrow s security disaster?! " Could more JavaScript possibly be better?! " Sample of the almost 400 JavaScript CVE entries: CVE-2007-1794: The Javascript engine in Mozilla 1.7 and earlier can allow remote attackers to execute arbitrary code. CVE-1999-0793 Internet Explorer allows remote attackers to read files by redirecting data to a Javascript applet. CVE-1999-0790 A remote attacker can read from a Netscape user's cache via JS CVE-1999-0347 Internet Explorer 4.01 allows remote attackers to read local files and spoof web pages via a "%01" character in an "about:" Javascript URL, which causes Internet Explorer to use the domain specified

Overview! " Introduction! " Ajax for! " Developers! " Hackers! " Risks! " Old! " New! " State of the frameworks! " Automated protections! " The future of Ajax

AJAX FOR DEVELOPERS

Ajax From the Programmer s Perspective! " Increased complexity makes frameworks attractive! " Popular toolkits for Ajax development include:! " Google Web Toolkit (GWT)! " Direct Web Remoting (DWR)! " Microsoft ASP.NET AJAX (Codename Atlas)! " Client-side libraries (e.g. Prototype and Dojo)! " Also popular: ad-hoc Ajax (roll-your-own)

Back-of-the-Napkin Analysis high Ad-hoc Atlas DWR low GWT high

Ajax - The Case of the Vanishing X! " XML being replaced by more JavaScript/JSON XML JSON <book> <title>javascript, the Definitive Guide</title> <publisher>o'reilly</publisher> <author>david Flanagan</author> <cover src="/images/cover_defguide.jpg" /> <blurb>elit.</blurb> </book> { "book": { "title":"javascript, the Definitive Guide", "publisher":"o'reilly", "author":"david Flanagan", "cover":"/images/cover_defguide.jpg", "blurb": elit." } }

AJAX FOR HACKERS

Ajax For Malware! " Exploit writers buy JavaScript books too! " Web 2.0 exploits for Web 1.0 vulnerabilities! " MySpace worm! " Port scanning behind your firewall! " Jikto

MySpace Worm - 1/3! " MySpace does bad input validation! " Users to post a subset of HTML on their pages! " No <script> tags, no use of the word javascript, etc

MySpace Worm - 2/3! " User Samy discovers some holes! " Some browsers allow JavaScript in style attributes! " Some browsers interpret java\nscript as javascript! " Circumvents MySpace's efforts to prevent JavaScript

MySpace Worm - 3/3! " Samy adds JavaScript (Ajax) to his page! " Visitors to his page automatically add Samy as a friend and inserts Samy is my hero into their profile! " Visitors to a page where Samy is a friend take the same actions! " MySpace goes down

Port Scanning Behind Firewalls - 1/2 Server 1) show me dancing pigs! 2) check this out Malicious Web page scan 3) port scan results scan Browser scan Firewall

Port Scanning Behind Firewalls - 2/2! " Request images from internal IPs (<img src= 192.168.0.4:8080 />! " Use timeout/onerror to determine if hosts respond! " <iframe/> with timer/onload to map web servers! " Fingerprint webapps using known image names

Jikto - 1/2! " JavaScript vulnerability scanner (Billy Hoffman with credit to pdp for crawler)! " Spreads like worm over XSS vulnerabilities! " Uses Google as proxy to bypass same origin policy! " Same Origin Policy: basis for browser security! " JavaScript can't see content from other domains! " Protects sites from each other

Jikto - 2/2 "Infected" page Target Site Google Translate attack Victim Malicious Site vulnerability scanner

Moral to the Story! " No new vulnerabilities here, just better exploits! " Good offense makes good defense more important! " Good offense is making fast progress

OLD RISKS RECONSIDERED

Defending Ajax: Old Risks Reconsidered New name, same game! " Old vulnerabilities, new programming language! " Input validation! " Exposing the server

Old Vulnerabilities, New Language Cross-site scripting in pure JavaScript: q = location.search.split( q= )[1]; q = unescape(q); div.innerhtml = searching for + q;

Old Risks: Input validation - 1/3 Easy to lose track of where validation is performed Server Client

Old Risks: Input validation - 2/3! " More entry points on the server! " More, smaller, requests! " Decentralized design! " Easy to over-expose

Old Risks: Input validation - 3/3! " More subtle entry points on the server! " Looks like Web services! " Hard to tell if method call initiated locally (safe) or remotely (dangerous)! " Harder to tell what can be trusted

Old Risk: Exposing Yourself! " Example: DWR <dwr> <allow>... <create creator= new javascript= ApartmentDAO class= dwr.sample.apartmentdao > <exclude method= countapartments /> </create> </allow> </dwr>

NEW PROBLEMS

New: Harder to Test! " Dirty-data shooters rely on Web 1.0 conventions! " HTTP! " HTML forms! " 1 parameter = 1 application variable! " Ajax = more complex data structures! " Ajax requires sophisticated browser emulation! " How do you spider an Ajax application?! " Looks much more like testing conventional software

Old: Cross-Site Request Forgery (CSRF)! " Cross-Site Request Forgery! " JavaScript submits HTTP requests on victim's behalf! " Allows attacker to submit commands, but not inspect the response (Same Origin Policy)! " Application is vulnerable if it:! " Relies on user s identity (e.g. persistent or session cookies)! " Does not have secondary authentication mechanism! " Attack against data integrity

New: JavaScript Hijacking - 1/2! " Builds on CSRF! " Breaks confidentiality through loophole in SOP! " Vulnerable if:! " Site responds to HTTP GET! " Transmits sensitive data in JavaScript syntax

New: JavaScript Hijacking - 2/2 Ajax Application Malicious Server GET 1) show me dancing pigs! 2) check this out Mal page { witness code } <script src=... > JavaScript 3) confidential data Browser

Defenses Against JavaScript Hijacking! " Prevent CSRF! " Decline malicious requests by requiring unique token and remember! " Default to POST not enough (Developers add GET so that result can be cached)! " Check for a known HTTP header not enough (Flash CSRF vulnerability)! " Prevent execution of JavaScript! " while(1);, /*... */, etc and remember! " calling parsejson() rather than eval() does not help

STATE OF THE FRAMEWORKS

How 12 Popular Frameworks Stack Up Framework Summary Prevents JavaScript Hijacking? Prototype Script.aculo.us Supports JSON. Defaults to POST when no method is specified, but is easily customizable for using either POST or GET. Supports JSON. Provides additional UI controls and uses the Prototype library for generating requests. Dojo Supports JSON. Defaults to POST, but does not explicitly prevent JavaScript Hijacking. No DWR 1.1.4 Uses an expanded version of JSON. Does not implement any JavaScript Hijacking prevention mechanisms. Moo.fx Supports JSON. Defaults to POST, but can easily be configured to use GET. No jquery Supports JSON. Defaults to GET. No Yahoo! UI Supports JSON. Responds to GET requests. No Rico Microsoft Atlas Does not currently support JSON, but will in the future. Supports XML as a data transfer format. Defaults to GET. Supports JSON. Uses POST by default, but allows programmers to easily change POST to GET and encourages doing so for performance and caching. MochiKit Supports JSON. Defaults to GET. No xajax Does not currently support JSON. Supports XML as a data transfer format. N/A GWT Supports JSON. Uses POST by default; however, documentation describes how to make GET requests instead and does not mention any security ramifications. No No No N/A No No

Popular Framework Responses - 1/3! " We will fix it! " Thanks for the heads up on this! " Thanks for the paper. We are looking at the issue, and we re starting to formulate some solutions that mesh well with what you re suggesting

Popular Framework Responses - 2/3! " This is not a client-side framework problem! " Entirely dependent on the server to do the right thing! " Why the hell should there be security documentation in client frameworks?! " I added comment stripping support so that people would shut up, not because it s useful in theory or practice

Popular Framework Responses - 3/3! " You are recommending bad practices! " But by recommending bad practices, and by failing to strongly recommend good practices, you are making things worse

Proof is in the Pudding Head-in-the-sand defense! " 3 releases that contain a fix:! " Dojo 0.4.3! " Implemented /* */, but! " Only for JSON, not JavaScript! " DWR 2.0! " Implemented double-cookie submission! " Accepted our /* */ patch! " Prototype 1.5.1! " Implemented /* */! " 3 frameworks planned a fix:! " GWT! " MochiKit! " Script.aculo.us

Also Good! " 4 mentioned in documentation:! " dojotoolkit.org/2007/04/02/note-javascript-hijacking! " getahead.org/dwr/security/script-tag-protection! " www.prototypejs.org/learn/json! " developer.yahoo.com/security/

AUTOMATED PROTECTIONS

Static Analysis (Fortify SCA)! " Challenge:! " Lacking standard way to build dynamic JavaScript! " Identify the use of vulnerable frameworks! " API calls! " Configuration files! " Source files! " Identify construction of JavaScript responses! " response.setcontenttype( text/javascript )

Real-Time Analysis (Fortify RTA)! " Guard to prevent CSRF! " Insert CSRF token on the page using JavaScript! " Verify the unique token is present in requests

CONCLUSIONS

Confusion over JavaScript Hijacking! " A system administration problem! " Not unique just a way to parse results of CSRF! " Not interesting just View Source! " JavaScript Hijacking can be prevented by:! " Defaulting to HTTP POST! " Using parsejson() instead of eval()! " Using object notation {} rather than array notation []! " Checking for application/json in content-type

The Future of Ajax - 1/2! " Frameworks offer a chance to build security in! " Prevent CSRF! " Provide secure defaults! " Opportunity for better validation! " Better separation between display and controller! " Better definition for browser/server interaction

The Future of Ajax - 2/2! " Better Web standards! " Cookies: broken, need *working* HTTP only cookies! " Browsers: broken, need to distinguish between scripts from different domains! " Flash?! " Documented security best-practices! " Hard to mistake data and code! " Well-defined system for cross-domain communication

Mashups Aren t Secure! " Scripts from multiple domains == security problem! " Fine for maps, not okay for confidential data Pink Floyd Dark Side of the Moon AJAX all purpose cleaner

Summary! " Ajax: a matter of degree! " Attack techniques improving quickly! " Technology pushed well past original design goals! " Old best practices still apply! " Don t trust the client! " Protect the server! " New challenges! " Harder to test! " More complexity == more room for error! " A new ally! " Build security into Ajax frameworks

Jacob West! jacob@fortify.com"