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



Similar documents
Detecting and Exploiting XSS with Xenotix XSS Exploit Framework

WEB SECURITY CONCERNS THAT WEB VULNERABILITY SCANNING CAN IDENTIFY

Thomas Röthlisberger IT Security Analyst

Chapter 1 Web Application (In)security 1

Magento Security and Vulnerabilities. Roman Stepanov

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

Sichere Webanwendungen mit Java

(WAPT) Web Application Penetration Testing

JVA-122. Secure Java Web Development

Web Application Report

Web-Application Security

EECS 398 Project 2: Classic Web Vulnerabilities

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

An Insight into Cookie Security

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

Where every interaction matters.

Check list for web developers

Hack Proof Your Webapps

Ruby on Rails Secure Coding Recommendations

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

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

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

Project 2: Web Security Pitfalls

Security Research Advisory IBM inotes 9 Active Content Filtering Bypass

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

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

NoSQL, But Even Less Security Bryan Sullivan, Senior Security Researcher, Adobe Secure Software Engineering Team

How to break in. Tecniche avanzate di pen testing in ambito Web Application, Internal Network and Social Engineering

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

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

Bank Hacking Live! Ofer Maor CTO, Hacktics Ltd. ATC-4, 12 Jun 2006, 4:30PM

Web Application Guidelines

Pentests more than just using the proper tools

Security Testing with Selenium

EVALUATING COMMERCIAL WEB APPLICATION SECURITY. By Aaron Parke

From the Intranet to Mobile. By Divya Mehra and Stian Thorgersen

Web application security

Testing the OWASP Top 10 Security Issues

Traitware Authentication Service Integration Document

Cyber Security Challenge Australia 2014

Login with Amazon. Developer Guide for Websites

IJMIE Volume 2, Issue 9 ISSN:

Web Security Testing Cookbook*

State of The Art: Automated Black Box Web Application Vulnerability Testing. Jason Bau, Elie Bursztein, Divij Gupta, John Mitchell

Essential IT Security Testing

ASP.NET MVC Secure Coding 4-Day hands on Course. Course Syllabus

Pentests more than just using the proper tools

Adobe Systems Incorporated

Enterprise Application Security Workshop Series

The Dark Side of Ajax. Jacob West Fortify Software

Learn Ethical Hacking, Become a Pentester

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

CS 558 Internet Systems and Technologies

Single Sign-On for the Internet: A Security Story. Eugene Tsyrklevich eugene@tsyrklevich.name Vlad Tsyrklevich vlad902@gmail.com

SESSION IDENTIFIER ARE FOR NOW, PASSWORDS ARE FOREVER

Mavituna Security Ltd. Finance House, 522A Uxbridge Rd. Pinner. HA5 3PU / UK

OWASP TOP 10 ILIA

Last update: February 23, 2004

Intunex Oy Skillhive Service Description 1 / 6

Secure Programming Lecture 12: Web Application Security III

HACKING AUTHENTICATION CHECKS IN WEB APPLICATIONS ASHISH RAO & SIDDHARTH ANBALAHAN

Protecting Web Applications and Users

elearning for Secure Application Development

Preparing for the Cross Site Request Forgery Defense

ASL IT SECURITY BEGINNERS WEB HACKING AND EXPLOITATION

WHITE PAPER FORTIWEB WEB APPLICATION FIREWALL. Ensuring Compliance for PCI DSS 6.5 and 6.6

How To Fix A Web Application Security Vulnerability

The Top Web Application Attacks: Are you vulnerable?

Cross Site Scripting in Joomla Acajoom Component

What is Web Security? Motivation

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

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

Intrusion detection for web applications

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

Complete Cross-site Scripting Walkthrough

Attack Vector Detail Report Atlassian

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

Web Vulnerability Assessment Report

Next Generation Clickjacking

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

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

Web Application Worms & Browser Insecurity

Web Application Security

Web Application Vulnerability Testing with Nessus

WHITE PAPER. FortiWeb Web Application Firewall Ensuring Compliance for PCI DSS 6.5 and 6.6

Cross-Site Scripting

Criteria for web application security check. Version

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

Certified Secure Web Application Security Test Checklist

Security vulnerabilities in new web applications. Ing. Pavol Lupták, CISSP, CEH Lead Security Consultant

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

CTF Web Security Training. Engin Kirda

Web Application Security

Cross-site site Scripting Attacks on Android WebView

4.2 Understand Microsoft ASP.NET Web Application Development

OWASP Top Ten Tools and Tactics

Transcription:

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

Agenda Quick reminder of how HTML forms work How cross-site request forgery (CSRF) attack works Obstacles and how attackers work around them Demo of attack Common proposals for prevention Demo of detected attack How to pen-test the prevention mechanism Built-in features to prevent attacks Impact on SOAP Automated testing

Why is CSRF interesting? Allows an attacker to take arbitrary actions as the victim against a web site. Similar to cross-site scripting Often missed by web pen-testers Not a small coding error like XSS Many platforms do not have built-in features to prevent the attack Preventing the attack may require implementing a new feature and often isn t trivial to do right Can apply to SOAP

Refresher on HTML Forms Client Requests Page from Server Client using Web Browser Server Responds with HTML Form Client Sends Form Data Web Server User completes HTML form and submits it Server authenticates and authorizes user. If success, performs requested action. Okay, what s the security problem? Only authorized users can perform actions.

Reminder: Browser Security Model Browsers prevent cross-domain read access to data. Example: http://www.contoso.com cannot read http://www.microsoft.com Cross-domain form submissions are allowed. CSRF Attack - Attacker coerces victim to submit attacker s form data to the victim s web server. (Cross-site form submission)

Anatomy of CSRF Attack Step 1: Attacker hosts web page with pre-populated HTML form data. Step2: Victim browses to attacker s HTML form. Step 3: Page automatically submits pre-populated form data to a site where victim has access. Remember: Javascript can automate posting forms. Step 4: Site authenticates request (with attacker s form data) as coming from the victim. Result: Attacker s form data is accepted by server since it was sent from legitimate user.

Demo of Attack

Obstacles for Attacker Needs to know victim s server Knowing victim s server is not hard in a targeted attack or a commonly used server. Example: Famous banks, auction sites, etc. Needs to get victim to browse to attacker s site (pre-populated form) Getting victim to load the attacker s form isn t hard. (Phishing is often successful.) Needs victim to log into server Victim might already be logged into a site or might have automatic log-in enabled. Examples: SSO, cookie, or Windows Integrated Authentication. Windows Integrated Authentication is very popular on intranets.

Easier for GET Operations RFC 2616 (HTTP 1.1) states, the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. In practice this is not followed. Many GET operations perform operations that do things besides/in addition to data retrieval. Example: http://server/deletemessage.asp?id=1 Even easier to attack than POST, because victim can be attacked any place a URL is evaluated. Example: Picture in email.

Common Prevention Ideas Check HTTP Referer For privacy, Referer might not be present. Redirects on the site might allow for correct Referer even if only redirecting to it s own site. Example: http://server/redir.aspx?url=/delete.aspx?id=100 Store state When user browses to the form, record state, check it when it is submitted. Examples: Server-side state or cookies (Attacker cannot set cookie for another user on victim s site without another security bug.) Still vulnerable! Attacker can force the victim s browser to load the form from the trusted site and then submit the form from the attacker s site. (State will be correctly set.) Hidden HTML form field storing state This works if done correctly. Let s look at how to test for correctness.

Demo of Attack Detection

Pen-testing CSRF Validation Fields Test 1: Verify validation field is unique for each user. Developers sometimes believe if the validation field is only good for a few minutes it s good enough. Remember, an attacker s pre-populated HTML form could use server-side code to grab a validation field on the fly.

Pen-testing CSRF Validation Fields Test 2: Verify the validation field cannot be determined by other users. If the attacker can create a correct value of the validation field for another user, there is no value in the validation field. Validation field should also be unique for each site. Example: If a hosting company deploys a web site for contoso.com and wingtiptoys.com, the validation field for user1 on one site should not work on the other. Especially bad if accounts can have different owners. Even worse if problem present in commercial off the self software.

Pen-testing CSRF Validation Fields Test 3: Verify the validation field is never sent on the query string. This data could be leaked in places like the HTTP Referer to the attacker. Also remember only data retrieval should occur through GET requests.

Pen-testing CSRF Validation Fields Test 4: Verify request fails if validation field is missing. Nulling out data often bypasses checks. Validation field may only be checked on certain operations. Example: During threat modeling, a team only planned to check validation field on database updates. They also send mail as the user but didn t plan on checking there!

ASP.NET Built-in Solution ASP.NET 1.1 introduced the ViewStateUserKey property. ViewStateUserKey can be set with user specific information. Information used to create unique VIEWSTATE field. ASP.NET automatically checks when page is submitted Almost painless for developers. Other languages like C++, PHP, Classic ASP, do not currently have built-in support.

Impact on SOAP SOAP request are POSTs with XML contents Client should prevent cross-domain SOAP requests SOAP requests should be strictly validated so sending SOAP XML as form data should fail. This generally means SOAP doesn t have CSRF issues. However, SOAP 1.2 may allow it through both POST and GET

GET/POST Binding SOAP method can be called using an HTTP GET or HTTP POST (normal form payload not XML payload). SOAP 1.2 spec includes GET binding WSDL 1.1 spec includes GET and POST binding.

SOAP: HTTP GET Binding Usually takes 1 of 2 formats Format 1: SOAP Method Name http://server/auction.asmx/bid?id=5089&value=1000 Parameter Name Parameter Value Format 2: SOAP Method Name http://server/auction.asmx?method=bid&id=8&value=10 Parameter Name Parameter Value

SOAP: HTTP POST Binding Same data as HTTP GET except form data is send in POST payload instead of query string. Both POST and GET can often be disabled. Example: ASP.NET contains 2 properties HttpPost and HttpGet to toggle this. Disabled by default. Often enabled for debugging, and mistakenly left on. Sometimes only enabled for localhost. (Still attackable but more difficult.)

Automated Testing Only interested in authenticated requests that perform actions besides data retrieval. Testing normal HTML forms: Write code to find forms that are missing the known hidden validation forms. Example: VIEWSTATE Existing functionality testing automation can be leveraged. Write code to hook the onbeforesubmit event and modify data accordingly. Useful to have multiple accounts when testing. Testing SOAP GET/POST Binding Local access - investigate server config (example: web.config for HttpGet/HttpPost setting) Local access If config allows GET/POST, examine methods for nonretrieval operations. Remote access Visit WSDL and try forming HTTP GET/POST requests based on information exposed. Success should return the same data as an XML SOAP request.

Questions? Related attacks covered in Hunting Security Bugs from Microsoft Press - http://www.microsoft.com/ MSPress/books/8485.asp. Pick up a copy.