Become a Security Ninja

Paul Gilzow
Paul GilzowProgrammer/Analyst-Expert at University of Missouri
BECOME A SECURITY NINJA
Don’t let your code be low-hanging fruit
Paul Gilzow

gilzow@missouri.edu

Twitter: @gilzow

Facebook: /gilzow

https://www.linkedin.com/in/gilzow
What we will talk about
Get our example files up and running
What is OWASP
What is the OWASP Top 10
The Current Top 10 Web Security Risks
ATTACK!
Set Up Our Exercise files
Log into your Digital Ocean account

https://cloud.digitalocean.com/login















Set Up Our Exercise files
Click on “Create Droplet”





















Set Up Our Exercise files
Choose a size
Click on “One-click apps”























Set Up Our Excersice files
Click on Docker























Set Up Our Excersice files
Scroll to the bottom of the page
Click the “Create” button























Set Up Our Excersice files
Once the instance is created, check your email for the credentials
In your ssh client, log into your new instance























Set Up Our Excersice files
You’ll need to change your password the first time you login























Set Up Our Excersice files
At the prompt type in



docker run -d -p 8899:80 opendns/security-ninjas
Docker will download and install the security-ninjas container



















Set Up Our Excersice files
Open your browser and go to your droplet ip address, port 8899

e.g. http://45.55.167.245:8899



















What is OWASP
Open Web Application Security Project
Worldwide non-project organization focused on
improving software security by raising awareness
Started in 2001
Hundreds of local chapters throughout the
world, with over a hundred in the U.S.
Current State of Web App security
160% increase in websites hosting malware between
2015 and 20161
55% of web apps have at least one high-severity
vulnerability, up 9% from 2015 to 20162
84% are suscptible to at least one medium-serverity
vulnerability2
Average of 15 vulnerabilities per site3
1 - Google Transparency Report, 2016
2 - Acunetix Web Application Vulnerability report 2016
3 - White Hat Security Web Applications Security Statistics Report 2016
Education, 49% of sites had at least one vulnerability
every day of the year1
Education, average of 28 vulnerabilities per site, 15 of
those serious1
Education, took an average of 4 months to remediate
issues1
1 - White Hat Security Web Applications Security Statistics Report 2016
Education Industry
Current State of Web App security
Why Education is an attractive target
Network capacity and availability
Rich in hardware infrastructure
Poor in human resources
Resistant to blacklisting
SEO reputation
Personally Identifiable Information (PII) / Sensitive Personal Information
(SPI)
Confidential Research Data / Proprietary Intellectual Property
What is the OWASP Top 10
Not a standard, but an awareness document
10 Most Critical Web Application Security Risks
For each risk, it includes
Description
Example vulnerabilities
Example Attacks
Guidance on how to avoid
First released in 2003, refreshed every 3 years
Current version is from 2013, next version due out late this year, early 2017
Current Top 10 (as of 2013)
1. Injection
2. Broken Authentication and Session Management
3. Cross-Site Scripting (XSS)
4. Insecure Direct Object Reference
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
A1. Injection
• Untrusted/tainted data is sent to an interpreter
as part of a command or query.
• Interpreter is tricked into executing unintended
commands
What is it?
A1. Injection
• HTML/Javascript
• SQL
• LDAP
• Xpath/Xquery
• Anything that accepts input and executes
What is susceptible?
A1. Injection
A1. Injection
• Failure to separate untrusted data with commands sent
to an interpreter
• Lack of input validation and/or input sanitation
• Attacker is able to change execution context
Why does it happen?
A1. Injection
• SQL Injection





SELECT UserId, Name, Password FROM Users WHERE UserId = $input;



Becomes



SELECT UserId, Name, Password FROM Users WHERE UserId = 105 or 1=1;





Examples
A1. Injection
ATTACK!
A1. Injection
• Use APIs that provide parameterized/sanitized
interfaces
• Validate input against a whitelist (do NOT use a
blacklist)
• Escape any special characters that you whitelist





Prevention
A2. Broken Authentication and
Session Management
• Failure to protect credentials and session tokens
throughout the lifecycle of the session
• Weak authentication logic
• Imperfect implementation
What is it?
A2. Broken Authentication and
Session Management
• Passing the session ID as a parameter in the URL
• Using a predictable value for the session ID
• User credentials passed unencrypted
• Poor username and password recovery functions
Why does it happen?
A2. Broken Authentication and
Session Management
ATTACK!
A2. Broken Authentication and
Session Management
• Never send credentials/sensitive data in the clear; use SSL
• Protect secrets throughout their lifecycle
• Don’t expose credentials (including session IDs) in the URL or logs
• Use centralized authentication and session management APIs, if available
• Implement strong account management functions (e.g.,	 account creation,
change password, recover password, etc.)
• Use strong algorithms to generate (random) secrets
• Do not rely on untrustworthy information for authentication (e.g. IP address,
referrer, etc.)
Prevention
A2. Broken Authentication and
Session Management
• Use a different session ID after authentication or
whenever authorization/permission levels change
• Destroy/invalidate the session ID completely after the
log out method has completed
• Enforce session timeouts
• Protect against Cross-Site Scripting (XSS)
Prevention
A3. Cross-Site Scripting (XSS)
• Similar to injection, but the intended target is a user’s
browser: the user’s browser is tricked into executing
unintended commands
• Usually in the form of HTML code or client-side scripts
• Occurs when an application takes unstrusted data from
the user and sends it back to the browser without
validation or encoding
• Exploits the trust the user has for a site
What is it?
If an attacker controls your browser, it is no longer
your browser
A3. Cross-Site Scripting
• Failure to separate untrusted data with commands
• Lack of input validation and/or input sanitation
• Attacker is able to change execution context
Why does it happen?
A3. Cross-Site Scripting
• Reflected
• Stored (aka persistent)
• Dom based
Types
A3. Cross-Site Scripting
• Data from the URL is used in the creation of the page
• Attacker tricks/entices user to click the exploited URL
• Web application reflects the payload back to the user’s
browser where it is executed as if it came from the
originating site
Types: Reflected
A3. Cross-Site Scripting
Types: Reflected Example
A3. Cross-Site Scripting
• Injected script is stored on the target server
• The injection script is then sent to visitors of the site
• Vicitim’s browser then executes the injected script as it
believes it came from the originating site
• Delayed (aka “Blind”) refers to the payload being
executed at a later time, possibly in a completely different
system (e.g. Log viewers, customer service apps, etc.)
Types: Stored/Persistent
A3. Cross-Site Scripting
• Similar to reflected but instead of tricking the user’s browser to
exectute script, tricks legitimate client side script into executing
the payload
• The attack payload is executed as a result of modifying the
DOM environment in the victim’s browser used by the original
client side script, so that the client side code runs in an
unexpected manner
• More prevalent now than in the past due to the increase use in
javascript and vulnerable javascript libraries (almost 200%
increase between 2015 and 20161
)
Types: Dom-based (aka Client Side)
1 - Acunetix web application vulnerability report 2016, pg 5
A3. Cross-Site Scripting
Types: Dom-based Example
A3. Cross-Site Scripting
Types: Dom-based Example, cont.
A3. Cross-Site Scripting
ATTACK!
A3. Cross-Site Scripting
• Implicitly deny
• Validate all input, regardless of where it
comes from
• Context-based output encoding
Prevention
A3. Cross-Site Scripting
• HTML Element Content

<div>DATA</div>
• HTML Attribute Values

<input name=“DATA” type=“text” value=“DATA” />
• Javascript Data

<script>someFunc(‘DATA’);</script>
• CSS Property Values

.foo a:hover{ color: DATA }
• URI Attribute VAlues

<a href=“/search/?q=DATA”>
Prevention - Context-based output encoding
• ( &, <, >, “) —> &entity; 

( ‘, / ) —> &#DDD; or &#xHH;
(UTF-8 encode)
• All non-alphanumeric —> &#xHH;
• All non-alphanumeric —> xHH
• All non-alphanumeric —> HH
• All non-alphanumeric —> %HH
A3. Cross-Site Scripting
• Implicitly deny
• Validate all input, regardless of where it comes from
• Context-based output encoding
• Content-Security-Policy headers
Prevention
A3. Cross-Site Scripting
Set of HTTP Response headers (or can be implemented
via meta element) that defines where resources can be
loaded from, preventing users’ browser from loading data
from any other locations.



Header Set Content-Security-Policy: script-src 'self' https://apis.google.com



<meta http-equiv="Content-Security-Policy" content="default-src 'self'">
Prevention - Content-Security-Policy headers
A3. Cross-Site Scripting
Prevention - Content-Security-Policy headers
A3. Cross-Site Scripting
Prevention - Content-Security-Policy headers
http://caniuse.com/#feat=contentsecuritypolicy
A4. Insecure Direct Object References
• Occurs when a reference to an internal implementation
object (file, directory, database record/key) is exposed
as a URL or form parameter
• Without subsequent authorization checks, an attacker
can manipulate these parameters to access
unauthorized data
What is it?
A4. Insecure Direct Object References
Examples
A4. Insecure Direct Object References
Examples
http://foo.bar.edu/file.php?file=report.txt
http://foo.bar.edu/file.php?file=../../app/config/database
A4. Insecure Direct Object References
ATTACK!
A4. Insecure Direct Object References
• Do not expose internal keys or identifiers for
objects
• Use object references that are difficult to guess
• Perform server-side authorization checks for object
access
Prevention
A5. Security Misconfiguration
• Security issues anywhere in the stack
• Framework
• Application Server
• Web Server
• Database Server
• Operating System
• 3rd party contols/modules
What is it?
A5. Security Misconfiguration
• Application dumps stack trace or reveals other
debugging information
• Default passwords not changed
• Out-of-date software
• Directory listings enabled
Examples
A5. Security Misconfiguration
ATTACK!
A5. Security Misconfiguration
• Security hardening throughout the entire application
stack
• Change default passwords
• Disable/remove debugging message and overly
informative error messages in production
• Remove unnecessary/unused features/modules/
components
Prevention
A6. Sensitive Data Exposure
• Storing and transmitting sensitive data insecurely, due to:
• Failure to identify all sensitive data
• Failure to identify all locations where sensitive data is
stored (database, files, logs, backups, etc)
• Failure to identify all locations sensitive data is sent
(web, databases, internal communications, external
business partners)
What is it?
A6. Sensitive Data Exposure
• Debugging information in comments of ouput
sent to the browser
• Application that stores sensitive data (correctly)
encoutners an error and logs that data
insecurely
Examples
A6. Sensitive Data Exposure
ATTACK!
A6. Sensitive Data Exposure
Prevention
Someone can’t steal it if you
don’t have it
A6. Sensitive Data Exposure
• Don’t store sensitive data if you don’t need it
• Catalog all sensitive data and where it is used
• Disable caching of pages that contains sensitive data
• Encrypt all sensitive data at rest and in transit
• Use strong standard algorithms and strong keys
Prevention
A7. Missing Function Level Access Controls
• Enforcing proper authorization for requests









What is it?
A7. Missing Function Level Access Controls
Examples
A7. Missing Function Level Access Controls
• Attacker notices the URL structure indicates his role

https://example.com/user/getAccount
• Attacker modifies it to another role

https://example.com/admin/getAccount
• The application fails to do a server-side check to verify
the request is coming from a user with the proper
authorization and the attacker now has access to data
on any account
Examples
A7. Missing Function Level Access Controls
ATTACK!
A7. Missing Function Level Access Controls
• Deny by default
• Perform server-side checks for every
function/action that requires authorization
• Server-side checks should not rely soley on
information provided by the client
Prevention
A8. Cross-Site Request Forgery
• Victim’s browser is tricked into issuing commands to a
vulnerable web application, to perform an unwanted action on a
trusted site for which the user is currently authenticated.
• Web browsers automatically include credentials (cookies,
sessions, basic authentication headers) with each request, even
for requests initiated by a form, script or image on another site
• Server-side code processes requests as if they came from the
authenticated user
• Often combined with Cross-Site Scripting
What is it?
A8. Cross-Site Request Forgery
• Application is built to allow a state change via URL
parameters



http://bankx.com/app?action=transfer&amount=3500&destinationAccount=4673243243
• Attacker constructs a request that will transfer funds to
to their account and embeds the requests on sites he
controls. He then tricks the victim into visiting the site



Examples
<img src="http://bankx.com/app?action=transfer&amount=14000&destinationAccount=attackersAcct#" width="0" height="0" />
A8. Cross-Site Request Forgery
ATTACK!
A8. Cross-Site Request Forgery
• Eliminate all XSS vulnerabilities in your application
• Never allow changes to data via a GET request
• Check Origin and Referer headers as a first step
• Include a per-request, cryptographically strong or
random token to all forms, where the verification token is
not provided by the browser
• Require reauthentication for sensitive transactions
Prevention
A9. Using Components with Known Vulnerabilities
• Using third-party controls/modules/frameworks with
known vulnerabilities anywhere in the stack can be
discovered and exploited by automated tools
• Third-party libraries/frameworks in an application
typically run with the same privileges as the application
• Those vulnerabilities can undermine other defenses
What is it?
A9. Using Components with Known Vulnerabilities
ATTACK!
A9. Using Components with Known Vulnerabilities
• Identify all third-party components in your applications, and
potentially throughout the entire stack
• Uninstall/disable all third-party components that are not being
used
• Monitor the security of these components in public databases
(CVE, NVD, etc.), security mailing lists
• Keep third-party components up-to-date religiously
• Develop a security policy on third-party component use
Prevention
A10. Unvalidated Redirects and Forwards
• Application takes input from an external source that is
then used to formulate a redirection or forward location
without validation
• Attacker links to an unvalidated redirect and tricks
victims into clicking it. Victims are more likely to click on
it, since the link is to a valid site



https://www.irs.gov/taxrefund/claim.jsp?
year=2015&dest=ev.il/sDfX4
What is it?
A10. Unvalidated Redirects and Forwards
• Application uses forwards to route requests between
different parts of the site. Pages use a parameter to
indicate where the user should be sent if a transaction
is successful.
• Attacker crafts a URL that will pass the application’s
access control check (or is missing control checks) and
then forwards the attacker to administrative
functionality for which the attacker isn’t authorized.
What is it?
A10. Unvalidated Redirects and Forwards
ATTACK!
A10. Unvalidated Redirects and Forwards
• Don’t use them unless you absolutely have to
• Avoid using user input to detemine destination URL
• Whitelist allowed pages or external sites
• Ensure URL is valid and authorized for the user
Prevention
Developer Take-aways
Security is a process, not an event.
Developer Take-aways
• Security is a process, not an event
• Build security into the software development life-cycle











Be paranoid; be skeptical
Developer Take-aways
• Security is a process, not an event
• Build security into the software development life-cycle
• Be paranoid; be skeptical
• Treat all data as tainted
• Validate data first (whitelist), then filter (blacklist)
• Validate/clean as early in the process as possible
• Encode data appropriately before sending to the client
• Never rely on client-side checks
Developer Take-aways
• Defense-in-depth
• Principle of Least Privilege
• Limit access to everything
• Enforce strong passwords
• Don’t harcode secrets in source code
• Keep third-party components up-to-date
• Error handling and Debug information
Continued
Questions?
Contact
gilzow@missouri.edu
@gilzow on twitter
Example Files: https://github.com/opendns/
Security_Ninjas_AppSec_Training
Slidedeck: https://github.com/gilzow/security-ninja/
1 of 84

Recommended

OWASP top 10-2013 by
OWASP top 10-2013OWASP top 10-2013
OWASP top 10-2013tmd800
12.7K views41 slides
AJAX Security - LAC2016 by
AJAX Security - LAC2016AJAX Security - LAC2016
AJAX Security - LAC2016Julia Logan a.k.a. IrishWonder
1.1K views17 slides
Top 10 Web Security Vulnerabilities (OWASP Top 10) by
Top 10 Web Security Vulnerabilities (OWASP Top 10)Top 10 Web Security Vulnerabilities (OWASP Top 10)
Top 10 Web Security Vulnerabilities (OWASP Top 10)Brian Huff
23.1K views27 slides
Top 10 Web Security Vulnerabilities by
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesCarol McDonald
7.7K views74 slides
Dzhengis 93098 ajax - security by
Dzhengis 93098   ajax - securityDzhengis 93098   ajax - security
Dzhengis 93098 ajax - securitydzhengo44
521 views11 slides
AJAX: How to Divert Threats by
AJAX:  How to Divert ThreatsAJAX:  How to Divert Threats
AJAX: How to Divert ThreatsCenzic
1.3K views33 slides

More Related Content

What's hot

Ajax Security Dangers by
Ajax Security DangersAjax Security Dangers
Ajax Security Dangersdrkimsky
2.6K views8 slides
RSA Europe 2013 OWASP Training by
RSA Europe 2013 OWASP TrainingRSA Europe 2013 OWASP Training
RSA Europe 2013 OWASP TrainingJim Manico
16.3K views150 slides
Case Study of Django: Web Frameworks that are Secure by Default by
Case Study of Django: Web Frameworks that are Secure by DefaultCase Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultMohammed ALDOUB
9.3K views34 slides
Owasp Top 10 A1: Injection by
Owasp Top 10 A1: InjectionOwasp Top 10 A1: Injection
Owasp Top 10 A1: InjectionMichael Hendrickx
10K views31 slides
Web Hacking by
Web HackingWeb Hacking
Web HackingInformation Technology
13.2K views54 slides
Starwest 2008 by
Starwest 2008Starwest 2008
Starwest 2008Caleb Sima
798 views40 slides

What's hot(20)

Ajax Security Dangers by drkimsky
Ajax Security DangersAjax Security Dangers
Ajax Security Dangers
drkimsky2.6K views
RSA Europe 2013 OWASP Training by Jim Manico
RSA Europe 2013 OWASP TrainingRSA Europe 2013 OWASP Training
RSA Europe 2013 OWASP Training
Jim Manico16.3K views
Case Study of Django: Web Frameworks that are Secure by Default by Mohammed ALDOUB
Case Study of Django: Web Frameworks that are Secure by DefaultCase Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by Default
Mohammed ALDOUB9.3K views
Starwest 2008 by Caleb Sima
Starwest 2008Starwest 2008
Starwest 2008
Caleb Sima798 views
A7 Missing Function Level Access Control by stevil1224
A7   Missing Function Level Access ControlA7   Missing Function Level Access Control
A7 Missing Function Level Access Control
stevil12245.6K views
Web application security: Threats & Countermeasures by Aung Thu Rha Hein
Web application security: Threats & CountermeasuresWeb application security: Threats & Countermeasures
Web application security: Threats & Countermeasures
Aung Thu Rha Hein7.4K views
OWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADF by Brian Huff
OWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADFOWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADF
OWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADF
Brian Huff8.6K views
Web application security & Testing by Deepu S Nath
Web application security  & TestingWeb application security  & Testing
Web application security & Testing
Deepu S Nath10.1K views
Cross Site Scripting (XSS) Defense with Java by Jim Manico
Cross Site Scripting (XSS) Defense with JavaCross Site Scripting (XSS) Defense with Java
Cross Site Scripting (XSS) Defense with Java
Jim Manico9K views
Owasp top 10 web application security hazards - Part 1 by Abhinav Sejpal
Owasp top 10 web application security hazards - Part 1Owasp top 10 web application security hazards - Part 1
Owasp top 10 web application security hazards - Part 1
Abhinav Sejpal1.3K views
A2 - broken authentication and session management(OWASP thailand chapter Apri... by Noppadol Songsakaew
A2 - broken authentication and session management(OWASP thailand chapter Apri...A2 - broken authentication and session management(OWASP thailand chapter Apri...
A2 - broken authentication and session management(OWASP thailand chapter Apri...
Noppadol Songsakaew4.3K views
Avoiding Cross Site Scripting - Not as easy as you might think by Erlend Oftedal
Avoiding Cross Site Scripting - Not as easy as you might thinkAvoiding Cross Site Scripting - Not as easy as you might think
Avoiding Cross Site Scripting - Not as easy as you might think
Erlend Oftedal10.2K views
Owasp top 10 web application security hazards part 2 by Abhinav Sejpal
Owasp top 10 web application security hazards part 2Owasp top 10 web application security hazards part 2
Owasp top 10 web application security hazards part 2
Abhinav Sejpal875 views
Web application attacks by hruth
Web application attacksWeb application attacks
Web application attacks
hruth56.5K views
Common Web Application Attacks by Ahmed Sherif
Common Web Application Attacks Common Web Application Attacks
Common Web Application Attacks
Ahmed Sherif802 views
Reliable and fast security audits - The modern and offensive way-Mohan Gandhi by bhumika2108
Reliable and fast security audits - The modern and offensive way-Mohan GandhiReliable and fast security audits - The modern and offensive way-Mohan Gandhi
Reliable and fast security audits - The modern and offensive way-Mohan Gandhi
bhumika21082.4K views

Similar to Become a Security Ninja

Developing Secure Applications and Defending Against Common Attacks by
Developing Secure Applications and Defending Against Common AttacksDeveloping Secure Applications and Defending Against Common Attacks
Developing Secure Applications and Defending Against Common AttacksPayPalX Developer Network
3.5K views35 slides
Spa Secure Coding Guide by
Spa Secure Coding GuideSpa Secure Coding Guide
Spa Secure Coding GuideGeoffrey Vandiest
152 views32 slides
Scalable threat modelling with risk patterns by
Scalable threat modelling with risk patternsScalable threat modelling with risk patterns
Scalable threat modelling with risk patternsStephen de Vries
1.2K views51 slides
Django (Web Applications that are Secure by Default) by
Django �(Web Applications that are Secure by Default�)Django �(Web Applications that are Secure by Default�)
Django (Web Applications that are Secure by Default)Kishor Kumar
644 views30 slides
How to Test for The OWASP Top Ten by
 How to Test for The OWASP Top Ten How to Test for The OWASP Top Ten
How to Test for The OWASP Top TenSecurity Innovation
3.3K views36 slides
Owasp top10salesforce by
Owasp top10salesforceOwasp top10salesforce
Owasp top10salesforcegbreavin
3.9K views18 slides

Similar to Become a Security Ninja(20)

Scalable threat modelling with risk patterns by Stephen de Vries
Scalable threat modelling with risk patternsScalable threat modelling with risk patterns
Scalable threat modelling with risk patterns
Stephen de Vries1.2K views
Django (Web Applications that are Secure by Default) by Kishor Kumar
Django �(Web Applications that are Secure by Default�)Django �(Web Applications that are Secure by Default�)
Django (Web Applications that are Secure by Default)
Kishor Kumar644 views
Owasp top10salesforce by gbreavin
Owasp top10salesforceOwasp top10salesforce
Owasp top10salesforce
gbreavin3.9K views
Threat modeling with architectural risk patterns by Stephen de Vries
Threat modeling with architectural risk patternsThreat modeling with architectural risk patterns
Threat modeling with architectural risk patterns
Stephen de Vries3K views
2013 OWASP Top 10 by bilcorry
2013 OWASP Top 102013 OWASP Top 10
2013 OWASP Top 10
bilcorry14.2K views
Mr. Mohammed Aldoub - A case study of django web applications that are secur... by nooralmousa
Mr. Mohammed Aldoub  - A case study of django web applications that are secur...Mr. Mohammed Aldoub  - A case study of django web applications that are secur...
Mr. Mohammed Aldoub - A case study of django web applications that are secur...
nooralmousa486 views
Securing Your .NET Application by Iron Speed
Securing Your .NET ApplicationSecuring Your .NET Application
Securing Your .NET Application
Iron Speed515 views
香港六合彩 by baoyin
香港六合彩香港六合彩
香港六合彩
baoyin564 views
OWASP Top 10 Proactive Controls 2016 - PHP Québec August 2017 by Philippe Gamache
OWASP Top 10 Proactive Controls 2016 - PHP Québec August 2017OWASP Top 10 Proactive Controls 2016 - PHP Québec August 2017
OWASP Top 10 Proactive Controls 2016 - PHP Québec August 2017
Philippe Gamache438 views

Recently uploaded

Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...ShapeBlue
88 views20 slides
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院IttrainingIttraining
80 views8 slides
Network Source of Truth and Infrastructure as Code revisited by
Network Source of Truth and Infrastructure as Code revisitedNetwork Source of Truth and Infrastructure as Code revisited
Network Source of Truth and Infrastructure as Code revisitedNetwork Automation Forum
42 views45 slides
Five Things You SHOULD Know About Postman by
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About PostmanPostman
40 views43 slides
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...Bernd Ruecker
50 views69 slides
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...Jasper Oosterveld
28 views49 slides

Recently uploaded(20)

Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue88 views
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman40 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker50 views
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... by ShapeBlue
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
ShapeBlue83 views
Business Analyst Series 2023 - Week 4 Session 7 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray1080 views
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue by ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
ShapeBlue131 views
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue by ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
ShapeBlue96 views
"Surviving highload with Node.js", Andrii Shumada by Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays40 views
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue96 views
NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu141 views
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue74 views
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De... by Moses Kemibaro
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Moses Kemibaro29 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue77 views
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT by ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue91 views

Become a Security Ninja

  • 1. BECOME A SECURITY NINJA Don’t let your code be low-hanging fruit Paul Gilzow
 gilzow@missouri.edu
 Twitter: @gilzow
 Facebook: /gilzow
 https://www.linkedin.com/in/gilzow
  • 2. What we will talk about Get our example files up and running What is OWASP What is the OWASP Top 10 The Current Top 10 Web Security Risks ATTACK!
  • 3. Set Up Our Exercise files Log into your Digital Ocean account
 https://cloud.digitalocean.com/login
 
 
 
 
 
 
 

  • 4. Set Up Our Exercise files Click on “Create Droplet”
 
 
 
 
 
 
 
 
 
 

  • 5. Set Up Our Exercise files Choose a size Click on “One-click apps”
 
 
 
 
 
 
 
 
 
 
 

  • 6. Set Up Our Excersice files Click on Docker
 
 
 
 
 
 
 
 
 
 
 

  • 7. Set Up Our Excersice files Scroll to the bottom of the page Click the “Create” button
 
 
 
 
 
 
 
 
 
 
 

  • 8. Set Up Our Excersice files Once the instance is created, check your email for the credentials In your ssh client, log into your new instance
 
 
 
 
 
 
 
 
 
 
 

  • 9. Set Up Our Excersice files You’ll need to change your password the first time you login
 
 
 
 
 
 
 
 
 
 
 

  • 10. Set Up Our Excersice files At the prompt type in
 
 docker run -d -p 8899:80 opendns/security-ninjas Docker will download and install the security-ninjas container
 
 
 
 
 
 
 
 
 

  • 11. Set Up Our Excersice files Open your browser and go to your droplet ip address, port 8899
 e.g. http://45.55.167.245:8899
 
 
 
 
 
 
 
 
 

  • 12. What is OWASP Open Web Application Security Project Worldwide non-project organization focused on improving software security by raising awareness Started in 2001 Hundreds of local chapters throughout the world, with over a hundred in the U.S.
  • 13. Current State of Web App security 160% increase in websites hosting malware between 2015 and 20161 55% of web apps have at least one high-severity vulnerability, up 9% from 2015 to 20162 84% are suscptible to at least one medium-serverity vulnerability2 Average of 15 vulnerabilities per site3 1 - Google Transparency Report, 2016 2 - Acunetix Web Application Vulnerability report 2016 3 - White Hat Security Web Applications Security Statistics Report 2016
  • 14. Education, 49% of sites had at least one vulnerability every day of the year1 Education, average of 28 vulnerabilities per site, 15 of those serious1 Education, took an average of 4 months to remediate issues1 1 - White Hat Security Web Applications Security Statistics Report 2016 Education Industry Current State of Web App security
  • 15. Why Education is an attractive target Network capacity and availability Rich in hardware infrastructure Poor in human resources Resistant to blacklisting SEO reputation Personally Identifiable Information (PII) / Sensitive Personal Information (SPI) Confidential Research Data / Proprietary Intellectual Property
  • 16. What is the OWASP Top 10 Not a standard, but an awareness document 10 Most Critical Web Application Security Risks For each risk, it includes Description Example vulnerabilities Example Attacks Guidance on how to avoid First released in 2003, refreshed every 3 years Current version is from 2013, next version due out late this year, early 2017
  • 17. Current Top 10 (as of 2013) 1. Injection 2. Broken Authentication and Session Management 3. Cross-Site Scripting (XSS) 4. Insecure Direct Object Reference 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
  • 18. A1. Injection • Untrusted/tainted data is sent to an interpreter as part of a command or query. • Interpreter is tricked into executing unintended commands What is it?
  • 19. A1. Injection • HTML/Javascript • SQL • LDAP • Xpath/Xquery • Anything that accepts input and executes What is susceptible?
  • 21. A1. Injection • Failure to separate untrusted data with commands sent to an interpreter • Lack of input validation and/or input sanitation • Attacker is able to change execution context Why does it happen?
  • 22. A1. Injection • SQL Injection
 
 
 SELECT UserId, Name, Password FROM Users WHERE UserId = $input;
 
 Becomes
 
 SELECT UserId, Name, Password FROM Users WHERE UserId = 105 or 1=1;
 
 
 Examples
  • 24. A1. Injection • Use APIs that provide parameterized/sanitized interfaces • Validate input against a whitelist (do NOT use a blacklist) • Escape any special characters that you whitelist
 
 
 Prevention
  • 25. A2. Broken Authentication and Session Management • Failure to protect credentials and session tokens throughout the lifecycle of the session • Weak authentication logic • Imperfect implementation What is it?
  • 26. A2. Broken Authentication and Session Management • Passing the session ID as a parameter in the URL • Using a predictable value for the session ID • User credentials passed unencrypted • Poor username and password recovery functions Why does it happen?
  • 27. A2. Broken Authentication and Session Management ATTACK!
  • 28. A2. Broken Authentication and Session Management • Never send credentials/sensitive data in the clear; use SSL • Protect secrets throughout their lifecycle • Don’t expose credentials (including session IDs) in the URL or logs • Use centralized authentication and session management APIs, if available • Implement strong account management functions (e.g., account creation, change password, recover password, etc.) • Use strong algorithms to generate (random) secrets • Do not rely on untrustworthy information for authentication (e.g. IP address, referrer, etc.) Prevention
  • 29. A2. Broken Authentication and Session Management • Use a different session ID after authentication or whenever authorization/permission levels change • Destroy/invalidate the session ID completely after the log out method has completed • Enforce session timeouts • Protect against Cross-Site Scripting (XSS) Prevention
  • 30. A3. Cross-Site Scripting (XSS) • Similar to injection, but the intended target is a user’s browser: the user’s browser is tricked into executing unintended commands • Usually in the form of HTML code or client-side scripts • Occurs when an application takes unstrusted data from the user and sends it back to the browser without validation or encoding • Exploits the trust the user has for a site What is it?
  • 31. If an attacker controls your browser, it is no longer your browser
  • 32. A3. Cross-Site Scripting • Failure to separate untrusted data with commands • Lack of input validation and/or input sanitation • Attacker is able to change execution context Why does it happen?
  • 33. A3. Cross-Site Scripting • Reflected • Stored (aka persistent) • Dom based Types
  • 34. A3. Cross-Site Scripting • Data from the URL is used in the creation of the page • Attacker tricks/entices user to click the exploited URL • Web application reflects the payload back to the user’s browser where it is executed as if it came from the originating site Types: Reflected
  • 35. A3. Cross-Site Scripting Types: Reflected Example
  • 36. A3. Cross-Site Scripting • Injected script is stored on the target server • The injection script is then sent to visitors of the site • Vicitim’s browser then executes the injected script as it believes it came from the originating site • Delayed (aka “Blind”) refers to the payload being executed at a later time, possibly in a completely different system (e.g. Log viewers, customer service apps, etc.) Types: Stored/Persistent
  • 37. A3. Cross-Site Scripting • Similar to reflected but instead of tricking the user’s browser to exectute script, tricks legitimate client side script into executing the payload • The attack payload is executed as a result of modifying the DOM environment in the victim’s browser used by the original client side script, so that the client side code runs in an unexpected manner • More prevalent now than in the past due to the increase use in javascript and vulnerable javascript libraries (almost 200% increase between 2015 and 20161 ) Types: Dom-based (aka Client Side) 1 - Acunetix web application vulnerability report 2016, pg 5
  • 38. A3. Cross-Site Scripting Types: Dom-based Example
  • 39. A3. Cross-Site Scripting Types: Dom-based Example, cont.
  • 41. A3. Cross-Site Scripting • Implicitly deny • Validate all input, regardless of where it comes from • Context-based output encoding Prevention
  • 42. A3. Cross-Site Scripting • HTML Element Content
 <div>DATA</div> • HTML Attribute Values
 <input name=“DATA” type=“text” value=“DATA” /> • Javascript Data
 <script>someFunc(‘DATA’);</script> • CSS Property Values
 .foo a:hover{ color: DATA } • URI Attribute VAlues
 <a href=“/search/?q=DATA”> Prevention - Context-based output encoding • ( &, <, >, “) —> &entity; 
 ( ‘, / ) —> &#DDD; or &#xHH; (UTF-8 encode) • All non-alphanumeric —> &#xHH; • All non-alphanumeric —> xHH • All non-alphanumeric —> HH • All non-alphanumeric —> %HH
  • 43. A3. Cross-Site Scripting • Implicitly deny • Validate all input, regardless of where it comes from • Context-based output encoding • Content-Security-Policy headers Prevention
  • 44. A3. Cross-Site Scripting Set of HTTP Response headers (or can be implemented via meta element) that defines where resources can be loaded from, preventing users’ browser from loading data from any other locations.
 
 Header Set Content-Security-Policy: script-src 'self' https://apis.google.com
 
 <meta http-equiv="Content-Security-Policy" content="default-src 'self'"> Prevention - Content-Security-Policy headers
  • 45. A3. Cross-Site Scripting Prevention - Content-Security-Policy headers
  • 46. A3. Cross-Site Scripting Prevention - Content-Security-Policy headers http://caniuse.com/#feat=contentsecuritypolicy
  • 47. A4. Insecure Direct Object References • Occurs when a reference to an internal implementation object (file, directory, database record/key) is exposed as a URL or form parameter • Without subsequent authorization checks, an attacker can manipulate these parameters to access unauthorized data What is it?
  • 48. A4. Insecure Direct Object References Examples
  • 49. A4. Insecure Direct Object References Examples http://foo.bar.edu/file.php?file=report.txt http://foo.bar.edu/file.php?file=../../app/config/database
  • 50. A4. Insecure Direct Object References ATTACK!
  • 51. A4. Insecure Direct Object References • Do not expose internal keys or identifiers for objects • Use object references that are difficult to guess • Perform server-side authorization checks for object access Prevention
  • 52. A5. Security Misconfiguration • Security issues anywhere in the stack • Framework • Application Server • Web Server • Database Server • Operating System • 3rd party contols/modules What is it?
  • 53. A5. Security Misconfiguration • Application dumps stack trace or reveals other debugging information • Default passwords not changed • Out-of-date software • Directory listings enabled Examples
  • 55. A5. Security Misconfiguration • Security hardening throughout the entire application stack • Change default passwords • Disable/remove debugging message and overly informative error messages in production • Remove unnecessary/unused features/modules/ components Prevention
  • 56. A6. Sensitive Data Exposure • Storing and transmitting sensitive data insecurely, due to: • Failure to identify all sensitive data • Failure to identify all locations where sensitive data is stored (database, files, logs, backups, etc) • Failure to identify all locations sensitive data is sent (web, databases, internal communications, external business partners) What is it?
  • 57. A6. Sensitive Data Exposure • Debugging information in comments of ouput sent to the browser • Application that stores sensitive data (correctly) encoutners an error and logs that data insecurely Examples
  • 58. A6. Sensitive Data Exposure ATTACK!
  • 59. A6. Sensitive Data Exposure Prevention
  • 60. Someone can’t steal it if you don’t have it
  • 61. A6. Sensitive Data Exposure • Don’t store sensitive data if you don’t need it • Catalog all sensitive data and where it is used • Disable caching of pages that contains sensitive data • Encrypt all sensitive data at rest and in transit • Use strong standard algorithms and strong keys Prevention
  • 62. A7. Missing Function Level Access Controls • Enforcing proper authorization for requests
 
 
 
 
 What is it?
  • 63. A7. Missing Function Level Access Controls Examples
  • 64. A7. Missing Function Level Access Controls • Attacker notices the URL structure indicates his role
 https://example.com/user/getAccount • Attacker modifies it to another role
 https://example.com/admin/getAccount • The application fails to do a server-side check to verify the request is coming from a user with the proper authorization and the attacker now has access to data on any account Examples
  • 65. A7. Missing Function Level Access Controls ATTACK!
  • 66. A7. Missing Function Level Access Controls • Deny by default • Perform server-side checks for every function/action that requires authorization • Server-side checks should not rely soley on information provided by the client Prevention
  • 67. A8. Cross-Site Request Forgery • Victim’s browser is tricked into issuing commands to a vulnerable web application, to perform an unwanted action on a trusted site for which the user is currently authenticated. • Web browsers automatically include credentials (cookies, sessions, basic authentication headers) with each request, even for requests initiated by a form, script or image on another site • Server-side code processes requests as if they came from the authenticated user • Often combined with Cross-Site Scripting What is it?
  • 68. A8. Cross-Site Request Forgery • Application is built to allow a state change via URL parameters
 
 http://bankx.com/app?action=transfer&amount=3500&destinationAccount=4673243243 • Attacker constructs a request that will transfer funds to to their account and embeds the requests on sites he controls. He then tricks the victim into visiting the site
 
 Examples <img src="http://bankx.com/app?action=transfer&amount=14000&destinationAccount=attackersAcct#" width="0" height="0" />
  • 69. A8. Cross-Site Request Forgery ATTACK!
  • 70. A8. Cross-Site Request Forgery • Eliminate all XSS vulnerabilities in your application • Never allow changes to data via a GET request • Check Origin and Referer headers as a first step • Include a per-request, cryptographically strong or random token to all forms, where the verification token is not provided by the browser • Require reauthentication for sensitive transactions Prevention
  • 71. A9. Using Components with Known Vulnerabilities • Using third-party controls/modules/frameworks with known vulnerabilities anywhere in the stack can be discovered and exploited by automated tools • Third-party libraries/frameworks in an application typically run with the same privileges as the application • Those vulnerabilities can undermine other defenses What is it?
  • 72. A9. Using Components with Known Vulnerabilities ATTACK!
  • 73. A9. Using Components with Known Vulnerabilities • Identify all third-party components in your applications, and potentially throughout the entire stack • Uninstall/disable all third-party components that are not being used • Monitor the security of these components in public databases (CVE, NVD, etc.), security mailing lists • Keep third-party components up-to-date religiously • Develop a security policy on third-party component use Prevention
  • 74. A10. Unvalidated Redirects and Forwards • Application takes input from an external source that is then used to formulate a redirection or forward location without validation • Attacker links to an unvalidated redirect and tricks victims into clicking it. Victims are more likely to click on it, since the link is to a valid site
 
 https://www.irs.gov/taxrefund/claim.jsp? year=2015&dest=ev.il/sDfX4 What is it?
  • 75. A10. Unvalidated Redirects and Forwards • Application uses forwards to route requests between different parts of the site. Pages use a parameter to indicate where the user should be sent if a transaction is successful. • Attacker crafts a URL that will pass the application’s access control check (or is missing control checks) and then forwards the attacker to administrative functionality for which the attacker isn’t authorized. What is it?
  • 76. A10. Unvalidated Redirects and Forwards ATTACK!
  • 77. A10. Unvalidated Redirects and Forwards • Don’t use them unless you absolutely have to • Avoid using user input to detemine destination URL • Whitelist allowed pages or external sites • Ensure URL is valid and authorized for the user Prevention
  • 79. Security is a process, not an event.
  • 80. Developer Take-aways • Security is a process, not an event • Build security into the software development life-cycle
 
 
 
 
 

  • 81. Be paranoid; be skeptical
  • 82. Developer Take-aways • Security is a process, not an event • Build security into the software development life-cycle • Be paranoid; be skeptical • Treat all data as tainted • Validate data first (whitelist), then filter (blacklist) • Validate/clean as early in the process as possible • Encode data appropriately before sending to the client • Never rely on client-side checks
  • 83. Developer Take-aways • Defense-in-depth • Principle of Least Privilege • Limit access to everything • Enforce strong passwords • Don’t harcode secrets in source code • Keep third-party components up-to-date • Error handling and Debug information Continued
  • 84. Questions? Contact gilzow@missouri.edu @gilzow on twitter Example Files: https://github.com/opendns/ Security_Ninjas_AppSec_Training Slidedeck: https://github.com/gilzow/security-ninja/