Introduction To WASP
Introduction To WASP
From
OWASP Top 10: The Ten Most Critical Web Application Security Vulnera
bilities
Cross-Site Scripting (XSS) Attacks
• Malicious code that can change the look and function of a
legitimate web application
• Originates from old phishing attacks but less obvious and more
dangerous to the user/victim
• More widespread now because of move to more rich Internet
applications using dynamic content and JavaScript and the latest
AJAX trend
• My favorite XSS resource
• OWASP Cross-site Scripting (XSS)
Websites XSS’d
• A hacker was able to insert JavaScript code into the Obama community blog
section
• The JavaScript would redirect the users to the Hillary Clinton website
• YouTube Demonstration
• Read about it on ChannelWeb
• E.g. /BankAccount.jsp?acct_nmbr=123
• The hacker modifies the parameter to view another users account
Demo
• Bypass Data Layer Access Control
Solution
• Properly validate data!
• Cookie data, URL parameters, all HTML Form data (even hidden, select, radio
and checkbox types)
• Restricting length of HTML text boxes, options in select boxes, and JavaScript
validation can all be easily sidestepped and are not secure
• All input data MUST be validated server side for each request – client side
validation is EASILY bypassed
• Do not expose internals to the user
• Such as IDs (if possible/necessary)
• Use an indirect reference map with hard to guess keys (hash)
• POST /BankAccount.jsp?acct_nmbr=d83OJdm3
• The server then uses the key to get the real value
• Key: d83OJdm3 value: 123
Use Proper Authorization
• Architect your application to check authorization with every request
http://xkcd.com/327/
SQL Injection Demo…
• String SQL Injection
Preventing SQL injection
• Use Prepared Statements (aka Parameterized Queries)
• $id=1234
• “select * from accounts where id = “ + $id
vs
• “select * from accounts where id =1234”
• Validate input
• Strong typing
• If the id parameter is a number, try parsing it into an integer
• Business logic validation
• Escape questionable characters (ticks, --, semi-colon, brackets, etc.)
Mimimize the Impact of SQL injection
• Quiz: Is running a Web Application as the Database System
Admin “sa” account a good practice?
• Session Hijacking: The hacker masquerades as another user by stealing the users
session id (usually via XSS)
Demos
Spoofing an Authentication Cookie
Hardening Authentication
• Every request to each page of a web application should be revalidated for
proper authenticated and authorized access