240 likes | 256 Views
HI-TEC 2011 SQL Injection. ODBC or OLE DB Or ADO. Web Server Apache or IIS HTML Forms CGI Scripts. Database SQL Server or Oracle or MySQL. HTTP or HTTPS. Client ’ s Browser. Common Web Application Vulnerabilities. Common Web Application Vulnerabilities. Cross-Site Scripting (XSS)
E N D
ODBC or OLE DB Or ADO Web Server Apache or IIS HTML Forms CGI Scripts Database SQL Server or Oracle or MySQL HTTP or HTTPS Client’s Browser
Common Web Application Vulnerabilities • Cross-Site Scripting (XSS) • SQL Injection • Cross-Site Request Forgery (CSRF)
Cross-Site Scripting (XSS) Attacks • One user injects code that attacks another user • Common on guestbooks, comment pages, forums, etc. • Caused by failure to filter out HTML tags • These characters < > " & • Also watch out for hex-encoded versions • %3c instead of < • %3e instead of > • %22 instead of "
Cross-Site Scripting (XSS) • One client posts active content, with <script> tags or other programming content • When another client reads the messages, the scripts are executed in his or her browser • One user attacks another user, using the vulnerable Web application as a weapon
<script>alert("XSS vulnerability!")</script> • <script>alert(document.cookie)</script> • <script>window.location="http://www.ccsf.edu"</script>
XSS Scripting Effects • Steal another user's authentication cookie • Hijack session • Harvest stored passwords from the target's browser • Take over machine through browser vulnerability • Redirect Webpage • Many, many other evil things…
Common XSS Payloads • See link Ch 12z06
Cross-Site Scripting Countermeasures • Filter out < > ( ) # & and the variants of them • HTML-encode output, so a character like < becomes < -- that will stop scripts from running • In IE 6 SP1 or later, an application can set HttpOnly Cookies, which prevents them from being accessed by scripts • Analyze your applications for XSS vulnerabilities • Fix the errors you find
Common Web Application Vulnerabilities • SQL Injection
SQL Injection Comic • xkcd.org – a great comic • Link Ch 11i
SQL Injection Example HTML form collects name and pw SQL then uses those fields: SELECT * FROM customer WHERE username = ‘name' AND password = ‘pw' If a hacker enters a name of ’ OR 1=1 -- The SQL becomes: SELECT * FROM customer WHERE username = ‘’ OR 1=1 --' AND password = ‘pw‘ Which is always true, and returns all the records
Finding Vulnerable Web Apps with Google • Inurl:SELECT%20FROM
Expensive Commercial Tools • HP WebInspect and Security Toolkit • Rational AppScan • Cenzic Hailstorm
Cenzic Hailstorm • Highly rated commercial Web applicaion vulnerability scanner • Links Ch 11o, 11p
Tamper Data Demo • Vulnerable Message Board
Acts like a proxy server • You can see POST data and alter it • This will defeat client-side validation