SlideShare a Scribd company logo
XSS Countermeasures in
Grails
Rafael Luque @rafael_luque — OSOCO
José San Leandro @rydnr — Ventura24
http://goo.gl/UGdJ0I
XSS Intro
XSS concepts
• What’s a XSS
• XSS Types: Reflected, stored, DOM-based.
• Famous XSS attacks: Samy worm, MrBean defacement, ...
XSS threats
• Interface defacement
• Session hijacking
• Click hijacking
• Malware infection
• Your PC may be joined to the horde of zombies in a BotNet.
Following
the
white
rabbit. . .
Something more than a joke. . .
Hooking your browser
Hooked browsers with BeEF
Exploiting your system
Exploiting the browser
1. Preparing the exploit server. . .
Exploiting the browser
2. Injecting an invisible frame pointing to the exploit server. . .
Exploiting the browser
3. Exploit works and executes the payload. . .
Exploiting the browser
4. Spawning notepad.exe process to migrate to. . .
Fun with
post-exploitation
Post-exploitation phase
Run a remote shell
Post-exploitation phase
Keylogging
Post-exploitation phase
Run VNC session
Post-exploitation phase
Run VNC session
Welcome to the
horde of
zombies
Joining to a botnet
1. Install the malware. . .
Joining to a botnet
2. Welcome to my botnet C&C. . .
Responsibilities: Why is
this still an issue?
Commercial software
• XSS is not known for business stakeholders
Commercial software
• XSS is not known for business stakeholders
• For most people, security means attacking your servers
Commercial software
• XSS is not known for business stakeholders
• For most people, security means attacking your servers
• Developers don’t pay enough attention
Do your homework
• Raise awareness
Do your homework
• Raise awareness
• Practice with security tools
Do your homework
• Raise awareness
• Practice with security tools
• Promote defensive coding
Do your homework
• Raise awareness
• Practice with security tools
• Promote defensive coding
• Improve monitoring
Understanding Grails
Encoding
Grails Pre-2.3 Gotchas
#1: Built-in default codec
#1: Built-in default codec
grails.views.default.codec
#1: Built-in default codec
is none!
grails.views.default.codec = ’’none’’
#1: Built-in default codec
is none!
Problems
You have to escape explicitly every untrusted
data:
encodeAsHTML()
encodeAsJavaScript()
encodeAsURL()
#1: Built-in default codec
is none!
Problems
High likelihood of XSS vulnerabilities in
production.
E.g. Grails.org website.
#1: Built-in default codec
is none!
Problems
Double-encoding prevention over Security by
default.
#1: Built-in default codec
is none!
Solution
Change default codec to HTML:
grails.views.default.codec = ’’html’’
#2: Inconsistent behaviour
Apply codec Does not apply codec
• GSP EL: ${...}
#2: Inconsistent behaviour
Apply codec Does not apply codec
• GSP EL: ${...}
• Tag: <g:tag .../>
#2: Inconsistent behaviour
Apply codec Does not apply codec
• GSP EL: ${...}
• Tag: <g:tag .../>
• GSP EL in tag attribute: <g:tag a="${...}"/>
#2: Inconsistent behaviour
Apply codec Does not apply codec
• GSP EL: ${...}
• Tag: <g:tag .../>
• GSP EL in tag attribute: <g:tag a="${...}"/>
• Tag as a method: ${g.tag(...)}
#2: Inconsistent behaviour
Apply codec Does not apply codec
• GSP EL: ${...}
• Tag: <g:tag .../>
• GSP EL in tag attribute: <g:tag a="${...}"/>
• Tag as a method: ${g.tag(...)}
• Scriptlets: <%= ... %>
#2: Inconsistent behaviour
Apply codec Does not apply codec
• GSP EL: ${...}
• Tag: <g:tag .../>
• GSP EL in tag attribute: <g:tag a="${...}"/>
• Tag as a method: ${g.tag(...)}
• Scriptlets: <%= ... %>
#3: Tag output is not
escaped
Problems
Review the tags you use to make sure they
encode their output or have options for this (e.g.
encodeAs attribute).
#3: Tag output is not
escaped
Problems
Review the tags from plugins you use.
#3: Tag output is not
escaped
Problems
Review the tags you invoke as methods in
Controllers.
#3: Tag output is not
escaped
Problems
Don’t trust Grails core tags, they have
inconsistent behaviour. E.g:
<g:fieldValue /> // HTML-encoded
<g:message /> // NO HTML-encoded
#3: Tag output is not
escaped
Solutions
If tag implementation doesn’t encode, add it
explicitly or invoke it as a method inside a GSP
expression:
<g:message ... encodeAs=’’HTML’’/>
${g.message(...)}
g.message(...).encodeAsHTML()
#4: g:message doesn’t
escape arguments
Problems
With default codec set to HTML the following
XSS attack vector works:
<g:message code=’welcome’ args=’[params.user]’/>
where:
welcome = Hi {0}!
params.user = <script>alert(’pwnd’)</script>
#4: g:message doesn’t
escape arguments
Solutions
Upgrade to a Grails version with the issue
(GRAILS-7170) fixed:
2.0.5, 2.1.5, 2.2.2, 2.3-M1
#4: g:message doesn’t
escape arguments
Solutions
Escape explicitly or invoke the tag inside a GSP
expression:
<g:message code=’welcome’ args=’[params.user]’
encodeAs=’HTML’/>
${g.message(code:’welcome’, args:[params.user])}
#5: One codec is not
enough
You MUST use the escape syntax for the context of the HTML
document you’re putting untrusted data into:
• HTML
• JavaScript
• URL
• CSS
#5: One codec is not
enough
HTML entity encoding doesn’t work if you’re using untrusted
data inside a <script>, or an event handler attribute like
onmouseover, or inside CSS, or in a URL.
#5: One codec is not
enough
Problems
You can override the default codec for a page,
but not to switch the codec for each context:
<%@page defaultCodec=’CODEC’ %>
#5: One codec is not
enough
Problems
How to manage GSPs with mixed encoding
requirements?
#5: One codec is not
enough
Solutions
Turn off default codec for that page and use
encodeAsJavaScript() and
encodeAsHTML() explicitly everywhere.
#5: One codec is not
enough
Solutions
Extract the JavaScript fragment to a GSP tag
encoding as JavaScript.
Grails 2.3 Encoding
Enhancements
#1: New configuration more
secure by default
#1: New configuration more
security by default
grails {
views {
gsp {
encoding = ’UTF-8’
htmlcodec = ’xml’ // use xml escaping instead of HTML4
codecs {
expression = ’html’ // escapes values inside ${}
scriptlet = ’html’ // escapes output from scriptlets in GSPs
taglib = ’none’ // escapes output from taglibs
staticparts = ’none’ // escapes output from static templates
}
}
// escapes all not-encoded output at final stage of outputting
filteringCodecForContentType {
//’text/html’ = ’html’
}
}
}
#2: Finer-grained control of
codecs
Control the codecs used per plugin:
pluginName.grails.views.gsp.codecs.expression = ’CODEC’
#2: Finer-grained control of
codecs
Control the codecs used per page:
<%@ expressionCodec=’CODEC’ %>
#2: Finer-grained control of
codecs
Control the default codec used by a tag library:
static defaultEncodeAs = ’HTML’
Or on a per tag basis:
static encodeAsForTags = [tagName: ’HTML’]
#2: Finer-grained control of
codecs
Add support for an optional encodeAs attribute to all tags
automatically:
<my:tag arg=’foo.bar’ encodeAs=’JavaScript’/>
#3: Context-sensitive
encoding switching
Tag withCodec(’CODEC’, Closure) to switch the current
default codec, pushing and popping a default codec stack.
out.println ’<script type=’’text/javascript’’>’
withCodec(‘‘JavaScript’’) {
out << body()
}
out.println()
out.println ’</script>’
#3: Context-sensitive
encoding switching
Core tags like <g:javascript/> and <r:script/>
automatically set an appropriate codec.
#4: Raw output
When you do not wish to encode a value, you can use the
raw() method.
${raw(book.title)}
It’s available in GSPs, controllers and tag libraries.
#5: Default encoding for all
output
You can configure Grails to encode all output at the end of a
response.
#5: Default encoding for all
output
grails {
views {
gsp {
codecs {
...
staticparts = ’raw’ // escapes output from static templates
}
}
// escapes all not-encoded output at final stage of outputting
filteringCodecForContentType {
’text/html’ = ’html’
}
}
}
If activated, the staticparts codec needs to be set to raw so
that static markup is not encoded.
Check your Plugins
security
Plugins are also part of your application
• Grails plugins are not security audited
Plugins are also part of your application
• Grails plugins are not security audited
• Grails plugins are part of your application’s attack surface
Plugins are also part of your application
• Grails plugins are not security audited
• Grails plugins are part of your application’s attack surface
• Review plugins to make sure they encode, and if they don’t
you should JIRA the authors immediately, and fork and
patch to fix your app quickly.
E.g. Javamelody vulnerability
• CVE-2013-4378 vulnerability reported.
E.g. Javamelody vulnerability
• CVE-2013-4378 vulnerability reported.
• Allows blind XSS attack via X-Forwarded-For header
spoofing.
E.g. Javamelody vulnerability
• CVE-2013-4378 vulnerability reported.
• Allows blind XSS attack via X-Forwarded-For header
spoofing.
• The attack target is the admin’s browser.
E.g. Javamelody vulnerability
• CVE-2013-4378 vulnerability reported.
• Allows blind XSS attack via X-Forwarded-For header
spoofing.
• The attack target is the admin’s browser.
• Fixed in the last release (1.47).
E.g. Javamelody vulnerability
• CVE-2013-4378 vulnerability reported.
• Allows blind XSS attack via X-Forwarded-For header
spoofing.
• The attack target is the admin’s browser.
• Fixed in the last release (1.47).
• You should upgrade ASAP.
Demo: Javamelody XSSed
Solutions: What options
do we have?
Think like an attacker
• According to your grails version
Think like an attacker
• According to your grails version
• Find unescaped values
Think like an attacker
• According to your grails version
• Find unescaped values
• Use fuzzers
Think like an attacker
• According to your grails version
• Find unescaped values
• Use fuzzers
• Read and understand Samy code
Think like an attacker
• According to your grails version
• Find unescaped values
• Use fuzzers
• Read and understand Samy code
• Review OWASP XSS cheatsheets
Be aware
• Review your Grails app to double-check how all dynamic
content gets escaped
Be aware
• Review your Grails app to double-check how all dynamic
content gets escaped
• Monitor for suspicious traffic
Be aware
• Review your Grails app to double-check how all dynamic
content gets escaped
• Monitor for suspicious traffic
• Spread the knowledge
Be aware
• Review your Grails app to double-check how all dynamic
content gets escaped
• Monitor for suspicious traffic
• Spread the knowledge
• Adopt ZAP or similar fuzzers in your CI process
Be aware
• Review your Grails app to double-check how all dynamic
content gets escaped
• Monitor for suspicious traffic
• Spread the knowledge
• Adopt ZAP or similar fuzzers in your CI process
• Review available security plugins for Grails
Application firewalls
• Enable common, safe rules
Application firewalls
• Enable common, safe rules
• Log unexpected traffic
Application firewalls
• Enable common, safe rules
• Log unexpected traffic
• Don’t fool yourself
Early-adopt CSP
• CSP: Content Security Policy
Early-adopt CSP
• CSP: Content Security Policy
• Adds headers to disable default behavior
Early-adopt CSP
• CSP: Content Security Policy
• Adds headers to disable default behavior
• inline Javascript
Early-adopt CSP
• CSP: Content Security Policy
• Adds headers to disable default behavior
• inline Javascript
• dynamic code evaluation
Early-adopt CSP
• CSP: Content Security Policy
• Adds headers to disable default behavior
• inline Javascript
• dynamic code evaluation
• Still a Candidate Recommendation of W3C
Conclusions: Grails can
defeat XSS
Grails
• Is able to defend our application from XSS attacks
Grails
• Is able to defend our application from XSS attacks
• But we need to pay attention to the details
Grails
• Is able to defend our application from XSS attacks
• But we need to pay attention to the details
• Upgrade to 2.3 ASAP
Grails
• Is able to defend our application from XSS attacks
• But we need to pay attention to the details
• Upgrade to 2.3 ASAP
• Pay attention to XSS
XSS
• Is much more dangerous than defacement jokes
XSS
• Is much more dangerous than defacement jokes
• The browsers are the actual target
XSS
• Is much more dangerous than defacement jokes
• The browsers are the actual target
• Difficult to monitor
XSS
• Is much more dangerous than defacement jokes
• The browsers are the actual target
• Difficult to monitor
• Unconfortable counter-measures in the browser: NoScript,
Request Policy
Wake up
• Write secure applications by default
Wake up
• Write secure applications by default
• Get yourself used with Metasploit, Burp, ZAP
Wake up
• Write secure applications by default
• Get yourself used with Metasploit, Burp, ZAP
• Spread the word both horizontally and vertically
Picture credits
• Cover:
http://www.flickr.com/photos/usairforce/
CC by-nc
• White rabbit:
http://www.flickr.com/photos/alles-banane/5849593440
CC by-sa-nc
• Hieroglyphs:
http://www.flickr.com/photos/59372146@N00
CC by-sa-nc
• Zombies:
http://www.flickr.com/photos/aeviin/4986897433
CC by-sa-nc
XSS Countermeasures in
Grails
Rafael Luque @rafael_luque — OSOCO
José San Leandro @rydnr — Ventura24

More Related Content

What's hot

BlueHat v17 || You Are Making Application Whitelisting Difficult
BlueHat v17 || You Are Making Application Whitelisting Difficult BlueHat v17 || You Are Making Application Whitelisting Difficult
BlueHat v17 || You Are Making Application Whitelisting Difficult
BlueHat Security Conference
 
Network Security and Cryptography.pdf
Network Security and Cryptography.pdfNetwork Security and Cryptography.pdf
Network Security and Cryptography.pdf
AdityaKumar1548
 
Kioptrix 2014 5
Kioptrix 2014 5Kioptrix 2014 5
Kioptrix 2014 5
Jayesh Patel
 
Breaking the cyber kill chain!
Breaking the cyber kill chain!Breaking the cyber kill chain!
Breaking the cyber kill chain!
Nahidul Kibria
 
BlueHat v18 || May i see your credentials, please
BlueHat v18 || May i see your credentials, pleaseBlueHat v18 || May i see your credentials, please
BlueHat v18 || May i see your credentials, please
BlueHat Security Conference
 
Triển khai Modsecurity vào hệ thống NMS - Quan Minh Tâm
Triển khai Modsecurity vào hệ thống NMS - Quan Minh TâmTriển khai Modsecurity vào hệ thống NMS - Quan Minh Tâm
Triển khai Modsecurity vào hệ thống NMS - Quan Minh Tâm
Security Bootcamp
 
Neoito — Secure coding practices
Neoito — Secure coding practicesNeoito — Secure coding practices
Neoito — Secure coding practices
Neoito
 
In The Middle of Printers - The (In)Security of Pull Printing solutions - Hac...
In The Middle of Printers - The (In)Security of Pull Printing solutions - Hac...In The Middle of Printers - The (In)Security of Pull Printing solutions - Hac...
In The Middle of Printers - The (In)Security of Pull Printing solutions - Hac...
Jakub Kałużny
 
[Wroclaw #9] The purge - dealing with secrets in Opera Software
[Wroclaw #9] The purge - dealing with secrets in Opera Software[Wroclaw #9] The purge - dealing with secrets in Opera Software
[Wroclaw #9] The purge - dealing with secrets in Opera Software
OWASP
 
Crypto failures every developer should avoid
Crypto failures every developer should avoidCrypto failures every developer should avoid
Crypto failures every developer should avoidFilip Šebesta
 
Root via sms. 4G security assessment
Root via sms. 4G security assessment Root via sms. 4G security assessment
Root via sms. 4G security assessment
Sergey Gordeychik
 
Cryptography in PHP: Some Use Cases
Cryptography in PHP: Some Use CasesCryptography in PHP: Some Use Cases
Cryptography in PHP: Some Use Cases
Zend by Rogue Wave Software
 
Challenges Building Secure Mobile Applications
Challenges Building Secure Mobile ApplicationsChallenges Building Secure Mobile Applications
Challenges Building Secure Mobile Applications
Masabi
 
[ITAS.VN]CheckMarx-CxSuite-Sample result for webgoat5.3rc1
[ITAS.VN]CheckMarx-CxSuite-Sample result for webgoat5.3rc1[ITAS.VN]CheckMarx-CxSuite-Sample result for webgoat5.3rc1
[ITAS.VN]CheckMarx-CxSuite-Sample result for webgoat5.3rc1
ITAS VIETNAM
 
OWASP Poland Day 2018 - Amir Shladovsky - Crypto-mining
OWASP Poland Day 2018 - Amir Shladovsky - Crypto-miningOWASP Poland Day 2018 - Amir Shladovsky - Crypto-mining
OWASP Poland Day 2018 - Amir Shladovsky - Crypto-mining
OWASP
 
Stranger Danger: Securing Third Party Components (Tech2020)
Stranger Danger: Securing Third Party Components (Tech2020)Stranger Danger: Securing Third Party Components (Tech2020)
Stranger Danger: Securing Third Party Components (Tech2020)
Guy Podjarny
 

What's hot (17)

BlueHat v17 || You Are Making Application Whitelisting Difficult
BlueHat v17 || You Are Making Application Whitelisting Difficult BlueHat v17 || You Are Making Application Whitelisting Difficult
BlueHat v17 || You Are Making Application Whitelisting Difficult
 
Network Security and Cryptography.pdf
Network Security and Cryptography.pdfNetwork Security and Cryptography.pdf
Network Security and Cryptography.pdf
 
Kioptrix 2014 5
Kioptrix 2014 5Kioptrix 2014 5
Kioptrix 2014 5
 
Web Security.pdf
Web Security.pdfWeb Security.pdf
Web Security.pdf
 
Breaking the cyber kill chain!
Breaking the cyber kill chain!Breaking the cyber kill chain!
Breaking the cyber kill chain!
 
BlueHat v18 || May i see your credentials, please
BlueHat v18 || May i see your credentials, pleaseBlueHat v18 || May i see your credentials, please
BlueHat v18 || May i see your credentials, please
 
Triển khai Modsecurity vào hệ thống NMS - Quan Minh Tâm
Triển khai Modsecurity vào hệ thống NMS - Quan Minh TâmTriển khai Modsecurity vào hệ thống NMS - Quan Minh Tâm
Triển khai Modsecurity vào hệ thống NMS - Quan Minh Tâm
 
Neoito — Secure coding practices
Neoito — Secure coding practicesNeoito — Secure coding practices
Neoito — Secure coding practices
 
In The Middle of Printers - The (In)Security of Pull Printing solutions - Hac...
In The Middle of Printers - The (In)Security of Pull Printing solutions - Hac...In The Middle of Printers - The (In)Security of Pull Printing solutions - Hac...
In The Middle of Printers - The (In)Security of Pull Printing solutions - Hac...
 
[Wroclaw #9] The purge - dealing with secrets in Opera Software
[Wroclaw #9] The purge - dealing with secrets in Opera Software[Wroclaw #9] The purge - dealing with secrets in Opera Software
[Wroclaw #9] The purge - dealing with secrets in Opera Software
 
Crypto failures every developer should avoid
Crypto failures every developer should avoidCrypto failures every developer should avoid
Crypto failures every developer should avoid
 
Root via sms. 4G security assessment
Root via sms. 4G security assessment Root via sms. 4G security assessment
Root via sms. 4G security assessment
 
Cryptography in PHP: Some Use Cases
Cryptography in PHP: Some Use CasesCryptography in PHP: Some Use Cases
Cryptography in PHP: Some Use Cases
 
Challenges Building Secure Mobile Applications
Challenges Building Secure Mobile ApplicationsChallenges Building Secure Mobile Applications
Challenges Building Secure Mobile Applications
 
[ITAS.VN]CheckMarx-CxSuite-Sample result for webgoat5.3rc1
[ITAS.VN]CheckMarx-CxSuite-Sample result for webgoat5.3rc1[ITAS.VN]CheckMarx-CxSuite-Sample result for webgoat5.3rc1
[ITAS.VN]CheckMarx-CxSuite-Sample result for webgoat5.3rc1
 
OWASP Poland Day 2018 - Amir Shladovsky - Crypto-mining
OWASP Poland Day 2018 - Amir Shladovsky - Crypto-miningOWASP Poland Day 2018 - Amir Shladovsky - Crypto-mining
OWASP Poland Day 2018 - Amir Shladovsky - Crypto-mining
 
Stranger Danger: Securing Third Party Components (Tech2020)
Stranger Danger: Securing Third Party Components (Tech2020)Stranger Danger: Securing Third Party Components (Tech2020)
Stranger Danger: Securing Third Party Components (Tech2020)
 

Viewers also liked

Developing Secure Web Application - Cross-Site Scripting (XSS)
Developing Secure Web Application - Cross-Site Scripting (XSS)Developing Secure Web Application - Cross-Site Scripting (XSS)
Developing Secure Web Application - Cross-Site Scripting (XSS)Codecamp Romania
 
Load test nfr gathering
Load test nfr gatheringLoad test nfr gathering
Load test nfr gathering
Tomasz Fajks
 
Cross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert BoxCross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert Box
Aaron Weaver
 
Xss talk, attack and defense
Xss talk, attack and defenseXss talk, attack and defense
Xss talk, attack and defense
Prakashchand Suthar
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)OWASP Khartoum
 
Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation
Ikhade Maro Igbape
 
Cross site scripting attacks and defenses
Cross site scripting attacks and defensesCross site scripting attacks and defenses
Cross site scripting attacks and defenses
Mohammed A. Imran
 
Ppt on sql injection
Ppt on sql injectionPpt on sql injection
Ppt on sql injectionashish20012
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
kinish kumar
 
Pentesting Using Burp Suite
Pentesting Using Burp SuitePentesting Using Burp Suite
Pentesting Using Burp Suite
jasonhaddix
 
Web Hacking With Burp Suite 101
Web Hacking With Burp Suite 101Web Hacking With Burp Suite 101
Web Hacking With Burp Suite 101
Zack Meyers
 
Hack like a pro with burp suite - nullhyd
Hack like a pro with burp suite - nullhydHack like a pro with burp suite - nullhyd
Hack like a pro with burp suite - nullhyd
n|u - The Open Security Community
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
Amit Tyagi
 
Xss (cross site scripting)
Xss (cross site scripting)Xss (cross site scripting)
Xss (cross site scripting)
vinayh.vaghamshi _
 

Viewers also liked (14)

Developing Secure Web Application - Cross-Site Scripting (XSS)
Developing Secure Web Application - Cross-Site Scripting (XSS)Developing Secure Web Application - Cross-Site Scripting (XSS)
Developing Secure Web Application - Cross-Site Scripting (XSS)
 
Load test nfr gathering
Load test nfr gatheringLoad test nfr gathering
Load test nfr gathering
 
Cross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert BoxCross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert Box
 
Xss talk, attack and defense
Xss talk, attack and defenseXss talk, attack and defense
Xss talk, attack and defense
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
 
Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation
 
Cross site scripting attacks and defenses
Cross site scripting attacks and defensesCross site scripting attacks and defenses
Cross site scripting attacks and defenses
 
Ppt on sql injection
Ppt on sql injectionPpt on sql injection
Ppt on sql injection
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
 
Pentesting Using Burp Suite
Pentesting Using Burp SuitePentesting Using Burp Suite
Pentesting Using Burp Suite
 
Web Hacking With Burp Suite 101
Web Hacking With Burp Suite 101Web Hacking With Burp Suite 101
Web Hacking With Burp Suite 101
 
Hack like a pro with burp suite - nullhyd
Hack like a pro with burp suite - nullhydHack like a pro with burp suite - nullhyd
Hack like a pro with burp suite - nullhyd
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
 
Xss (cross site scripting)
Xss (cross site scripting)Xss (cross site scripting)
Xss (cross site scripting)
 

Similar to XSS Countermeasures in Grails

Grails vs XSS: Defending Grails against XSS attacks
Grails vs XSS: Defending Grails against XSS attacksGrails vs XSS: Defending Grails against XSS attacks
Grails vs XSS: Defending Grails against XSS attacks
Rafael Luque Leiva
 
Web security: Securing untrusted web content at browsers
Web security: Securing untrusted web content at browsersWeb security: Securing untrusted web content at browsers
Web security: Securing untrusted web content at browsers
Phú Phùng
 
Web security: Securing Untrusted Web Content in Browsers
Web security: Securing Untrusted Web Content in BrowsersWeb security: Securing Untrusted Web Content in Browsers
Web security: Securing Untrusted Web Content in Browsers
Phú Phùng
 
Secure Software: Action, Comedy or Drama? (2017 edition)
Secure Software: Action, Comedy or Drama? (2017 edition)Secure Software: Action, Comedy or Drama? (2017 edition)
Secure Software: Action, Comedy or Drama? (2017 edition)
Peter Sabev
 
IDA Vulnerabilities and Bug Bounty  by Masaaki Chida
IDA Vulnerabilities and Bug Bounty  by Masaaki ChidaIDA Vulnerabilities and Bug Bounty  by Masaaki Chida
IDA Vulnerabilities and Bug Bounty  by Masaaki Chida
CODE BLUE
 
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
Denis Kolegov
 
Sandboxing JS and HTML. A lession Learned
Sandboxing JS and HTML. A lession LearnedSandboxing JS and HTML. A lession Learned
Sandboxing JS and HTML. A lession Learned
Minded Security
 
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
GiorgiRcheulishvili
 
Google chrome sandbox
Google chrome sandboxGoogle chrome sandbox
Google chrome sandboxNephi Johnson
 
Defending Against Attacks With Rails
Defending Against Attacks With RailsDefending Against Attacks With Rails
Defending Against Attacks With Rails
Tony Amoyal
 
.Net Debugging Techniques
.Net Debugging Techniques.Net Debugging Techniques
.Net Debugging Techniques
Bala Subra
 
.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques
Bala Subra
 
Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007Stephan Chenette
 
Xss mitigation php [Repaired]
Xss mitigation php [Repaired]Xss mitigation php [Repaired]
Xss mitigation php [Repaired]Tinashe Makuti
 
Web Hacking Series Part 4
Web Hacking Series Part 4Web Hacking Series Part 4
Web Hacking Series Part 4
Aditya Kamat
 
Gartner Security & Risk Management Summit 2018
Gartner Security & Risk Management Summit 2018Gartner Security & Risk Management Summit 2018
Gartner Security & Risk Management Summit 2018
Paula Januszkiewicz
 
Piratng Avs to bypass exploit mitigation
Piratng Avs to bypass exploit mitigationPiratng Avs to bypass exploit mitigation
Piratng Avs to bypass exploit mitigation
Priyanka Aash
 
Captain Hook: Pirating AVs to Bypass Exploit Mitigations
Captain Hook: Pirating AVs to Bypass Exploit MitigationsCaptain Hook: Pirating AVs to Bypass Exploit Mitigations
Captain Hook: Pirating AVs to Bypass Exploit Mitigations
enSilo
 
Protractor: The Hacker way (NG-MY 2019)
Protractor: The Hacker way (NG-MY 2019)Protractor: The Hacker way (NG-MY 2019)
Protractor: The Hacker way (NG-MY 2019)
Will Huang
 
How to hide your browser 0-day @ Disobey
How to hide your browser 0-day @ DisobeyHow to hide your browser 0-day @ Disobey
How to hide your browser 0-day @ Disobey
Zoltan Balazs
 

Similar to XSS Countermeasures in Grails (20)

Grails vs XSS: Defending Grails against XSS attacks
Grails vs XSS: Defending Grails against XSS attacksGrails vs XSS: Defending Grails against XSS attacks
Grails vs XSS: Defending Grails against XSS attacks
 
Web security: Securing untrusted web content at browsers
Web security: Securing untrusted web content at browsersWeb security: Securing untrusted web content at browsers
Web security: Securing untrusted web content at browsers
 
Web security: Securing Untrusted Web Content in Browsers
Web security: Securing Untrusted Web Content in BrowsersWeb security: Securing Untrusted Web Content in Browsers
Web security: Securing Untrusted Web Content in Browsers
 
Secure Software: Action, Comedy or Drama? (2017 edition)
Secure Software: Action, Comedy or Drama? (2017 edition)Secure Software: Action, Comedy or Drama? (2017 edition)
Secure Software: Action, Comedy or Drama? (2017 edition)
 
IDA Vulnerabilities and Bug Bounty  by Masaaki Chida
IDA Vulnerabilities and Bug Bounty  by Masaaki ChidaIDA Vulnerabilities and Bug Bounty  by Masaaki Chida
IDA Vulnerabilities and Bug Bounty  by Masaaki Chida
 
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
 
Sandboxing JS and HTML. A lession Learned
Sandboxing JS and HTML. A lession LearnedSandboxing JS and HTML. A lession Learned
Sandboxing JS and HTML. A lession Learned
 
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
 
Google chrome sandbox
Google chrome sandboxGoogle chrome sandbox
Google chrome sandbox
 
Defending Against Attacks With Rails
Defending Against Attacks With RailsDefending Against Attacks With Rails
Defending Against Attacks With Rails
 
.Net Debugging Techniques
.Net Debugging Techniques.Net Debugging Techniques
.Net Debugging Techniques
 
.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques
 
Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007
 
Xss mitigation php [Repaired]
Xss mitigation php [Repaired]Xss mitigation php [Repaired]
Xss mitigation php [Repaired]
 
Web Hacking Series Part 4
Web Hacking Series Part 4Web Hacking Series Part 4
Web Hacking Series Part 4
 
Gartner Security & Risk Management Summit 2018
Gartner Security & Risk Management Summit 2018Gartner Security & Risk Management Summit 2018
Gartner Security & Risk Management Summit 2018
 
Piratng Avs to bypass exploit mitigation
Piratng Avs to bypass exploit mitigationPiratng Avs to bypass exploit mitigation
Piratng Avs to bypass exploit mitigation
 
Captain Hook: Pirating AVs to Bypass Exploit Mitigations
Captain Hook: Pirating AVs to Bypass Exploit MitigationsCaptain Hook: Pirating AVs to Bypass Exploit Mitigations
Captain Hook: Pirating AVs to Bypass Exploit Mitigations
 
Protractor: The Hacker way (NG-MY 2019)
Protractor: The Hacker way (NG-MY 2019)Protractor: The Hacker way (NG-MY 2019)
Protractor: The Hacker way (NG-MY 2019)
 
How to hide your browser 0-day @ Disobey
How to hide your browser 0-day @ DisobeyHow to hide your browser 0-day @ Disobey
How to hide your browser 0-day @ Disobey
 

Recently uploaded

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 

Recently uploaded (20)

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 

XSS Countermeasures in Grails

  • 1. XSS Countermeasures in Grails Rafael Luque @rafael_luque — OSOCO José San Leandro @rydnr — Ventura24
  • 4. XSS concepts • What’s a XSS • XSS Types: Reflected, stored, DOM-based. • Famous XSS attacks: Samy worm, MrBean defacement, ...
  • 5. XSS threats • Interface defacement • Session hijacking • Click hijacking • Malware infection • Your PC may be joined to the horde of zombies in a BotNet.
  • 7. Something more than a joke. . .
  • 11. Exploiting the browser 1. Preparing the exploit server. . .
  • 12. Exploiting the browser 2. Injecting an invisible frame pointing to the exploit server. . .
  • 13. Exploiting the browser 3. Exploit works and executes the payload. . .
  • 14. Exploiting the browser 4. Spawning notepad.exe process to migrate to. . .
  • 20. Welcome to the horde of zombies
  • 21. Joining to a botnet 1. Install the malware. . .
  • 22. Joining to a botnet 2. Welcome to my botnet C&C. . .
  • 23. Responsibilities: Why is this still an issue?
  • 24. Commercial software • XSS is not known for business stakeholders
  • 25. Commercial software • XSS is not known for business stakeholders • For most people, security means attacking your servers
  • 26. Commercial software • XSS is not known for business stakeholders • For most people, security means attacking your servers • Developers don’t pay enough attention
  • 27. Do your homework • Raise awareness
  • 28. Do your homework • Raise awareness • Practice with security tools
  • 29. Do your homework • Raise awareness • Practice with security tools • Promote defensive coding
  • 30. Do your homework • Raise awareness • Practice with security tools • Promote defensive coding • Improve monitoring
  • 34. #1: Built-in default codec grails.views.default.codec
  • 35. #1: Built-in default codec is none! grails.views.default.codec = ’’none’’
  • 36. #1: Built-in default codec is none! Problems You have to escape explicitly every untrusted data: encodeAsHTML() encodeAsJavaScript() encodeAsURL()
  • 37. #1: Built-in default codec is none! Problems High likelihood of XSS vulnerabilities in production. E.g. Grails.org website.
  • 38. #1: Built-in default codec is none! Problems Double-encoding prevention over Security by default.
  • 39. #1: Built-in default codec is none! Solution Change default codec to HTML: grails.views.default.codec = ’’html’’
  • 40. #2: Inconsistent behaviour Apply codec Does not apply codec • GSP EL: ${...}
  • 41. #2: Inconsistent behaviour Apply codec Does not apply codec • GSP EL: ${...} • Tag: <g:tag .../>
  • 42. #2: Inconsistent behaviour Apply codec Does not apply codec • GSP EL: ${...} • Tag: <g:tag .../> • GSP EL in tag attribute: <g:tag a="${...}"/>
  • 43. #2: Inconsistent behaviour Apply codec Does not apply codec • GSP EL: ${...} • Tag: <g:tag .../> • GSP EL in tag attribute: <g:tag a="${...}"/> • Tag as a method: ${g.tag(...)}
  • 44. #2: Inconsistent behaviour Apply codec Does not apply codec • GSP EL: ${...} • Tag: <g:tag .../> • GSP EL in tag attribute: <g:tag a="${...}"/> • Tag as a method: ${g.tag(...)} • Scriptlets: <%= ... %>
  • 45. #2: Inconsistent behaviour Apply codec Does not apply codec • GSP EL: ${...} • Tag: <g:tag .../> • GSP EL in tag attribute: <g:tag a="${...}"/> • Tag as a method: ${g.tag(...)} • Scriptlets: <%= ... %>
  • 46. #3: Tag output is not escaped Problems Review the tags you use to make sure they encode their output or have options for this (e.g. encodeAs attribute).
  • 47. #3: Tag output is not escaped Problems Review the tags from plugins you use.
  • 48. #3: Tag output is not escaped Problems Review the tags you invoke as methods in Controllers.
  • 49. #3: Tag output is not escaped Problems Don’t trust Grails core tags, they have inconsistent behaviour. E.g: <g:fieldValue /> // HTML-encoded <g:message /> // NO HTML-encoded
  • 50. #3: Tag output is not escaped Solutions If tag implementation doesn’t encode, add it explicitly or invoke it as a method inside a GSP expression: <g:message ... encodeAs=’’HTML’’/> ${g.message(...)} g.message(...).encodeAsHTML()
  • 51. #4: g:message doesn’t escape arguments Problems With default codec set to HTML the following XSS attack vector works: <g:message code=’welcome’ args=’[params.user]’/> where: welcome = Hi {0}! params.user = <script>alert(’pwnd’)</script>
  • 52. #4: g:message doesn’t escape arguments Solutions Upgrade to a Grails version with the issue (GRAILS-7170) fixed: 2.0.5, 2.1.5, 2.2.2, 2.3-M1
  • 53. #4: g:message doesn’t escape arguments Solutions Escape explicitly or invoke the tag inside a GSP expression: <g:message code=’welcome’ args=’[params.user]’ encodeAs=’HTML’/> ${g.message(code:’welcome’, args:[params.user])}
  • 54. #5: One codec is not enough You MUST use the escape syntax for the context of the HTML document you’re putting untrusted data into: • HTML • JavaScript • URL • CSS
  • 55. #5: One codec is not enough HTML entity encoding doesn’t work if you’re using untrusted data inside a <script>, or an event handler attribute like onmouseover, or inside CSS, or in a URL.
  • 56. #5: One codec is not enough Problems You can override the default codec for a page, but not to switch the codec for each context: <%@page defaultCodec=’CODEC’ %>
  • 57. #5: One codec is not enough Problems How to manage GSPs with mixed encoding requirements?
  • 58. #5: One codec is not enough Solutions Turn off default codec for that page and use encodeAsJavaScript() and encodeAsHTML() explicitly everywhere.
  • 59. #5: One codec is not enough Solutions Extract the JavaScript fragment to a GSP tag encoding as JavaScript.
  • 61. #1: New configuration more secure by default
  • 62. #1: New configuration more security by default grails { views { gsp { encoding = ’UTF-8’ htmlcodec = ’xml’ // use xml escaping instead of HTML4 codecs { expression = ’html’ // escapes values inside ${} scriptlet = ’html’ // escapes output from scriptlets in GSPs taglib = ’none’ // escapes output from taglibs staticparts = ’none’ // escapes output from static templates } } // escapes all not-encoded output at final stage of outputting filteringCodecForContentType { //’text/html’ = ’html’ } } }
  • 63. #2: Finer-grained control of codecs Control the codecs used per plugin: pluginName.grails.views.gsp.codecs.expression = ’CODEC’
  • 64. #2: Finer-grained control of codecs Control the codecs used per page: <%@ expressionCodec=’CODEC’ %>
  • 65. #2: Finer-grained control of codecs Control the default codec used by a tag library: static defaultEncodeAs = ’HTML’ Or on a per tag basis: static encodeAsForTags = [tagName: ’HTML’]
  • 66. #2: Finer-grained control of codecs Add support for an optional encodeAs attribute to all tags automatically: <my:tag arg=’foo.bar’ encodeAs=’JavaScript’/>
  • 67. #3: Context-sensitive encoding switching Tag withCodec(’CODEC’, Closure) to switch the current default codec, pushing and popping a default codec stack. out.println ’<script type=’’text/javascript’’>’ withCodec(‘‘JavaScript’’) { out << body() } out.println() out.println ’</script>’
  • 68. #3: Context-sensitive encoding switching Core tags like <g:javascript/> and <r:script/> automatically set an appropriate codec.
  • 69. #4: Raw output When you do not wish to encode a value, you can use the raw() method. ${raw(book.title)} It’s available in GSPs, controllers and tag libraries.
  • 70. #5: Default encoding for all output You can configure Grails to encode all output at the end of a response.
  • 71. #5: Default encoding for all output grails { views { gsp { codecs { ... staticparts = ’raw’ // escapes output from static templates } } // escapes all not-encoded output at final stage of outputting filteringCodecForContentType { ’text/html’ = ’html’ } } } If activated, the staticparts codec needs to be set to raw so that static markup is not encoded.
  • 73. Plugins are also part of your application • Grails plugins are not security audited
  • 74. Plugins are also part of your application • Grails plugins are not security audited • Grails plugins are part of your application’s attack surface
  • 75. Plugins are also part of your application • Grails plugins are not security audited • Grails plugins are part of your application’s attack surface • Review plugins to make sure they encode, and if they don’t you should JIRA the authors immediately, and fork and patch to fix your app quickly.
  • 76. E.g. Javamelody vulnerability • CVE-2013-4378 vulnerability reported.
  • 77. E.g. Javamelody vulnerability • CVE-2013-4378 vulnerability reported. • Allows blind XSS attack via X-Forwarded-For header spoofing.
  • 78. E.g. Javamelody vulnerability • CVE-2013-4378 vulnerability reported. • Allows blind XSS attack via X-Forwarded-For header spoofing. • The attack target is the admin’s browser.
  • 79. E.g. Javamelody vulnerability • CVE-2013-4378 vulnerability reported. • Allows blind XSS attack via X-Forwarded-For header spoofing. • The attack target is the admin’s browser. • Fixed in the last release (1.47).
  • 80. E.g. Javamelody vulnerability • CVE-2013-4378 vulnerability reported. • Allows blind XSS attack via X-Forwarded-For header spoofing. • The attack target is the admin’s browser. • Fixed in the last release (1.47). • You should upgrade ASAP.
  • 83. Think like an attacker • According to your grails version
  • 84. Think like an attacker • According to your grails version • Find unescaped values
  • 85. Think like an attacker • According to your grails version • Find unescaped values • Use fuzzers
  • 86. Think like an attacker • According to your grails version • Find unescaped values • Use fuzzers • Read and understand Samy code
  • 87. Think like an attacker • According to your grails version • Find unescaped values • Use fuzzers • Read and understand Samy code • Review OWASP XSS cheatsheets
  • 88. Be aware • Review your Grails app to double-check how all dynamic content gets escaped
  • 89. Be aware • Review your Grails app to double-check how all dynamic content gets escaped • Monitor for suspicious traffic
  • 90. Be aware • Review your Grails app to double-check how all dynamic content gets escaped • Monitor for suspicious traffic • Spread the knowledge
  • 91. Be aware • Review your Grails app to double-check how all dynamic content gets escaped • Monitor for suspicious traffic • Spread the knowledge • Adopt ZAP or similar fuzzers in your CI process
  • 92. Be aware • Review your Grails app to double-check how all dynamic content gets escaped • Monitor for suspicious traffic • Spread the knowledge • Adopt ZAP or similar fuzzers in your CI process • Review available security plugins for Grails
  • 93. Application firewalls • Enable common, safe rules
  • 94. Application firewalls • Enable common, safe rules • Log unexpected traffic
  • 95. Application firewalls • Enable common, safe rules • Log unexpected traffic • Don’t fool yourself
  • 96. Early-adopt CSP • CSP: Content Security Policy
  • 97. Early-adopt CSP • CSP: Content Security Policy • Adds headers to disable default behavior
  • 98. Early-adopt CSP • CSP: Content Security Policy • Adds headers to disable default behavior • inline Javascript
  • 99. Early-adopt CSP • CSP: Content Security Policy • Adds headers to disable default behavior • inline Javascript • dynamic code evaluation
  • 100. Early-adopt CSP • CSP: Content Security Policy • Adds headers to disable default behavior • inline Javascript • dynamic code evaluation • Still a Candidate Recommendation of W3C
  • 102. Grails • Is able to defend our application from XSS attacks
  • 103. Grails • Is able to defend our application from XSS attacks • But we need to pay attention to the details
  • 104. Grails • Is able to defend our application from XSS attacks • But we need to pay attention to the details • Upgrade to 2.3 ASAP
  • 105. Grails • Is able to defend our application from XSS attacks • But we need to pay attention to the details • Upgrade to 2.3 ASAP • Pay attention to XSS
  • 106. XSS • Is much more dangerous than defacement jokes
  • 107. XSS • Is much more dangerous than defacement jokes • The browsers are the actual target
  • 108. XSS • Is much more dangerous than defacement jokes • The browsers are the actual target • Difficult to monitor
  • 109. XSS • Is much more dangerous than defacement jokes • The browsers are the actual target • Difficult to monitor • Unconfortable counter-measures in the browser: NoScript, Request Policy
  • 110. Wake up • Write secure applications by default
  • 111. Wake up • Write secure applications by default • Get yourself used with Metasploit, Burp, ZAP
  • 112. Wake up • Write secure applications by default • Get yourself used with Metasploit, Burp, ZAP • Spread the word both horizontally and vertically
  • 113. Picture credits • Cover: http://www.flickr.com/photos/usairforce/ CC by-nc • White rabbit: http://www.flickr.com/photos/alles-banane/5849593440 CC by-sa-nc • Hieroglyphs: http://www.flickr.com/photos/59372146@N00 CC by-sa-nc • Zombies: http://www.flickr.com/photos/aeviin/4986897433 CC by-sa-nc
  • 114. XSS Countermeasures in Grails Rafael Luque @rafael_luque — OSOCO José San Leandro @rydnr — Ventura24