Professional Documents
Culture Documents
Top-10 2017
Dave Wichers
Previous OWASP Top 10 Project Lead (2003 thru 2017)
Former OWASP Board Member (2003 thru 2013)
CoFounder and COO, Aspect Security
which is now EY
About the OWASP Top 10
• Not a standard…
Released
3
What Didn’t Change
Threat Attack
Weakness Prevalence Weakness Detectability Technical Impact Business Impact
Agent Vector
3 2 3 3
• Added: 3
• Merged: 2 merged into 1
• Reordered: 3
Injection means…
• Tricking an application into including unintended commands in the data sent
to an interpreter
Interpreters…
• Take strings and interpret them as commands
• SQL, OS Shell, LDAP, XPath, Hibernate, etc…
Typical Impact
• Usually severe. Entire database can usually be read or modified
• May also allow full database schema, or account access, or even OS level
access 8
SQL Injection – Illustrated
"SELECT * FROM
Account Summary
Account:
accounts WHERE
Knowledge Mgmt
Communication
Administration
Bus. Functions
Legacy Systems
Human Resrcs
E-Commerce
Transactions
Application Layer
Web Services
SKU:
Directories
acct=‘’ OR
Databases
Accounts
Acct:5424-6066-2134-4334
Finance HTTP
Billing
HTTP SQL DB Table Acct:4128-7574-3921-0192
response !
1=1--’"
request query Acct:5424-9383-2039-4029
APPLICATION "
>
M > M
ATTACK Acct:4128-0004-1234-0293
Custom Code
1. Application presents a form to
the attacker
2. Attacker sends an attack in the
form data
App Server
3. Application forwards attack to
Web Server
the database in a SQL query
Hardened OS
4. Database runs query containing
Network Layer
Recommendations
• Avoid the interpreter entirely, or
• Use an interface that supports bind variables (e.g., prepared
statements, or stored procedures),
• Bind variables allow the interpreter to distinguish between code and
data
• Encode all user input before passing it to the interpreter
• Always perform ‘white list’ input validation on all user supplied input
• Always minimize database privileges to reduce the impact of a flaw
Typical Impact
• User accounts compromised or user sessions hijacked
11
Broken Authentication
Illustrated
Knowledge Mgmt
Communication
Administration
Bus. Functions
E-Commerce
Transactions
Accounts
Finance
www.boi.com?JSESSIONID=9FA1DB9EA...
Site uses URL rewriting 2 Custom Code
(i.e., put session in URL)
Typical Impact
• Attackers access or modify confidential or private information
• e.g., credit cards, health care records, financial data (yours or your customers)
• Attackers extract secrets to use in additional attacks
• Company embarrassment, customer dissatisfaction, and loss of trust
• Expense of cleaning up the incident, such as forensics, sending apology
letters, reissuing thousands of credit cards, providing identity theft
insurance
• Business gets sued and/or fined
Insecure Cryptographic
Storage Illustrated
Communication
Administration
Bus. Functions
E-Commerce
Transactions
Knowledge
Accounts
Finance
Mgmt
Custom Code
Log files
4 Malicious insider
steals 4 million credit Error handler logs CC 2
card numbers details because merchant
gateway is unavailable
Business Partners
External Victim
Custom Code Backend Systems
Employees
1 2
External attacker Internal attacker
steals credentials steals credentials
and data off and data from
network internal network
External Attacker Internal Attacker
Avoiding Insufficient
Transport Layer Protection
• https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet
• https://www.owasp.org/index.php/HTTP_Strict_Transport_Security_Cheat_Sheet
2017-A4 – XML eXternal Entity
(XXE) Attack
What is it?
A common mistake …
Typical Impact
<?xml version="1.0"?>
<!DOCTYPE kaboom [
<!ENTITY a "aaaaaaaaaaaaaaaaaa..."> ]>
<kaboom>&a;&a;&a;&a;&a;&a;&a;&a;&a;...</kaboom>
What happens this time?
XXE Defense Examples
Defense 1: Disable Entity inclusion. The XML Validator will throw a Fatal Exception if such an entity is
included.
Xerces Example:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
try {
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
// Use DBF here to parse XML (safely)
} catch (ParserConfigurationException e) { //handle error }
How do you protect access to specific functions and specific data elements?
• Each function and data reference needs to verify user is authorized to access in manner
requested (read, write, delete, create, etc.)
A common mistake …
Typical Impact
• He modifies it to another
directory (role)
/admin/getAccounts, or
/manager/getAccounts
• Attacker views more
accounts than just their
own
Insecure Direct Object
References Illustrated
• He modifies it to a nearby
number
?acct=6066
• Attacker views the
victim’s account
information
25
Avoiding Broken Access
Control
Typical Impact
Knowledge Mgmt
Communication
Administration
Bus. Functions
E-Commerce
Transactions
Accounts
Finance
Database
Custom Code
App Configuration
Development
Framework
App Server
QA Servers
Web Server
Hardened OS
Insider Test Servers
Source Control
Avoiding Security
Misconfiguration
Raw data…
• Stored in database
• Reflected from web input (form field, hidden field, URL, etc…)
• Sent directly into rich JavaScript client
Typical Impact
• Steal user’s session, steal sensitive data, rewrite web page, redirect user to
phishing or malware site
• Most Severe: Install XSS proxy which allows attacker to observe and direct all
user’s behavior on vulnerable site and force user to other sites 30
Cross-Site Scripting Illustrated
Application with
stored XSS
Attacker enters a vulnerability
malicious script into a web
page that stores the data
on the server
Knowledge Mgmt
Communication
Administration
Bus. Functions
E-Commerce
Transactions
2 Victim views page – sees attacker profile
Accounts
Finance
Custom Code
• Recommendations
– Eliminate Flaw
• Don’t include user supplied input in the output page
– Defend Against the Flaw
• Use Content Security Policy (CSP)
• Primary Recommendation: Output encode all user supplied input (Use
OWASP’s Java Encoders to output encode)
https://www.owasp.org/index.php/OWASP_Java_Encoder_Project
• Perform ‘white list’ input validation on all user input to be included in page
• For large chunks of user supplied HTML, use OWASP’s AntiSamy to sanitize
this HTML to make it safe
See: https://www.owasp.org/index.php/AntiSamy
• References
– For how to output encode properly, read the
https://www.owasp.org/index.php/XSS_(Cross Site Scripting) Prevention Cheat Sheet
(AntiSamy)
32
Safe Escaping Schemes in Various
HTML Execution Contexts
#1: ( &, <, >, " ) à &entity; ( ', / ) à &#xHH;
ESAPI: encodeForHTML()
See: www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet
https://www.owasp.org/index.php/DOM_based_XSS_Prevention_Cheat_Sheet 33
2017-A8 – Insecure
Deserialization
Commonly identified in
Typical Impact
Libraries
• https://www.owasp.org/index.php/Deserialization_Cheat_Sheet 36
2017-A9 – Using Known
Vulnerable Components
Widespread
• Virtually every application has these issues because most development teams don’t
focus on ensuring their components/libraries are up to date
• In many cases, the developers don’t even know all the components they are using,
never mind their versions. Component dependencies make things even worse
Typical Impact
• Full range of weaknesses is possible, including injection, broken access control, XSS ...
• The impact could range from minimal to complete host takeover and data
compromise
37
What Can You Do
to Avoid This?
Output from the Maven Versions Plugin – Automated Analysis of Libraries’ Status
against Central repository
• They usually just tell users about errors (failed attacks) and
ask them to try again
• They (usually) DON’T log such attacks well
• They frequently don’t monitor what they do log (or
notice), and take action when unexpected behaviors are
detected (Attacks!!)
Typical Impact
Logging
• Do you have a standard logging system?
• Do all your standard security controls log all security critical events?
• Do all your custom security controls log all security critical events?
• Can you easily distinguish security vs. non-security log events?
Monitoring
• Are application logs sent to a central monitoring location?
• Do you have monitoring software, that is running?
• Can it detect security critical events? Can it detect the accumulation of interesting
events above defined thresholds?
• Can monitoring software raise alerts to system owners?
• Can monitoring software take action against obvious attackers?