SlideShare a Scribd company logo
1 of 30
Download to read offline
Modern 
Web 
Applica0on 
Defense 
with 
OWASP 
Tools 
OWASP 
AppSec 
2014 
1
• Frank 
Kim 
– SANS 
Ins0tute 
• Curriculum 
About 
Lead, 
Applica0on 
Security 
• Author, 
Secure 
Coding 
in 
Java 
2
Cross-­‐Site 
Scrip0ng 
(XSS) 
• Occurs 
when 
unvalidated 
data 
is 
rendered 
in 
the 
browser 
• Types 
of 
XSS 
– Reflected 
– Stored 
– Document 
Object 
Model 
(DOM) 
based 
3
Contextual 
Output 
Encoding 
• OWASP 
ESAPI 
– hWps://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API 
Encoder e = ESAPI.encoder(); 
e.encodeForHTML(string); 
e.encodeForURL(string); 
e.encodeForJavaScript(string); 
• OWASP 
Java 
Encoder 
– hWps://www.owasp.org/index.php/OWASP_Java_Encoder_Project 
Encode.forHtml(value); 
Encode.forUri(value); 
Encode.forJavaScript(value); 
4
HWpOnly 
Flag 
• Ensures 
that 
the 
Cookie 
cannot 
be 
accessed 
via 
client 
side 
scripts 
(e.g. 
JavaScript) 
• Configure 
in 
web.xml 
as 
of 
Servlet 
3.0 
<session-config> 
<cookie-config> 
<http-only>true</http-only> 
</cookie-config> 
</session-config> 
• Programma0cally 
– Since 
Servlet 
3.0 
Cookie cookie = new Cookie("mycookie", "test"); 
cookie.setHttpOnly(true); 
– Before 
Servlet 
3.0 
String cookie = "mycookie=test; Secure; HttpOnly"; 
response.addHeader("Set-Cookie", cookie); 
5
Content 
Security 
Policy 
• Helps 
mi0gate 
XSS 
– Originally 
developed 
by 
Mozilla 
– Currently 
a 
W3C 
Candidate 
Recommenda0on 
• hWp://www.w3.org/TR/CSP 
• CSP 
headers 
– Content-Security-Policy 
• Star0ng 
in 
Firefox 
23 
and 
Chrome 
25 
– X-Content-Security-Policy 
• Experimental 
header 
supported 
in 
IE 
10 
and 
older 
Firefox 
versions 
– X-WebKit-CSP 
• Experimental 
header 
supported 
in 
Safari 
and 
older 
Chrome 
versions 
6
CSP 
Requirements 
• No 
inline 
scripts 
– Can't 
put 
code 
in 
<script> 
blocks 
– Can't 
do 
inline 
event 
handlers 
like 
<a onclick="javascript"> 
• No 
inline 
styles 
– Can't 
write 
styles 
inline 
7
CSP 
Direc0ves 
• default-­‐src 
• script-­‐src 
• object-­‐src 
• style-­‐src 
• img-­‐src 
• media-­‐src 
• frame-­‐src 
• font-­‐src 
• connect-­‐src 
8
CSP 
Examples 
1) 
Only 
load 
resources 
from 
the 
same 
origin 
X-Content-Security-Policy: default-src 'self' 
2) 
Example 
from 
mikewest.org 
x-content-security-policy: 
default-src 'none'; 
style-src https://mikewestdotorg.hasacdn.net; 
frame-src 
https://www.youtube.com 
http://www.slideshare.net; 
script-src 
https://mikewestdotorg.hasacdn.net 
https://ssl.google-analytics.com; 
img-src 'self' 
https://mikewestdotorg.hasacdn.net 
https://ssl.google-analytics.com data:; 
font-src https://mikewestdotorg.hasacdn.net 9
Report 
Only 
• Facebook 
Example 
x-content-security-policy-report-only: 
allow *; 
script-src https://*.facebook.com 
http://*.facebook.com 
https://*.fbcdn.net 
http://*.fbcdn.net 
*.facebook.net 
*.google-analytics.com 
*.virtualearth.net 
*.google.com 
127.0.0.1:* 
*.spotilocal.com:*; 
options inline-script eval-script; 
report-uri https://www.facebook.com/csp.php 10
Content 
Security 
Policy 
Demo 
11
Strict-­‐Transport-­‐Security 
• Tells 
browser 
to 
only 
talk 
to 
the 
server 
via 
HTTPS 
– First 
0me 
your 
site 
accessed 
via 
HTTPS 
and 
the 
header 
is 
used 
the 
browser 
stores 
the 
cer0ficate 
info 
– Subsequent 
requests 
to 
HTTP 
automa0cally 
use 
HTTPS 
• Supported 
browsers 
– Implemented 
in 
Firefox 
and 
Chrome 
– Currently 
an 
IETF 
drag 
Strict-Transport-Security: max-age=seconds 
[; includeSubdomains] 
12
X-­‐Frame-­‐Op0ons 
• Prevents 
Clickjacking 
– HTTP 
Response 
Header 
supported 
by 
modern 
browsers 
• Three 
op0ons 
– DENY 
• Prevents 
any 
site 
from 
framing 
the 
page 
– SAMEORIGIN 
• Allows 
framing 
only 
from 
the 
same 
origin 
– ALLOW-­‐FROM 
origin 
• Allows 
framing 
only 
from 
the 
specified 
origin 
• Only 
supported 
by 
IE 
(based 
on 
my 
tes0ng) 
• Firefox 
Bug 
690168 
-­‐ 
"This 
was 
an 
uninten0onal 
oversight" 
13
Using 
Secure 
Headers 
• OWASP 
Secure 
Headers 
Project 
– hWps://www.owasp.org/index.php/ 
OWASP_Secure_Headers_Project 
• Security 
Header 
Injec0on 
Module 
(SHIM) 
– Developed 
by 
Eric 
Johnson 
& 
Aaron 
Cure 
14
Cross-­‐Site 
Request 
Forgery 
(CSRF) 
15 
Vic0m 
browser 
mybank.com 
1) 
Vic0m 
signs 
on 
to 
mybank 
2) 
Vic0m 
visits 
aWacker.com 
3) 
Page 
contains 
CSRF 
code 
4) 
Browser 
sends 
<form 
ac0on=hWps://mybank.com/transfer.jsp 
the 
request 
to 
mybank 
method=POST> 
<input 
name=recipient 
value=aWacker> 
<input 
name=amount 
value=1000> 
</form> 
<script>document.forms[0].submit()</script> 
POST 
/transfer.jsp 
HTTP/1.1 
Cookie: 
<mybank 
authen0ca0on 
cookie> 
recipient=aWacker&amount=1000 
aWacker.com
OWASP 
1-­‐Liner 
• Deliberately 
vulnerable 
applica0on 
– Intended 
for 
demos 
and 
training 
– Created 
by 
John 
Wilander 
@johnwilander 
• More 
informa0on 
at 
– hWps://www.owasp.org/index.php/OWASP_1-­‐ 
Liner 
16
JSON 
CSRF 
Demo 
17
Normal 
JSON 
Message 
{"id":0,"nickName":"John",! 
"oneLiner":"I LOVE Java!",! 
"timestamp":"2013-05-27T17:04:23"}! 
18
Forged 
JSON 
Message 
! 
{"id": 0, "nickName": "John",! 
"oneLiner": "I hate Java!",! 
"timestamp": "20111006"}//=dummy! 
19
CSRF 
AWack 
Form 
<form id="target" method="POST"! 
action="https://local.1-liner.org:8444/ws/ 
vulnerable/oneliners" ! 
enctype="text/plain" ! 
style="visibility:hidden">! 
! 
<input type="text" ! 
name='{"id": 0, "nickName": "John",! 
"oneLiner": "I hate Java!",! 
"timestamp": "20111006"}//' ! 
value="dummy" />! 
! 
<input type="submit" value="Go" />! 
</form>! 
20
CSRF 
AWack 
Form 
<form id="target" method="POST"! 
action="https://local.1-liner.org:8444/ws/ 
vulnerable/oneliners" ! 
enctype="text/plain" ! 
style="visibility:hidden">! 
! 
<input type="text" ! 
name='{"id": 0, "nickName": "John",! 
"oneLiner": "I hate Java!",! 
"timestamp": "20111006"}//' ! 
value="dummy" />! 
! 
<input type="submit" value="Go" />! 
</form>! 
21
Forged 
JSON 
Message 
! 
{"id": 0, "nickName": "John",! 
"oneLiner": "I hate Java!",! 
"timestamp": "20111006"}//=dummy! 
22
CSRF 
Defense 
• Must 
include 
something 
random 
in 
the 
request 
– Use 
an 
an0-­‐CSRF 
token 
• OWASP 
CSRFGuard 
– WriWen 
by 
Eric 
Sheridan 
@eric_sheridan 
– Can 
inject 
an0-­‐CSRF 
token 
using 
• JSP 
Tag 
library 
-­‐ 
for 
manual, 
fine 
grained 
protec0on 
• JavaScript 
DOM 
manipula0on 
-­‐ 
for 
automated 
protec0on 
requiring 
minimal 
effort 
– Filter 
that 
intercepts 
requests 
and 
validates 
tokens 
23
CSRFGuard 
JSP 
Tags 
• Tags 
for 
token 
name 
and 
value 
<form name="test1" action="protect.html">! 
<input type="text" name="text" value="text"/>! 
<input type="submit" name="submit" value="submit"/>! 
<input type="hidden" name="<csrf:token-name/>"! 
value="<csrf:token-value/>"/> ! 
</form> 
• Tag 
for 
name/value 
pair 
(delimited 
with 
"=") 
<a href="protect.html?<csrf:token/>">protect.html</a>! 
• Convenience 
tags 
for 
forms 
and 
links 
as 
well 
<csrf:form> 
and 
<csrf:a>! 
! 
Examples 
from 
hWps://www.owasp.org/index.php/CSRFGuard_3_Token_Injec0on 
24
CSRFGuard 
DOM 
Manipula0on 
• Include 
JavaScript 
in 
every 
page 
that 
needs 
CSRF 
protec0on 
<script src="/securish/JavaScriptServlet"></script>! 
• JavaScript 
used 
to 
hook 
the 
open 
and 
send 
methods 
XMLHttpRequest.prototype._open = XMLHttpRequest.prototype.open;! 
XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {! 
// store a copy of the target URL! 
this.url = url; ! 
this._open.apply(this, arguments);! 
}! 
! 
XMLHttpRequest.prototype._send = XMLHttpRequest.prototype.send;! 
XMLHttpRequest.prototype.send = function(data) {! 
if(this.onsend != null) {! 
// call custom onsend method to modify the request! 
this.onsend.apply(this, arguments);! 
}! 
this._send.apply(this, arguments);! 
}! 
25
Protec0ng 
XHR 
Requests 
• CSRFGuard 
sends 
two 
HTTP 
headers 
XMLHttpRequest.prototype.onsend = function(data) {! 
if(isValidUrl(this.url)) {! 
this.setRequestHeader("X-Requested-With", ! 
"OWASP CSRFGuard Project")! 
this.setRequestHeader("OWASP_CSRFTOKEN", ! 
"EDTF-U8O6-J91L-RZOW-4X09-KEXB-K9B3-4OIV");! 
}! 
};! 
26
JSON 
CSRF 
Protec0on 
Demo 
27
Summary 
• Many 
tools 
to 
choose 
from 
– ESAPI, 
Java 
Encoder, 
Secure 
Headers 
Project, 
CSRFGuard, 
1-­‐Liner, 
Zed 
AWack 
Proxy 
(ZAP) 
• Look 
to 
use 
Secure 
HTTP 
Response 
Headers 
like 
– Content 
Security 
Policy 
– Strict-­‐Transport-­‐Security 
– X-­‐Frame-­‐Op0ons 
28
Frank 
Kim 
vim@sans.org 
@sansappsec
Modern Web Application Defense

More Related Content

What's hot

List of useful security related http headers
List of useful security related http headersList of useful security related http headers
List of useful security related http headers한익 주
 
Top Ten Web Hacking Techniques (2008)
Top Ten Web Hacking Techniques (2008)Top Ten Web Hacking Techniques (2008)
Top Ten Web Hacking Techniques (2008)Jeremiah Grossman
 
Django (Web Applications that are Secure by Default)
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
 
Top Ten Web Hacking Techniques (2010)
Top Ten Web Hacking Techniques (2010)Top Ten Web Hacking Techniques (2010)
Top Ten Web Hacking Techniques (2010)Jeremiah Grossman
 
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 DefaultMohammed ALDOUB
 
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolfDefeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolfdrewz lin
 
Introduction to web security @ confess 2012
Introduction to web security @ confess 2012Introduction to web security @ confess 2012
Introduction to web security @ confess 2012jakobkorherr
 
Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)Francois Marier
 
Phu appsec13
Phu appsec13Phu appsec13
Phu appsec13drewz lin
 
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 fundamentalsSimon Willison
 
Integrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptIntegrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptFrancois Marier
 
MITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another PerspectiveMITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another PerspectiveGreenD0g
 
Web Application Security in front end
Web Application Security in front endWeb Application Security in front end
Web Application Security in front endErlend Oftedal
 
Java script, security and you - Tri-Cities Javascript Developers Group
Java script, security and you - Tri-Cities Javascript Developers GroupJava script, security and you - Tri-Cities Javascript Developers Group
Java script, security and you - Tri-Cities Javascript Developers GroupAdam Caudill
 
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)nyccamp
 
WebView security on iOS (EN)
WebView security on iOS (EN)WebView security on iOS (EN)
WebView security on iOS (EN)lpilorz
 
Drivesploit: Circumventing Both Automated AND Manual Drive-By-Download Detection
Drivesploit: Circumventing Both Automated AND Manual Drive-By-Download DetectionDrivesploit: Circumventing Both Automated AND Manual Drive-By-Download Detection
Drivesploit: Circumventing Both Automated AND Manual Drive-By-Download DetectionWayne Huang
 
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome ExtensionsI'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome ExtensionsKrzysztof Kotowicz
 
JavaScript Security
JavaScript SecurityJavaScript Security
JavaScript SecurityJason Harwig
 

What's hot (20)

List of useful security related http headers
List of useful security related http headersList of useful security related http headers
List of useful security related http headers
 
Top Ten Web Hacking Techniques (2008)
Top Ten Web Hacking Techniques (2008)Top Ten Web Hacking Techniques (2008)
Top Ten Web Hacking Techniques (2008)
 
Django (Web Applications that are Secure by Default)
Django �(Web Applications that are Secure by Default�)Django �(Web Applications that are Secure by Default�)
Django (Web Applications that are Secure by Default)
 
Top Ten Web Hacking Techniques (2010)
Top Ten Web Hacking Techniques (2010)Top Ten Web Hacking Techniques (2010)
Top Ten Web Hacking Techniques (2010)
 
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
 
Browser Security
Browser SecurityBrowser Security
Browser Security
 
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolfDefeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
 
Introduction to web security @ confess 2012
Introduction to web security @ confess 2012Introduction to web security @ confess 2012
Introduction to web security @ confess 2012
 
Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)
 
Phu appsec13
Phu appsec13Phu appsec13
Phu appsec13
 
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
 
Integrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptIntegrity protection for third-party JavaScript
Integrity protection for third-party JavaScript
 
MITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another PerspectiveMITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another Perspective
 
Web Application Security in front end
Web Application Security in front endWeb Application Security in front end
Web Application Security in front end
 
Java script, security and you - Tri-Cities Javascript Developers Group
Java script, security and you - Tri-Cities Javascript Developers GroupJava script, security and you - Tri-Cities Javascript Developers Group
Java script, security and you - Tri-Cities Javascript Developers Group
 
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
 
WebView security on iOS (EN)
WebView security on iOS (EN)WebView security on iOS (EN)
WebView security on iOS (EN)
 
Drivesploit: Circumventing Both Automated AND Manual Drive-By-Download Detection
Drivesploit: Circumventing Both Automated AND Manual Drive-By-Download DetectionDrivesploit: Circumventing Both Automated AND Manual Drive-By-Download Detection
Drivesploit: Circumventing Both Automated AND Manual Drive-By-Download Detection
 
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome ExtensionsI'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
 
JavaScript Security
JavaScript SecurityJavaScript Security
JavaScript Security
 

Viewers also liked

Jason Kent - AppSec Without Additional Tools
Jason Kent - AppSec Without Additional ToolsJason Kent - AppSec Without Additional Tools
Jason Kent - AppSec Without Additional Toolscentralohioissa
 
Making Security Agile - Oleg Gryb
Making Security Agile - Oleg GrybMaking Security Agile - Oleg Gryb
Making Security Agile - Oleg GrybSeniorStoryteller
 
Building Security In - A Tale of Two Stories - Laksh Raghavan
Building Security In - A Tale of Two Stories - Laksh RaghavanBuilding Security In - A Tale of Two Stories - Laksh Raghavan
Building Security In - A Tale of Two Stories - Laksh RaghavanSeniorStoryteller
 
Purple Teaming the Cyber Kill Chain: Practical Exercises for Everyone Sector...
Purple Teaming the Cyber Kill Chain: Practical Exercises for Everyone  Sector...Purple Teaming the Cyber Kill Chain: Practical Exercises for Everyone  Sector...
Purple Teaming the Cyber Kill Chain: Practical Exercises for Everyone Sector...Chris Gates
 
How to adapt the SDLC to the era of DevSecOps
How to adapt the SDLC to the era of DevSecOpsHow to adapt the SDLC to the era of DevSecOps
How to adapt the SDLC to the era of DevSecOpsZane Lackey
 
Tactical Application Security: Getting Stuff Done - Black Hat Briefings 2015
Tactical Application Security: Getting Stuff Done - Black Hat Briefings 2015Tactical Application Security: Getting Stuff Done - Black Hat Briefings 2015
Tactical Application Security: Getting Stuff Done - Black Hat Briefings 2015Cory Scott
 

Viewers also liked (6)

Jason Kent - AppSec Without Additional Tools
Jason Kent - AppSec Without Additional ToolsJason Kent - AppSec Without Additional Tools
Jason Kent - AppSec Without Additional Tools
 
Making Security Agile - Oleg Gryb
Making Security Agile - Oleg GrybMaking Security Agile - Oleg Gryb
Making Security Agile - Oleg Gryb
 
Building Security In - A Tale of Two Stories - Laksh Raghavan
Building Security In - A Tale of Two Stories - Laksh RaghavanBuilding Security In - A Tale of Two Stories - Laksh Raghavan
Building Security In - A Tale of Two Stories - Laksh Raghavan
 
Purple Teaming the Cyber Kill Chain: Practical Exercises for Everyone Sector...
Purple Teaming the Cyber Kill Chain: Practical Exercises for Everyone  Sector...Purple Teaming the Cyber Kill Chain: Practical Exercises for Everyone  Sector...
Purple Teaming the Cyber Kill Chain: Practical Exercises for Everyone Sector...
 
How to adapt the SDLC to the era of DevSecOps
How to adapt the SDLC to the era of DevSecOpsHow to adapt the SDLC to the era of DevSecOps
How to adapt the SDLC to the era of DevSecOps
 
Tactical Application Security: Getting Stuff Done - Black Hat Briefings 2015
Tactical Application Security: Getting Stuff Done - Black Hat Briefings 2015Tactical Application Security: Getting Stuff Done - Black Hat Briefings 2015
Tactical Application Security: Getting Stuff Done - Black Hat Briefings 2015
 

Similar to Modern Web Application Defense

Cross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterCross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterMichael Coates
 
CS166 Final project
CS166 Final projectCS166 Final project
CS166 Final projectKaya Ota
 
How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?Ksenia Peguero
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encodingEoin Keary
 
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScriptWarning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScriptCyber Security Alliance
 
Top Ten Web Application Defenses v12
Top Ten Web Application Defenses v12Top Ten Web Application Defenses v12
Top Ten Web Application Defenses v12Jim Manico
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesBrad Hill
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxFernandoVizer
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsLewis Ardern
 
The top 10 security issues in web applications
The top 10 security issues in web applicationsThe top 10 security issues in web applications
The top 10 security issues in web applicationsDevnology
 
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Jim Manico
 
Application Security for RIAs
Application Security for RIAsApplication Security for RIAs
Application Security for RIAsjohnwilander
 
Hacking WebApps for fun and profit : how to approach a target?
Hacking WebApps for fun and profit : how to approach a target?Hacking WebApps for fun and profit : how to approach a target?
Hacking WebApps for fun and profit : how to approach a target?Yassine Aboukir
 
OWASP Khartoum - Top 10 A5 - 7th meeting - Cross Site Request Forgery
OWASP Khartoum - Top 10 A5 - 7th meeting - Cross Site Request ForgeryOWASP Khartoum - Top 10 A5 - 7th meeting - Cross Site Request Forgery
OWASP Khartoum - Top 10 A5 - 7th meeting - Cross Site Request ForgeryOWASP Khartoum
 
Wakanda and the top 5 security risks - JS.everyrwhere(2012) Europe
Wakanda and the top 5 security risks - JS.everyrwhere(2012) EuropeWakanda and the top 5 security risks - JS.everyrwhere(2012) Europe
Wakanda and the top 5 security risks - JS.everyrwhere(2012) EuropeAlexandre Morgaut
 
Evolution Of Web Security
Evolution Of Web SecurityEvolution Of Web Security
Evolution Of Web SecurityChris Shiflett
 
Waf.js: How to Protect Web Applications using JavaScript
Waf.js: How to Protect Web Applications using JavaScriptWaf.js: How to Protect Web Applications using JavaScript
Waf.js: How to Protect Web Applications using JavaScriptDenis Kolegov
 

Similar to Modern Web Application Defense (20)

Web Application Defences
Web Application DefencesWeb Application Defences
Web Application Defences
 
Cross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterCross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning Center
 
CS166 Final project
CS166 Final projectCS166 Final project
CS166 Final project
 
How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encoding
 
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScriptWarning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
 
Top Ten Web Application Defenses v12
Top Ten Web Application Defenses v12Top Ten Web Application Defenses v12
Top Ten Web Application Defenses v12
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptx
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript Applications
 
The top 10 security issues in web applications
The top 10 security issues in web applicationsThe top 10 security issues in web applications
The top 10 security issues in web applications
 
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2
 
Application Security for RIAs
Application Security for RIAsApplication Security for RIAs
Application Security for RIAs
 
Romulus OWASP
Romulus OWASPRomulus OWASP
Romulus OWASP
 
Hacking WebApps for fun and profit : how to approach a target?
Hacking WebApps for fun and profit : how to approach a target?Hacking WebApps for fun and profit : how to approach a target?
Hacking WebApps for fun and profit : how to approach a target?
 
OWASP Khartoum - Top 10 A5 - 7th meeting - Cross Site Request Forgery
OWASP Khartoum - Top 10 A5 - 7th meeting - Cross Site Request ForgeryOWASP Khartoum - Top 10 A5 - 7th meeting - Cross Site Request Forgery
OWASP Khartoum - Top 10 A5 - 7th meeting - Cross Site Request Forgery
 
Wakanda and the top 5 security risks - JS.everyrwhere(2012) Europe
Wakanda and the top 5 security risks - JS.everyrwhere(2012) EuropeWakanda and the top 5 security risks - JS.everyrwhere(2012) Europe
Wakanda and the top 5 security risks - JS.everyrwhere(2012) Europe
 
Spa Secure Coding Guide
Spa Secure Coding GuideSpa Secure Coding Guide
Spa Secure Coding Guide
 
Evolution Of Web Security
Evolution Of Web SecurityEvolution Of Web Security
Evolution Of Web Security
 
Waf.js: How to Protect Web Applications using JavaScript
Waf.js: How to Protect Web Applications using JavaScriptWaf.js: How to Protect Web Applications using JavaScript
Waf.js: How to Protect Web Applications using JavaScript
 

Recently uploaded

20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdfMatthew Sinclair
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...SUHANI PANDEY
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrHenryBriggs2
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...roncy bisnoi
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...SUHANI PANDEY
 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubaikojalkojal131
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...singhpriety023
 
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋nirzagarg
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge GraphsEleniIlkou
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfJOHNBEBONYAP1
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftAanSulistiyo
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirtrahman018755
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445ruhi
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceDelhi Call girls
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdfMatthew Sinclair
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...kajalverma014
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 

Recently uploaded (20)

20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck Microsoft
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
 

Modern Web Application Defense

  • 1. Modern Web Applica0on Defense with OWASP Tools OWASP AppSec 2014 1
  • 2. • Frank Kim – SANS Ins0tute • Curriculum About Lead, Applica0on Security • Author, Secure Coding in Java 2
  • 3. Cross-­‐Site Scrip0ng (XSS) • Occurs when unvalidated data is rendered in the browser • Types of XSS – Reflected – Stored – Document Object Model (DOM) based 3
  • 4. Contextual Output Encoding • OWASP ESAPI – hWps://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API Encoder e = ESAPI.encoder(); e.encodeForHTML(string); e.encodeForURL(string); e.encodeForJavaScript(string); • OWASP Java Encoder – hWps://www.owasp.org/index.php/OWASP_Java_Encoder_Project Encode.forHtml(value); Encode.forUri(value); Encode.forJavaScript(value); 4
  • 5. HWpOnly Flag • Ensures that the Cookie cannot be accessed via client side scripts (e.g. JavaScript) • Configure in web.xml as of Servlet 3.0 <session-config> <cookie-config> <http-only>true</http-only> </cookie-config> </session-config> • Programma0cally – Since Servlet 3.0 Cookie cookie = new Cookie("mycookie", "test"); cookie.setHttpOnly(true); – Before Servlet 3.0 String cookie = "mycookie=test; Secure; HttpOnly"; response.addHeader("Set-Cookie", cookie); 5
  • 6. Content Security Policy • Helps mi0gate XSS – Originally developed by Mozilla – Currently a W3C Candidate Recommenda0on • hWp://www.w3.org/TR/CSP • CSP headers – Content-Security-Policy • Star0ng in Firefox 23 and Chrome 25 – X-Content-Security-Policy • Experimental header supported in IE 10 and older Firefox versions – X-WebKit-CSP • Experimental header supported in Safari and older Chrome versions 6
  • 7. CSP Requirements • No inline scripts – Can't put code in <script> blocks – Can't do inline event handlers like <a onclick="javascript"> • No inline styles – Can't write styles inline 7
  • 8. CSP Direc0ves • default-­‐src • script-­‐src • object-­‐src • style-­‐src • img-­‐src • media-­‐src • frame-­‐src • font-­‐src • connect-­‐src 8
  • 9. CSP Examples 1) Only load resources from the same origin X-Content-Security-Policy: default-src 'self' 2) Example from mikewest.org x-content-security-policy: default-src 'none'; style-src https://mikewestdotorg.hasacdn.net; frame-src https://www.youtube.com http://www.slideshare.net; script-src https://mikewestdotorg.hasacdn.net https://ssl.google-analytics.com; img-src 'self' https://mikewestdotorg.hasacdn.net https://ssl.google-analytics.com data:; font-src https://mikewestdotorg.hasacdn.net 9
  • 10. Report Only • Facebook Example x-content-security-policy-report-only: allow *; script-src https://*.facebook.com http://*.facebook.com https://*.fbcdn.net http://*.fbcdn.net *.facebook.net *.google-analytics.com *.virtualearth.net *.google.com 127.0.0.1:* *.spotilocal.com:*; options inline-script eval-script; report-uri https://www.facebook.com/csp.php 10
  • 12. Strict-­‐Transport-­‐Security • Tells browser to only talk to the server via HTTPS – First 0me your site accessed via HTTPS and the header is used the browser stores the cer0ficate info – Subsequent requests to HTTP automa0cally use HTTPS • Supported browsers – Implemented in Firefox and Chrome – Currently an IETF drag Strict-Transport-Security: max-age=seconds [; includeSubdomains] 12
  • 13. X-­‐Frame-­‐Op0ons • Prevents Clickjacking – HTTP Response Header supported by modern browsers • Three op0ons – DENY • Prevents any site from framing the page – SAMEORIGIN • Allows framing only from the same origin – ALLOW-­‐FROM origin • Allows framing only from the specified origin • Only supported by IE (based on my tes0ng) • Firefox Bug 690168 -­‐ "This was an uninten0onal oversight" 13
  • 14. Using Secure Headers • OWASP Secure Headers Project – hWps://www.owasp.org/index.php/ OWASP_Secure_Headers_Project • Security Header Injec0on Module (SHIM) – Developed by Eric Johnson & Aaron Cure 14
  • 15. Cross-­‐Site Request Forgery (CSRF) 15 Vic0m browser mybank.com 1) Vic0m signs on to mybank 2) Vic0m visits aWacker.com 3) Page contains CSRF code 4) Browser sends <form ac0on=hWps://mybank.com/transfer.jsp the request to mybank method=POST> <input name=recipient value=aWacker> <input name=amount value=1000> </form> <script>document.forms[0].submit()</script> POST /transfer.jsp HTTP/1.1 Cookie: <mybank authen0ca0on cookie> recipient=aWacker&amount=1000 aWacker.com
  • 16. OWASP 1-­‐Liner • Deliberately vulnerable applica0on – Intended for demos and training – Created by John Wilander @johnwilander • More informa0on at – hWps://www.owasp.org/index.php/OWASP_1-­‐ Liner 16
  • 18. Normal JSON Message {"id":0,"nickName":"John",! "oneLiner":"I LOVE Java!",! "timestamp":"2013-05-27T17:04:23"}! 18
  • 19. Forged JSON Message ! {"id": 0, "nickName": "John",! "oneLiner": "I hate Java!",! "timestamp": "20111006"}//=dummy! 19
  • 20. CSRF AWack Form <form id="target" method="POST"! action="https://local.1-liner.org:8444/ws/ vulnerable/oneliners" ! enctype="text/plain" ! style="visibility:hidden">! ! <input type="text" ! name='{"id": 0, "nickName": "John",! "oneLiner": "I hate Java!",! "timestamp": "20111006"}//' ! value="dummy" />! ! <input type="submit" value="Go" />! </form>! 20
  • 21. CSRF AWack Form <form id="target" method="POST"! action="https://local.1-liner.org:8444/ws/ vulnerable/oneliners" ! enctype="text/plain" ! style="visibility:hidden">! ! <input type="text" ! name='{"id": 0, "nickName": "John",! "oneLiner": "I hate Java!",! "timestamp": "20111006"}//' ! value="dummy" />! ! <input type="submit" value="Go" />! </form>! 21
  • 22. Forged JSON Message ! {"id": 0, "nickName": "John",! "oneLiner": "I hate Java!",! "timestamp": "20111006"}//=dummy! 22
  • 23. CSRF Defense • Must include something random in the request – Use an an0-­‐CSRF token • OWASP CSRFGuard – WriWen by Eric Sheridan @eric_sheridan – Can inject an0-­‐CSRF token using • JSP Tag library -­‐ for manual, fine grained protec0on • JavaScript DOM manipula0on -­‐ for automated protec0on requiring minimal effort – Filter that intercepts requests and validates tokens 23
  • 24. CSRFGuard JSP Tags • Tags for token name and value <form name="test1" action="protect.html">! <input type="text" name="text" value="text"/>! <input type="submit" name="submit" value="submit"/>! <input type="hidden" name="<csrf:token-name/>"! value="<csrf:token-value/>"/> ! </form> • Tag for name/value pair (delimited with "=") <a href="protect.html?<csrf:token/>">protect.html</a>! • Convenience tags for forms and links as well <csrf:form> and <csrf:a>! ! Examples from hWps://www.owasp.org/index.php/CSRFGuard_3_Token_Injec0on 24
  • 25. CSRFGuard DOM Manipula0on • Include JavaScript in every page that needs CSRF protec0on <script src="/securish/JavaScriptServlet"></script>! • JavaScript used to hook the open and send methods XMLHttpRequest.prototype._open = XMLHttpRequest.prototype.open;! XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {! // store a copy of the target URL! this.url = url; ! this._open.apply(this, arguments);! }! ! XMLHttpRequest.prototype._send = XMLHttpRequest.prototype.send;! XMLHttpRequest.prototype.send = function(data) {! if(this.onsend != null) {! // call custom onsend method to modify the request! this.onsend.apply(this, arguments);! }! this._send.apply(this, arguments);! }! 25
  • 26. Protec0ng XHR Requests • CSRFGuard sends two HTTP headers XMLHttpRequest.prototype.onsend = function(data) {! if(isValidUrl(this.url)) {! this.setRequestHeader("X-Requested-With", ! "OWASP CSRFGuard Project")! this.setRequestHeader("OWASP_CSRFTOKEN", ! "EDTF-U8O6-J91L-RZOW-4X09-KEXB-K9B3-4OIV");! }! };! 26
  • 28. Summary • Many tools to choose from – ESAPI, Java Encoder, Secure Headers Project, CSRFGuard, 1-­‐Liner, Zed AWack Proxy (ZAP) • Look to use Secure HTTP Response Headers like – Content Security Policy – Strict-­‐Transport-­‐Security – X-­‐Frame-­‐Op0ons 28
  • 29. Frank Kim vim@sans.org @sansappsec