SlideShare a Scribd company logo
Copyright 2007 © The OWASP Foundation
Permission is granted to copy, distribute and/or modify this document
under the terms of the OWASP License.
The OWASP Foundation
OWASP
http://www.owasp.org
WebAppSec 101: OWASP Top
10 and WebGoat
Kyle
OWASP UCI Chapter Lead
5/17/2010
OWASP
Quick OWASP Background
Open Web Application Security Project
OC chapter lead by Neil Matatall, original creator of
this presentation
Upcoming conference on Tue, Sept 7th
AppSec US 2010 @ UCI
OWASP
OWASP’s Top 10 List
1. Injection Flaws
a) SQL Injection, XPATH Injection, etc
2. Cross-Site Scripting (XSS)
3. Broken Authentication and Session Management
4. Insecure Direct Object Reference
5. Cross Site Request Forgery (CSRF)
6. Security Misconfiguration
7. Insecure Cryptographic Storage
8. Failure to Restrict URL Access
9. Insufficient Transport Layer Protection
10. Unvalidated Redirects and Forwards
From OWASP Top 10: The Ten Most Critical Web Application Security
Vulnerabilities
OWASP
What We’re Covering
1. Cross-Site Scripting (XSS)
2. Cross-Site Request Forgery (CSRF)
3. Insecure Direct Object Reference
4. Injection Flaws
a) SQL Injection, XPATH Injection, etc
5. Broken Authentication and Session Management
6. Failure to Restrict URL Access
7. Insecure Cryptographic Storage
OWASP
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)
OWASP
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
Websites from FBI.gov, CNN.com, Time.com, Ebay,
Yahoo, Apple computer, Microsoft, Zdnet, Wired, and
Newsbytes have all had XSS bugs.
OWASP
Cross-Site Scripting (XSS) Attacks
OWASP
The Impact of XSS
Data residing on the web page can be sent anywhere in
the world
Including cookies!
Facilitates many other types of attacks
Cross-Site Request Forgery (CSRF), Session Attacks (more later)
Your site’s behavior can be hijacked
OWASP
Our first demo…
Stored XSS Attack
OWASP
Preventing XSS
Escape all user input when it is displayed
Escaping converts the output to harmless html entities
 <script> becomes &lt;script&gt;
 but still displayed as <script>
Methods:
 OWASP ESAPI
 Java Standard Tag Library (JSTL) <c:out/>
OWASP XSS Prevention Cheat Sheet
OWASP
Preventing XSS - Continued
Ensure your filter uses a white list approach
Filters based on blacklisting have historically been flawed
 E.g. PHP, Ruby on Rails sanitize method
New encoding schemes can easily bypass filters that use a blacklist
approach
Do not accept and reflect unsolicited input
Reflecting every parameter for confirmation pages
Printing out the session/request parameters in error pages
Great XSS Test Fixture: http://ha.ckers.org/xss.html
OWASP
This Presentation's Re-ordered List
1. Cross-Site Scripting (XSS)
2. Cross-Site Request Forgery (CSRF)
3. Insecure Direct Object Reference
4. Injection Flaws
a) SQL Injection, XPATH Injection, etc
5. Broken Authentication and Session Management
6. Failure to Restrict URL Access
7. Insecure Cryptographic Storage
OWASP
Cross Site Request Forgery (CSRF)
From http://www.owasp.org/index.php/Top_10_2010-Main:
“A CSRF attack forces a logged-on victim's browser to send
a pre-authenticated request to a vulnerable web
application, which then forces the victim's browser to
perform a hostile action to the benefit of the attacker.
CSRF can be as powerful as the web application that it
attacks.
OWASP
Cross Site Request Forgery (CSRF)
 Occurs when an authenticated user unknowingly initiates a request
 The request is handled as if it were intentional
 Usually happens without the user being aware!
 CSRF attacks are difficult to track
 Commands are executed in the context of the victim
 The request comes from the users IP address so it is difficult to hunt
down the hacker
 The hacker is essentially given all of the user’s privileges
 XSS facilitates CSRF via “Link Injection”
OWASP
CSRF Example
 A hacker posts to a message board containing an image tag
 <img src= “http://yourbank.com/transfer?
to_account=my_account_number&amount=all_of_your_money>
 An unsuspecting user logs into yourbank.com and authenticates
 The user then visits said message board
 A request is issued from the victim’s browser to the bank’s website
 The bank’s website transfers the user’s money to the hacker’s
account
OWASP
CSRF In the Real World
Netflix vulnerabilities allowed attackers to
change the shipping addresses, email address,
password, and movie queues
Novell GroupWise WebAccess was found to
contain a CSRF (and XSS) vulnerability that
allowed an attacker to receive copies of any
compromised email account
Sun’s IdM allowed hackers to change the
passwords of admin accounts
OWASP
Solution
Add a secondary authentication mechanism
 Such as an impossible to guess token
Require a confirmation page before executing potentially
dangerous actions
Eliminate XSS vulnerabilities
Use POST as your form action and only accept POST
requests on the server for sensitive data !
 Incoming CSRF requests will fail since the parameter is in the URL and not
the post body
You can protect yourself with RequestPolicy (Firefox
extension)
OWASP
This Presentation's Re-ordered List
1. Cross-Site Scripting (XSS)
2. Cross-Site Request Forgery (CSRF)
3. Insecure Direct Object Reference
4. Injection Flaws
a) SQL Injection, XPATH Injection, etc
5. Broken Authentication and Session Management
6. Failure to Restrict URL Access
7. Insecure Cryptographic Storage
OWASP
Insecure Direct Object Reference
 “A direct object reference occurs when a developer exposes a
reference to an internal implementation object, such as a file,
directory, database record, or key, as a URL or form parameter.
Attackers can manipulate those references to access other objects
without authorization.”
 Fancy term for parameter tampering
 Involves modifying parameters to access unauthorized materials
 E.g. /BankAccount.jsp?acct_nmbr=123
 The hacker modifies the parameter to view another users account
OWASP
Demo
Bypass Data Layer Access Control
OWASP
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
OWASP
Use Proper Authorization
 Architect your application to check authorization with every
request
 Back to the bank example
 Before: select * from accounts where account_number = ?
 After: select * from accounts where account_number = ? and
user_id =?
OWASP
This Presentation's Re-ordered
Top 10 List
1. Cross-Site Scripting (XSS)
2. Cross-Site Request Forgery (CSRF)
3. Insecure Direct Object Reference
4. Injection Flaws
a) SQL Injection, XPATH Injection, etc
5. Broken Authentication and Session Management
6. Failure to Restrict URL Access
7. Insecure Cryptographic Storage
OWASP
UCLA Security Incident
30,000 people affected directly; 800,000 notifications
sent out 12/2006
Unsupported/forgotten legacy web application was
targeted with escalated database privileges
Web application vulnerability exposed data online using
SQL injection
Hacked server was then used to gain access to more
sensitive servers
OWASP
SQL Injection Attacks
“SQL injection is a security vulnerability that occurs
in the database layer of an application. Its source is
the incorrect escaping of dynamically-generated
string literals embedded in SQL statements. “
(Wikipedia)
OWASP
Impact of SQL Injection - Dangerous
At best: you can leak information
Depending on your configuration, a hacker can
Delete, alter or create data
Grant direct access to the hacker
Escalate privileges and even take over the OS
OWASP
SQL Injection Attacks
Login Example Attack
Text in blue is your SQL code, Text in orange is the hacker input,
black text is your application code
Login: Password:
Dynamically Build SQL String performing authentication:
“SELECT * FROM users WHERE login = ‘” + userName + “’ and
password= ‘” + password + “’”;
Hacker logs in as: ‘ or ‘’ = ‘’; --
SELECT * FROM users WHERE login = ‘’ or ‘’ = ‘’; --‘ and
password=‘’
OWASP
More Dangerous SQL Injection Attacks
Hacker creates a Windows Account:
SELECT * FROM users WHERE login = ‘’; exec
master..xp_cmdshell 'net users username password /add';--’
and password= ’’
And then adds himself as an administrator:
SELECT * FROM users WHERE login = ‘'; exec
master..xp_cmdshell 'net localgroup Administrators
username /add';--’ and password= ‘’
SQL Injection examples are outlined in:
 http://www.spidynamics.com/papers/SQLInjectionWhitePaper.pdf
 http://www.unixwiz.net/techtips/sql-injection.html
OWASP
Exploits of a Mom
http://xkcd.com/327/
OWASP
SQL Injection Demo…
String SQL Injection
OWASP
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.)
OWASP
Mimimize the Impact of SQL injection
Quiz: Is running a Web Application as the Database
System Admin “sa” account a good practice?
Use the principle of least privilege
If the query is reading the database, do not run the query as a
user with update permissions (dbo, drop, etc)
OWASP
Injection Impacts
More Than SQL
“Injection Flaw” is a blanket term
SQL Injection is most prevalent
Other forms:
XPath Injection
Command Injection
LDAP (Lightweight Directory Access Protocol) Injection
DOM (Document Object Model) Injection
JSON (Javascript Object Notation) Injection
Log Spoofing
On and on and on…
OWASP
This Presentation's Re-ordered
Top 10 List
1. Cross-Site Scripting (XSS)
2. Cross-Site Request Forgery (CSRF)
3. Insecure Direct Object Reference
4. Injection Flaws
a) SQL Injection, XPATH Injection, etc
5. Broken Authentication and Session Management
6. Failure to Restrict URL Access
7. Insecure Cryptographic Storage
OWASP
Authentication Checks
 From http://www.owasp.org/index.php/Top_10_2010-Main “Account
credentials and session tokens are often not properly protected.
Attackers compromise passwords, keys, or authentication tokens to
assume other users' identities.”
 Never store passwords in plaintext
 Encrypt or Hash+Salt (preferred)
 Architect applications to check every request to see that the
authentication data is still valid
 Issue a new session token when a change in privilege occurs
 ASP reuses session IDs by default!
 If you absolutely must use “remember me” functionality, use a difficult to
guess authentication cookie
 Authentication data is sent with every request, so protect it
OWASP
Session Attacks
Session Fixation: The hacker predicts a valid session key
(usually via phishing)
Session Hijacking: The hacker masquerades as another
user by stealing the users session id (usually via XSS)
OWASP
Demos
Spoofing an Authentication Cookie
OWASP
Hardening Authentication
 Every request to each page of a web application should be
revalidated for proper authenticated and authorized access
 Check validity of authentication cookie on each request. Validate
original IP address is the same as current request IP and age since
created or last checked. Deny access if not.
 Check that the authenticated user is authorized to access your
application (using internal database of users, LDAP, authorization
service, etc) on each request
OWASP
Solution
Use built in session management!
Most application servers do a pretty good job of this (except
ASP, boo Microsoft)
Use secure randomly generated session keys to make
prediction impossible
Don’t expose the user to session ids if possible
Use reasonable session timeouts
OWASP
This Presentation's Re-ordered
Top 10 List
1. Cross-Site Scripting (XSS)
2. Cross-Site Request Forgery (CSRF)
3. Insecure Direct Object Reference
4. Injection Flaws
a) SQL Injection, XPATH Injection, etc
5. Broken Authentication and Session Management
6. Failure to Restrict URL Access
7. Insecure Cryptographic Storage
OWASP
Failure to Restrict URL Access
 “Frequently, an application only protects sensitive functionality by
preventing the display of links or URLs to unauthorized users.
Attackers can use this weakness to access and perform
unauthorized operations by accessing those URLs directly. “
 Can be caused by:
 Improper authentication
 Incorrect authorization
 Unprotected admin areas
 Usually caused by easy to guess URLs
 .htaccess is your friend!
OWASP
This Presentation's Re-ordered
Top 10 List
1. Cross-Site Scripting (XSS)
2. Cross-Site Request Forgery (CSRF)
3. Insecure Direct Object Reference
4. Injection Flaws
a) SQL Injection, XPATH Injection, etc
5. Broken Authentication and Session Management
6. Failure to Restrict URL Access
7. Insecure Cryptographic Storage
OWASP
Insecure Cryptographic Storage
 From http://www.owasp.org/index.php/Top_10_2007 : “Web applications
rarely use cryptographic functions properly to protect data and
credentials. Attackers use weakly protected data to conduct identity
theft and other crimes, such as credit card fraud.”
 Use latest standard encryption methods
 They are standards for a reason! And they change over time
 Use strong standard encryption methods
 Stop using Message-Digest Algorithm 5 (MD5), Secure Hash Algorithm
(SHA1), Data Encryption Standard (DES)
 Use SHA-256, Advanced Encryption Standard (AES),
Rivest/Shamir/Adleman Public Key Encryption (RSA)
 Encrypt stored passwords with above methods
OWASP
“MD5 Considered Harmful Today”
MD5 has been known to have serious weaknesses which
produce collisions
It has been considered a weak hash function since at
least 2004
Using knowledge of MD5 collisions, researchers were
able to impersonate a root CA common to all browsers
This rogue CA can issue SSL certificates that even the
knowledgeable end user may not notice
http://www.win.tue.nl/hashclash/rogue-ca/
OWASP
Thanks for coming!

More Related Content

PPT
OWASP_Top_10_Introduction_and_Remedies_2017.ppt
PPTX
Owasp top 10_-_2010 presentation
PDF
2013 OWASP Top 10
PPTX
OWASP top 10-2013
PPTX
OWASP -Top 5 Jagjit
PPTX
Application Security Vulnerabilities: OWASP Top 10 -2007
PDF
Web Application Security 101
PDF
OWASP Top 10 (2010 release candidate 1)
OWASP_Top_10_Introduction_and_Remedies_2017.ppt
Owasp top 10_-_2010 presentation
2013 OWASP Top 10
OWASP top 10-2013
OWASP -Top 5 Jagjit
Application Security Vulnerabilities: OWASP Top 10 -2007
Web Application Security 101
OWASP Top 10 (2010 release candidate 1)

Similar to WebApps_Lecture_15.ppt (20)

PPTX
OWASP Free Training - SF2014 - Keary and Manico
PPTX
Hacker, you shall not pass!
PPT
Owasp top 10
PPTX
Security risks awareness
PDF
Security Awareness
PDF
Owasp Top 10
PDF
Top 10 web application security risks akash mahajan
PPT
OWASP Top10 2010
PPT
OWASP App Sec US - 2010
PPTX
RSA Europe 2013 OWASP Training
PPT
OWASP Serbia - A5 cross-site request forgery
PPTX
Protección web con ESAPI y AppSensor [GuadalajaraCON 2013]
PDF
Solvay secure application layer v2015 seba
PPT
Owasp Hacker Secrets Barcamp
PPT
OWASP an Introduction
PPTX
ASP.NET security vulnerabilities
PDF
Web Application Security and Awareness
PPTX
Owasp first5 presentation
PPTX
Owasp first5 presentation
PPTX
Top web apps security vulnerabilities
OWASP Free Training - SF2014 - Keary and Manico
Hacker, you shall not pass!
Owasp top 10
Security risks awareness
Security Awareness
Owasp Top 10
Top 10 web application security risks akash mahajan
OWASP Top10 2010
OWASP App Sec US - 2010
RSA Europe 2013 OWASP Training
OWASP Serbia - A5 cross-site request forgery
Protección web con ESAPI y AppSensor [GuadalajaraCON 2013]
Solvay secure application layer v2015 seba
Owasp Hacker Secrets Barcamp
OWASP an Introduction
ASP.NET security vulnerabilities
Web Application Security and Awareness
Owasp first5 presentation
Owasp first5 presentation
Top web apps security vulnerabilities
Ad

Recently uploaded (20)

PPT
BCH3201 (Enzymes and biocatalysis)-JEB (1).ppt
PPT
Gsisgdkddkvdgjsjdvdbdbdbdghjkhgcvvkkfcxxfg
PDF
Why Today’s Brands Need ORM & SEO Specialists More Than Ever.pdf
PDF
Manager Resume for R, CL & Applying Online.pdf
PDF
313302 DBMS UNIT 1 PPT for diploma Computer Eng Unit 2
DOC
field study for teachers graduating samplr
PDF
Biography of Mohammad Anamul Haque Nayan
PPTX
A slide for students with the advantagea
PPTX
Overview Planner of Soft Skills in a single ppt
PPTX
The Stock at arrangement the stock and product.pptx
PPTX
E-Commerce____Intermediate_Presentation.pptx
PPTX
Your Guide to a Winning Interview Aug 2025.
DOCX
How to Become a Criminal Profiler or Behavioural Analyst.docx
PDF
Josh Gao Strength to Strength Book Summary
PDF
L-0018048598visual cloud book for PCa-pdf.pdf
PPT
APPROACH TO DEVELOPMENTALlllllllllllllllll
PDF
Entrepreneurship PowerPoint for students
PDF
Daisia Frank: Strategy-Driven Real Estate with Heart.pdf
PPTX
PMP (Project Management Professional) course prepares individuals
PPTX
AREAS OF SPECIALIZATION AND CAREER OPPORTUNITIES FOR COMMUNICATORS AND JOURNA...
BCH3201 (Enzymes and biocatalysis)-JEB (1).ppt
Gsisgdkddkvdgjsjdvdbdbdbdghjkhgcvvkkfcxxfg
Why Today’s Brands Need ORM & SEO Specialists More Than Ever.pdf
Manager Resume for R, CL & Applying Online.pdf
313302 DBMS UNIT 1 PPT for diploma Computer Eng Unit 2
field study for teachers graduating samplr
Biography of Mohammad Anamul Haque Nayan
A slide for students with the advantagea
Overview Planner of Soft Skills in a single ppt
The Stock at arrangement the stock and product.pptx
E-Commerce____Intermediate_Presentation.pptx
Your Guide to a Winning Interview Aug 2025.
How to Become a Criminal Profiler or Behavioural Analyst.docx
Josh Gao Strength to Strength Book Summary
L-0018048598visual cloud book for PCa-pdf.pdf
APPROACH TO DEVELOPMENTALlllllllllllllllll
Entrepreneurship PowerPoint for students
Daisia Frank: Strategy-Driven Real Estate with Heart.pdf
PMP (Project Management Professional) course prepares individuals
AREAS OF SPECIALIZATION AND CAREER OPPORTUNITIES FOR COMMUNICATORS AND JOURNA...
Ad

WebApps_Lecture_15.ppt

  • 1. Copyright 2007 © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP Foundation OWASP http://www.owasp.org WebAppSec 101: OWASP Top 10 and WebGoat Kyle OWASP UCI Chapter Lead 5/17/2010
  • 2. OWASP Quick OWASP Background Open Web Application Security Project OC chapter lead by Neil Matatall, original creator of this presentation Upcoming conference on Tue, Sept 7th AppSec US 2010 @ UCI
  • 3. OWASP OWASP’s Top 10 List 1. Injection Flaws a) SQL Injection, XPATH Injection, etc 2. Cross-Site Scripting (XSS) 3. Broken Authentication and Session Management 4. Insecure Direct Object Reference 5. Cross Site Request Forgery (CSRF) 6. Security Misconfiguration 7. Insecure Cryptographic Storage 8. Failure to Restrict URL Access 9. Insufficient Transport Layer Protection 10. Unvalidated Redirects and Forwards From OWASP Top 10: The Ten Most Critical Web Application Security Vulnerabilities
  • 4. OWASP What We’re Covering 1. Cross-Site Scripting (XSS) 2. Cross-Site Request Forgery (CSRF) 3. Insecure Direct Object Reference 4. Injection Flaws a) SQL Injection, XPATH Injection, etc 5. Broken Authentication and Session Management 6. Failure to Restrict URL Access 7. Insecure Cryptographic Storage
  • 5. OWASP 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)
  • 6. OWASP 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 Websites from FBI.gov, CNN.com, Time.com, Ebay, Yahoo, Apple computer, Microsoft, Zdnet, Wired, and Newsbytes have all had XSS bugs.
  • 8. OWASP The Impact of XSS Data residing on the web page can be sent anywhere in the world Including cookies! Facilitates many other types of attacks Cross-Site Request Forgery (CSRF), Session Attacks (more later) Your site’s behavior can be hijacked
  • 10. OWASP Preventing XSS Escape all user input when it is displayed Escaping converts the output to harmless html entities  <script> becomes &lt;script&gt;  but still displayed as <script> Methods:  OWASP ESAPI  Java Standard Tag Library (JSTL) <c:out/> OWASP XSS Prevention Cheat Sheet
  • 11. OWASP Preventing XSS - Continued Ensure your filter uses a white list approach Filters based on blacklisting have historically been flawed  E.g. PHP, Ruby on Rails sanitize method New encoding schemes can easily bypass filters that use a blacklist approach Do not accept and reflect unsolicited input Reflecting every parameter for confirmation pages Printing out the session/request parameters in error pages Great XSS Test Fixture: http://ha.ckers.org/xss.html
  • 12. OWASP This Presentation's Re-ordered List 1. Cross-Site Scripting (XSS) 2. Cross-Site Request Forgery (CSRF) 3. Insecure Direct Object Reference 4. Injection Flaws a) SQL Injection, XPATH Injection, etc 5. Broken Authentication and Session Management 6. Failure to Restrict URL Access 7. Insecure Cryptographic Storage
  • 13. OWASP Cross Site Request Forgery (CSRF) From http://www.owasp.org/index.php/Top_10_2010-Main: “A CSRF attack forces a logged-on victim's browser to send a pre-authenticated request to a vulnerable web application, which then forces the victim's browser to perform a hostile action to the benefit of the attacker. CSRF can be as powerful as the web application that it attacks.
  • 14. OWASP Cross Site Request Forgery (CSRF)  Occurs when an authenticated user unknowingly initiates a request  The request is handled as if it were intentional  Usually happens without the user being aware!  CSRF attacks are difficult to track  Commands are executed in the context of the victim  The request comes from the users IP address so it is difficult to hunt down the hacker  The hacker is essentially given all of the user’s privileges  XSS facilitates CSRF via “Link Injection”
  • 15. OWASP CSRF Example  A hacker posts to a message board containing an image tag  <img src= “http://yourbank.com/transfer? to_account=my_account_number&amount=all_of_your_money>  An unsuspecting user logs into yourbank.com and authenticates  The user then visits said message board  A request is issued from the victim’s browser to the bank’s website  The bank’s website transfers the user’s money to the hacker’s account
  • 16. OWASP CSRF In the Real World Netflix vulnerabilities allowed attackers to change the shipping addresses, email address, password, and movie queues Novell GroupWise WebAccess was found to contain a CSRF (and XSS) vulnerability that allowed an attacker to receive copies of any compromised email account Sun’s IdM allowed hackers to change the passwords of admin accounts
  • 17. OWASP Solution Add a secondary authentication mechanism  Such as an impossible to guess token Require a confirmation page before executing potentially dangerous actions Eliminate XSS vulnerabilities Use POST as your form action and only accept POST requests on the server for sensitive data !  Incoming CSRF requests will fail since the parameter is in the URL and not the post body You can protect yourself with RequestPolicy (Firefox extension)
  • 18. OWASP This Presentation's Re-ordered List 1. Cross-Site Scripting (XSS) 2. Cross-Site Request Forgery (CSRF) 3. Insecure Direct Object Reference 4. Injection Flaws a) SQL Injection, XPATH Injection, etc 5. Broken Authentication and Session Management 6. Failure to Restrict URL Access 7. Insecure Cryptographic Storage
  • 19. OWASP Insecure Direct Object Reference  “A direct object reference occurs when a developer exposes a reference to an internal implementation object, such as a file, directory, database record, or key, as a URL or form parameter. Attackers can manipulate those references to access other objects without authorization.”  Fancy term for parameter tampering  Involves modifying parameters to access unauthorized materials  E.g. /BankAccount.jsp?acct_nmbr=123  The hacker modifies the parameter to view another users account
  • 21. OWASP 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
  • 22. OWASP Use Proper Authorization  Architect your application to check authorization with every request  Back to the bank example  Before: select * from accounts where account_number = ?  After: select * from accounts where account_number = ? and user_id =?
  • 23. OWASP This Presentation's Re-ordered Top 10 List 1. Cross-Site Scripting (XSS) 2. Cross-Site Request Forgery (CSRF) 3. Insecure Direct Object Reference 4. Injection Flaws a) SQL Injection, XPATH Injection, etc 5. Broken Authentication and Session Management 6. Failure to Restrict URL Access 7. Insecure Cryptographic Storage
  • 24. OWASP UCLA Security Incident 30,000 people affected directly; 800,000 notifications sent out 12/2006 Unsupported/forgotten legacy web application was targeted with escalated database privileges Web application vulnerability exposed data online using SQL injection Hacked server was then used to gain access to more sensitive servers
  • 25. OWASP SQL Injection Attacks “SQL injection is a security vulnerability that occurs in the database layer of an application. Its source is the incorrect escaping of dynamically-generated string literals embedded in SQL statements. “ (Wikipedia)
  • 26. OWASP Impact of SQL Injection - Dangerous At best: you can leak information Depending on your configuration, a hacker can Delete, alter or create data Grant direct access to the hacker Escalate privileges and even take over the OS
  • 27. OWASP SQL Injection Attacks Login Example Attack Text in blue is your SQL code, Text in orange is the hacker input, black text is your application code Login: Password: Dynamically Build SQL String performing authentication: “SELECT * FROM users WHERE login = ‘” + userName + “’ and password= ‘” + password + “’”; Hacker logs in as: ‘ or ‘’ = ‘’; -- SELECT * FROM users WHERE login = ‘’ or ‘’ = ‘’; --‘ and password=‘’
  • 28. OWASP More Dangerous SQL Injection Attacks Hacker creates a Windows Account: SELECT * FROM users WHERE login = ‘’; exec master..xp_cmdshell 'net users username password /add';--’ and password= ’’ And then adds himself as an administrator: SELECT * FROM users WHERE login = ‘'; exec master..xp_cmdshell 'net localgroup Administrators username /add';--’ and password= ‘’ SQL Injection examples are outlined in:  http://www.spidynamics.com/papers/SQLInjectionWhitePaper.pdf  http://www.unixwiz.net/techtips/sql-injection.html
  • 29. OWASP Exploits of a Mom http://xkcd.com/327/
  • 31. OWASP 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.)
  • 32. OWASP Mimimize the Impact of SQL injection Quiz: Is running a Web Application as the Database System Admin “sa” account a good practice? Use the principle of least privilege If the query is reading the database, do not run the query as a user with update permissions (dbo, drop, etc)
  • 33. OWASP Injection Impacts More Than SQL “Injection Flaw” is a blanket term SQL Injection is most prevalent Other forms: XPath Injection Command Injection LDAP (Lightweight Directory Access Protocol) Injection DOM (Document Object Model) Injection JSON (Javascript Object Notation) Injection Log Spoofing On and on and on…
  • 34. OWASP This Presentation's Re-ordered Top 10 List 1. Cross-Site Scripting (XSS) 2. Cross-Site Request Forgery (CSRF) 3. Insecure Direct Object Reference 4. Injection Flaws a) SQL Injection, XPATH Injection, etc 5. Broken Authentication and Session Management 6. Failure to Restrict URL Access 7. Insecure Cryptographic Storage
  • 35. OWASP Authentication Checks  From http://www.owasp.org/index.php/Top_10_2010-Main “Account credentials and session tokens are often not properly protected. Attackers compromise passwords, keys, or authentication tokens to assume other users' identities.”  Never store passwords in plaintext  Encrypt or Hash+Salt (preferred)  Architect applications to check every request to see that the authentication data is still valid  Issue a new session token when a change in privilege occurs  ASP reuses session IDs by default!  If you absolutely must use “remember me” functionality, use a difficult to guess authentication cookie  Authentication data is sent with every request, so protect it
  • 36. OWASP Session Attacks Session Fixation: The hacker predicts a valid session key (usually via phishing) Session Hijacking: The hacker masquerades as another user by stealing the users session id (usually via XSS)
  • 38. OWASP Hardening Authentication  Every request to each page of a web application should be revalidated for proper authenticated and authorized access  Check validity of authentication cookie on each request. Validate original IP address is the same as current request IP and age since created or last checked. Deny access if not.  Check that the authenticated user is authorized to access your application (using internal database of users, LDAP, authorization service, etc) on each request
  • 39. OWASP Solution Use built in session management! Most application servers do a pretty good job of this (except ASP, boo Microsoft) Use secure randomly generated session keys to make prediction impossible Don’t expose the user to session ids if possible Use reasonable session timeouts
  • 40. OWASP This Presentation's Re-ordered Top 10 List 1. Cross-Site Scripting (XSS) 2. Cross-Site Request Forgery (CSRF) 3. Insecure Direct Object Reference 4. Injection Flaws a) SQL Injection, XPATH Injection, etc 5. Broken Authentication and Session Management 6. Failure to Restrict URL Access 7. Insecure Cryptographic Storage
  • 41. OWASP Failure to Restrict URL Access  “Frequently, an application only protects sensitive functionality by preventing the display of links or URLs to unauthorized users. Attackers can use this weakness to access and perform unauthorized operations by accessing those URLs directly. “  Can be caused by:  Improper authentication  Incorrect authorization  Unprotected admin areas  Usually caused by easy to guess URLs  .htaccess is your friend!
  • 42. OWASP This Presentation's Re-ordered Top 10 List 1. Cross-Site Scripting (XSS) 2. Cross-Site Request Forgery (CSRF) 3. Insecure Direct Object Reference 4. Injection Flaws a) SQL Injection, XPATH Injection, etc 5. Broken Authentication and Session Management 6. Failure to Restrict URL Access 7. Insecure Cryptographic Storage
  • 43. OWASP Insecure Cryptographic Storage  From http://www.owasp.org/index.php/Top_10_2007 : “Web applications rarely use cryptographic functions properly to protect data and credentials. Attackers use weakly protected data to conduct identity theft and other crimes, such as credit card fraud.”  Use latest standard encryption methods  They are standards for a reason! And they change over time  Use strong standard encryption methods  Stop using Message-Digest Algorithm 5 (MD5), Secure Hash Algorithm (SHA1), Data Encryption Standard (DES)  Use SHA-256, Advanced Encryption Standard (AES), Rivest/Shamir/Adleman Public Key Encryption (RSA)  Encrypt stored passwords with above methods
  • 44. OWASP “MD5 Considered Harmful Today” MD5 has been known to have serious weaknesses which produce collisions It has been considered a weak hash function since at least 2004 Using knowledge of MD5 collisions, researchers were able to impersonate a root CA common to all browsers This rogue CA can issue SSL certificates that even the knowledgeable end user may not notice http://www.win.tue.nl/hashclash/rogue-ca/

Editor's Notes

  • #47: WIFI Example "/><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/oHg5SJYRHA0&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/oHg5SJYRHA0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object><font color="black">@gmail.com