SlideShare a Scribd company logo
Web Client Side
Security -
Script Injection
Tal Be’ery
@Verint
2013
SOP Threat Model
Communicati
on
Custom Code
Accounts
Finance
Administratio
n
Transactions
Knowledge
Mgmt
E-Commerce
Bus.
Functions
Victim Application
3
Vulnerable site sees
legitimate request
from victim
performs the action
requested
And sends a
response
Attacker sets the trap on some website on the internet1
2
While logged into vulnerable site,
victim views attacker site
Victim site interaction
Some interaction
with victim site
Injecting Script to Defeat SOP
O So SOP does not allow scripts from a
different origin to access target origin’s
data?
O Then, attacker must get the script to run
from target’s origin!
Getting The Script In
O Malvertising: Paying the server to show
content (Malicious Ads)
O XSS :Abusing the application’s to serve
user content
O Breaking into the server to change content
O Mass injection
O Watering Hole attacks
O Injecting onto the connection (MitM)
Malvertising a Script
Paying the target site
O Paying the target site to serve attacker
controlled messages to its clients
O Paying for displaying content = advertising
Online advertising
O The business engine for the web
http://blogs-images.forbes.com/roberthof/files/2012/06/iabadrev.gif
Online advertising
O Many parties are involved
http://blogs.wsj.com/digits/2011/06/06/online-ads-where-1240-companies-fit-in/
Malvertising
O Malware advertising
O Usually in the context of malware
spreading
O If it allows scripting, can create XSS
http://2.bp.blogspot.com/-qyWHGQxwkPc/Tl0dNR-1g1I/AAAAAAAACdg/wsYFRVfM3NQ/s1600/malvertising%2Byieldmanager%2Bziddu%2Bwebsite.png
Targeting Ads
O Web ads can be highly targeted
O “C level” in “Israel” in the “security
industry”
Injecting a Script (XSS)
XSS = Script Injection
O Victim server embeds unsanitized user’s
Input in served content
O Served content can contain a script
invocation
O The script is from the origin of the victim
server and thus can access all of the
origin’s data
Stored XSS
O The victim server stores user generated
content
O Comments
O Profile in social network
O Reviews
O The content is displayed to other users
O If not properly sanitized the content can
contain a script
Stored XSS Illustrated
Attacker sets the trap – update my
profile
Attacker enters
a malicious
script into a
web page that
stores the data
on the server
1
Application
with stored
XSS
vulnerability
Custom Code
Accounts
Finance
Administratio
nTransactions
Communicati
onKnowledge
MgmtE-CommerceBus.
Functions
2 Victim views page – sees
attacker profile
Script runs
inside victim’s
browser with
full access to
the DOM and
cookies
3 Script silently sends attacker Victim’s session
cookie
1
Reflected XSS
O The victim sends back (reflects) user
generated content to the user
O “search results for <sent term>”
O “The form details you just filled <form
data>”
O The content is displayed to the user
O If not properly sanitized the content can
invoke a script
Reflected XSS
O Why should I attack myself?
O The attacker “convinces” the victim to
attack itself
O Link is embedded in attacker site
O Phishing email
Reflected XSS Demo
Reflected XSS Demo - testing
O Search page is a classic!
O /sitesearch/index.aspx?q=bbbbbbbbbbbb
Reflected XSS Demo – XSS!
O /index.aspx?q=<script> alert(
document.cookie); </script>
DOM Based XSS
O Javascript can change inner HTML
through the DOM
O If the script in victim server’s page accepts
input from user without sanitizing it and
changes the DOM than a script can be
invoked.
Javascript Invocation
O Direct Script Injection
O Event handler injection
O Javascript protocol injection
O Injecting into an existing script
Injection
O Injection happens when attacker is able to
make a cross over from data area to
control/code area
O All Injections (Script injections, but also
SQL injection, XML injection, LDAP
injection, etc.) share the same
characteristics:
O A token that ends the data part
O Some malicious code
O A token that returns to data part (optional)
Direct Script Injection
O <script>alert(1)</script>
O HTML parsers are usually very relaxed
and forgiving
Event handler injection
O Example:
O Original application:
O <img src="url" alt="some_user_text">
O Attacker:
O <img src="url" alt="” onload=“evil()">
Javascript protocol injection
O Injecting the javascript pseudo protocol in
places intended for URLs
O Original application:
O <iframe src="user supplied url" >
O Attacker:
O <iframe src=“Javascript:evil()" >
Injecting into an existing
script
O Input is embedded into existing script.
O Script must remain syntactically correct for
the malicious payload to execute
Injecting Into an Existing
Script – In the Wild
O The value of the locale HTTP parameter is
included directly in a javascript within the
response and assigned to the s_prop18
variable:
O <script>…var s_prop18="";alert(1);//“ …
</script>
XSS Attacker’s Tools
Vulnerability Scanners
O Many commercial tools
O IBM AppScan
O HP WebInspect
O Etc.
O Many free tools
Exploitation tools: BeEF
O The Browser Exploitation Framework
BeEF Demo!
XSS Protection
Input/Output Sanitizaiton
O Remove “bad” characters
O Encode “bad” characters
O Context dependent!
O When input is given the code does not
know in which context it would be
displayed
O When output is presented, the context is
known, but coder may forget its untrusted
origin
Too many contexts…
HTML Style Property
Values
(e.g., .pdiv a:hover {color: red; text-
decoration: underline} )
JavaScript Data
(e.g., <script> some javascript
</script> )
HTML Attribute Values
(e.g., <input name='person'
type='TEXT' value='defaultValue'> )
HTML Element
Content
(e.g., <div> some text to display
</div> )
URI Attribute Values
(e.g., <a href="javascript:toggle('lesson')"
)
#4: All non-alphanumeric < 256  HH
ESAPI: encodeForCSS()
#3: All non-alphanumeric < 256  xHH
ESAPI: encodeForJavaScript()
#1: ( &, <, >, " )  &entity; ( ', / )  &#xHH;
ESAPI: encodeForHTML()
#2: All non-alphanumeric < 256  &#xHH
ESAPI: encodeForHTMLAttribute()
#5: All non-alphanumeric < 256  %HH
ESAPI: encodeForURL()
CSP
O Content Security Policy
O Enables the website to specify with
custom headers the allowed scripts in the
page, so no new script can be injected
O In order for CSP to be effective, the
website code has to be refactored.
NoScript
O Client side plugin
O Stops scripts, but usually kills user
experience too
Web Application Firewalls
O Stop XSS vectors
O Both reflected and persistent
O Examples:
O Imperva SecureSphere
O ModSecurity
Browser XSS filter
O Checks for script invocation in user
supplied data
O Only effective against reflected XSS
XSS in the wild
XSSed.com
O http://xssed.com/
Scanners Stats
https://www.whitehatsec.com/assets/WPst
atsReport_052013.pdf
XSS in Google
http://www.acunetix.com/blog/web-security-zone/articles/xss-vulnerability-injected-google-analytics-executed-ioss-gmail-
application/
Breaking into the server
Watering Hole
O Waiting for the victim to come to the
attacker
http://tpzoo.files.wordpress.com/2013/02/lion-zebra-water-hole.jpg
Watering Hole Attack
O Break into a website
O Plant a malicious script in it
http://eromang.zataz.com/2013/02/20/facebook-apple-twitter-watering-hole-attack-additional-informations/
MITM
MITM
MITM Can Inject Scripts
O The victim requests “good.com”
O The attacker serves arbitrary content as a
response
O Scripts served that way, are considered by
the browser as coming from “good.com”
context
Attacker Don’t Have to Be
MITM
O Full MITM capabilities are not needed
O “Man on the Side” is enough
O It’s enough to be able:
O Eavesdrop for requests
O Be able to inject false responses
O No need to stop messages
The NSA Did It!
O QUANTUM program
O “..NSA relies on its secret partnerships with
US telecoms companies… the NSA places
secret servers, codenamed Quantum, at key
places on the Internet backbone. This
placement ensures that they can react faster
than other websites can. By exploiting that
speed difference, these servers can
impersonate a visited website to the target
before the legitimate website can respond..
https://www.schneier.com/blog/archives/2013/10
/how_the_nsa_att.html
Web Client Side
Security -
Implementation Bugs
Bugs In SOP
O 2004: Malicious redirects break IE’s SOP
implementation
Universal XSS
O Browser is not just the browser
O Addons, extensions, plugins…
O Some of them may have bugs in SOP
Adobe PDF Universal XSS
O Adobe PDF Reader universal XSS
O http://host/file.pdf#anyname=javascript:yo
ur_code_here
O If a site hosts a PDF it has XSS
vulnerability
https://www.owasp.org/images/4/4b/OWASP_IL_The_Universal_XSS_PDF_Vulnerability.pdf
Client Side Vulnerability
Black Hole Exploit Kit
Exploit Delivery
O Introduced with a script
O One of the Aforementioned Script Injection
techniques
O Checks for browser vendor, version and
installed component to use the right
exploit
O Creates the exploited object
Obfuscated Javascript
https://sophosnews.files.wordpress.com/2012/03/blackhole_paper_mar2012.pdf
Detect Vulnerabilities
PDF Exploit

More Related Content

PPTX
Client sidesec 2013 - non js
PPTX
Client sidesec 2013-intro
PPTX
Dom based xss
PDF
XSS-Alert-Pentration testing tool
PDF
Shreeraj-Hacking_Web_2
PDF
Rahul-Analysis_of_Adversarial_Code
PPT
Front end-security
KEY
Application Security for Rich Internet Applicationss (Jfokus 2012)
Client sidesec 2013 - non js
Client sidesec 2013-intro
Dom based xss
XSS-Alert-Pentration testing tool
Shreeraj-Hacking_Web_2
Rahul-Analysis_of_Adversarial_Code
Front end-security
Application Security for Rich Internet Applicationss (Jfokus 2012)

What's hot (20)

PPTX
MITM Attacks on HTTPS: Another Perspective
PPTX
Web Application Security in front end
PDF
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
PPTX
Its all about CSRF - null Mumbai Meet 10 January 2015 Null/OWASP Chapter
PDF
Grey H@t - Cross-site Request Forgery
KEY
Application Security for RIAs
PDF
Owasp eee 2015 csrf
PPTX
Reflective and Stored XSS- Cross Site Scripting
PPTX
Java script, security and you - Tri-Cities Javascript Developers Group
PDF
DEfcon15 XXE XXS
PDF
Linkedin.com DomXss 04-08-2014
PPTX
Web application security
PPTX
Xss (cross site scripting)
PPTX
Owasp Top 10 A3: Cross Site Scripting (XSS)
PDF
Top Ten Web Hacking Techniques (2008)
PPTX
Understanding Cross-site Request Forgery
PPTX
CSRF Attack and Its Prevention technique in ASP.NET MVC
PPT
(In)Security Implication in the JS Universe
PDF
Html5 localstorage attack vectors
PPTX
Preventing In-Browser Malicious Code Execution
MITM Attacks on HTTPS: Another Perspective
Web Application Security in front end
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
Its all about CSRF - null Mumbai Meet 10 January 2015 Null/OWASP Chapter
Grey H@t - Cross-site Request Forgery
Application Security for RIAs
Owasp eee 2015 csrf
Reflective and Stored XSS- Cross Site Scripting
Java script, security and you - Tri-Cities Javascript Developers Group
DEfcon15 XXE XXS
Linkedin.com DomXss 04-08-2014
Web application security
Xss (cross site scripting)
Owasp Top 10 A3: Cross Site Scripting (XSS)
Top Ten Web Hacking Techniques (2008)
Understanding Cross-site Request Forgery
CSRF Attack and Its Prevention technique in ASP.NET MVC
(In)Security Implication in the JS Universe
Html5 localstorage attack vectors
Preventing In-Browser Malicious Code Execution
Ad

Viewers also liked (18)

PDF
JL Mealer's Emergency Sessions of the 115th Congress Anti Gov't Fraud Bill.
PDF
C# application integration
PPTX
Presentación1elsy
DOCX
nik cv
PDF
CADZINE n° 1, giugno 2014, ANNO I
PPTX
Adab adab mkn
PPT
De la subversión a la inclusión: movimientos de mujeres de la segunda ola en ...
DOC
ABUBACKER SIDDIQ CV
PDF
reinvestment allowance 2008-inland revenue
PPTX
Nutrición y riesgo cardiovascular
PDF
Endolls de 220v adaptats
PPS
Llave de oro
PPTX
E portafolio Nataly Ruiz Grupo 201512_190
PDF
Content Marketing BeautyfulDays Mai 2016
PDF
Oktoberfeststammtisch münchen 2012
PDF
6 Schritte, damit sich Kunden in Dein Produkt verlieben
JL Mealer's Emergency Sessions of the 115th Congress Anti Gov't Fraud Bill.
C# application integration
Presentación1elsy
nik cv
CADZINE n° 1, giugno 2014, ANNO I
Adab adab mkn
De la subversión a la inclusión: movimientos de mujeres de la segunda ola en ...
ABUBACKER SIDDIQ CV
reinvestment allowance 2008-inland revenue
Nutrición y riesgo cardiovascular
Endolls de 220v adaptats
Llave de oro
E portafolio Nataly Ruiz Grupo 201512_190
Content Marketing BeautyfulDays Mai 2016
Oktoberfeststammtisch münchen 2012
6 Schritte, damit sich Kunden in Dein Produkt verlieben
Ad

Similar to Client sidesec 2013 - script injection (20)

PPTX
A Survey of Exploitation and Detection Methods of XSS Vulnerabilities.pptx
PPTX
Deep understanding on Cross-Site Scripting and SQL Injection
PPTX
Cross Site Scripting
PPTX
Secure Code Warrior - Cross site scripting
PPT
4.Xss
PPTX
XSS: From alert(1) to crypto mining malware
PDF
Xss 101 by-sai-shanthan
DOCX
Continuing in your role as a human service provider for your local.docx
PDF
XSS Exploitation
PPTX
Xss attack
PPTX
Cross Site Scripting ( XSS)
PPTX
PPT
144205230-Cross-Site-Scripting-XSS-ppt.ppt
PPTX
Cross Site Scripting Defense Presentation
PPTX
Cross Site Scripting(XSS)
PDF
SeanRobertsThesis
PDF
xss-100908063522-phpapp02.pdf
PPTX
15 owasp top 10 - a3-xss
PPTX
Understanding dom based xss
A Survey of Exploitation and Detection Methods of XSS Vulnerabilities.pptx
Deep understanding on Cross-Site Scripting and SQL Injection
Cross Site Scripting
Secure Code Warrior - Cross site scripting
4.Xss
XSS: From alert(1) to crypto mining malware
Xss 101 by-sai-shanthan
Continuing in your role as a human service provider for your local.docx
XSS Exploitation
Xss attack
Cross Site Scripting ( XSS)
144205230-Cross-Site-Scripting-XSS-ppt.ppt
Cross Site Scripting Defense Presentation
Cross Site Scripting(XSS)
SeanRobertsThesis
xss-100908063522-phpapp02.pdf
15 owasp top 10 - a3-xss
Understanding dom based xss

More from Tal Be'ery (15)

PPTX
2 Become One, 1 Becomes Two: Attacking and Protecting 2FA Tokens
PDF
Give me some (key) space!
PPTX
Web3’s red pill: Smashing Web3 transaction simulations for fun and profit
PDF
Understanding Compound‘s Liquidation
PDF
Web3 Security: The Blockchain is Your SIEM
PPTX
The Color of Money
PDF
Open Sesame: Picking Locks with Cortana
PPTX
THE VOICE OF ESAU: HACKING ENTERPRISES THROUGH VOICE INTERFACES
PDF
Automate or Die: How Automation Reshapes Cybersecurity
PDF
The Industrial Revolution of Lateral Movement
PPTX
The Enemy Within: Stopping Advanced Attacks Against Local Users
PDF
Target Breach Analysis
PPTX
Battlefield network
PPTX
One Key to Rule Them All: Detecting the Skeleton Key Malware
PPTX
Skeleton key malware detection owasp
2 Become One, 1 Becomes Two: Attacking and Protecting 2FA Tokens
Give me some (key) space!
Web3’s red pill: Smashing Web3 transaction simulations for fun and profit
Understanding Compound‘s Liquidation
Web3 Security: The Blockchain is Your SIEM
The Color of Money
Open Sesame: Picking Locks with Cortana
THE VOICE OF ESAU: HACKING ENTERPRISES THROUGH VOICE INTERFACES
Automate or Die: How Automation Reshapes Cybersecurity
The Industrial Revolution of Lateral Movement
The Enemy Within: Stopping Advanced Attacks Against Local Users
Target Breach Analysis
Battlefield network
One Key to Rule Them All: Detecting the Skeleton Key Malware
Skeleton key malware detection owasp

Recently uploaded (20)

PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PDF
Paper PDF World Game (s) Great Redesign.pdf
PPTX
innovation process that make everything different.pptx
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PPT
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
PPTX
presentation_pfe-universite-molay-seltan.pptx
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PPTX
SAP Ariba Sourcing PPT for learning material
PPTX
Digital Literacy And Online Safety on internet
PDF
Testing WebRTC applications at scale.pdf
PDF
SASE Traffic Flow - ZTNA Connector-1.pdf
PPTX
Power Point - Lesson 3_2.pptx grad school presentation
PDF
Introduction to the IoT system, how the IoT system works
PDF
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
Decoding a Decade: 10 Years of Applied CTI Discipline
Tenda Login Guide: Access Your Router in 5 Easy Steps
522797556-Unit-2-Temperature-measurement-1-1.pptx
Paper PDF World Game (s) Great Redesign.pdf
innovation process that make everything different.pptx
Introuction about WHO-FIC in ICD-10.pptx
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
presentation_pfe-universite-molay-seltan.pptx
An introduction to the IFRS (ISSB) Stndards.pdf
The New Creative Director: How AI Tools for Social Media Content Creation Are...
Unit-1 introduction to cyber security discuss about how to secure a system
SAP Ariba Sourcing PPT for learning material
Digital Literacy And Online Safety on internet
Testing WebRTC applications at scale.pdf
SASE Traffic Flow - ZTNA Connector-1.pdf
Power Point - Lesson 3_2.pptx grad school presentation
Introduction to the IoT system, how the IoT system works
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
Introduction about ICD -10 and ICD11 on 5.8.25.pptx

Client sidesec 2013 - script injection

  • 1. Web Client Side Security - Script Injection Tal Be’ery @Verint 2013
  • 2. SOP Threat Model Communicati on Custom Code Accounts Finance Administratio n Transactions Knowledge Mgmt E-Commerce Bus. Functions Victim Application 3 Vulnerable site sees legitimate request from victim performs the action requested And sends a response Attacker sets the trap on some website on the internet1 2 While logged into vulnerable site, victim views attacker site Victim site interaction Some interaction with victim site
  • 3. Injecting Script to Defeat SOP O So SOP does not allow scripts from a different origin to access target origin’s data? O Then, attacker must get the script to run from target’s origin!
  • 4. Getting The Script In O Malvertising: Paying the server to show content (Malicious Ads) O XSS :Abusing the application’s to serve user content O Breaking into the server to change content O Mass injection O Watering Hole attacks O Injecting onto the connection (MitM)
  • 6. Paying the target site O Paying the target site to serve attacker controlled messages to its clients O Paying for displaying content = advertising
  • 7. Online advertising O The business engine for the web http://blogs-images.forbes.com/roberthof/files/2012/06/iabadrev.gif
  • 8. Online advertising O Many parties are involved http://blogs.wsj.com/digits/2011/06/06/online-ads-where-1240-companies-fit-in/
  • 9. Malvertising O Malware advertising O Usually in the context of malware spreading O If it allows scripting, can create XSS http://2.bp.blogspot.com/-qyWHGQxwkPc/Tl0dNR-1g1I/AAAAAAAACdg/wsYFRVfM3NQ/s1600/malvertising%2Byieldmanager%2Bziddu%2Bwebsite.png
  • 10. Targeting Ads O Web ads can be highly targeted O “C level” in “Israel” in the “security industry”
  • 12. XSS = Script Injection O Victim server embeds unsanitized user’s Input in served content O Served content can contain a script invocation O The script is from the origin of the victim server and thus can access all of the origin’s data
  • 13. Stored XSS O The victim server stores user generated content O Comments O Profile in social network O Reviews O The content is displayed to other users O If not properly sanitized the content can contain a script
  • 14. Stored XSS Illustrated Attacker sets the trap – update my profile Attacker enters a malicious script into a web page that stores the data on the server 1 Application with stored XSS vulnerability Custom Code Accounts Finance Administratio nTransactions Communicati onKnowledge MgmtE-CommerceBus. Functions 2 Victim views page – sees attacker profile Script runs inside victim’s browser with full access to the DOM and cookies 3 Script silently sends attacker Victim’s session cookie 1
  • 15. Reflected XSS O The victim sends back (reflects) user generated content to the user O “search results for <sent term>” O “The form details you just filled <form data>” O The content is displayed to the user O If not properly sanitized the content can invoke a script
  • 16. Reflected XSS O Why should I attack myself? O The attacker “convinces” the victim to attack itself O Link is embedded in attacker site O Phishing email
  • 18. Reflected XSS Demo - testing O Search page is a classic! O /sitesearch/index.aspx?q=bbbbbbbbbbbb
  • 19. Reflected XSS Demo – XSS! O /index.aspx?q=<script> alert( document.cookie); </script>
  • 20. DOM Based XSS O Javascript can change inner HTML through the DOM O If the script in victim server’s page accepts input from user without sanitizing it and changes the DOM than a script can be invoked.
  • 21. Javascript Invocation O Direct Script Injection O Event handler injection O Javascript protocol injection O Injecting into an existing script
  • 22. Injection O Injection happens when attacker is able to make a cross over from data area to control/code area O All Injections (Script injections, but also SQL injection, XML injection, LDAP injection, etc.) share the same characteristics: O A token that ends the data part O Some malicious code O A token that returns to data part (optional)
  • 23. Direct Script Injection O <script>alert(1)</script> O HTML parsers are usually very relaxed and forgiving
  • 24. Event handler injection O Example: O Original application: O <img src="url" alt="some_user_text"> O Attacker: O <img src="url" alt="” onload=“evil()">
  • 25. Javascript protocol injection O Injecting the javascript pseudo protocol in places intended for URLs O Original application: O <iframe src="user supplied url" > O Attacker: O <iframe src=“Javascript:evil()" >
  • 26. Injecting into an existing script O Input is embedded into existing script. O Script must remain syntactically correct for the malicious payload to execute
  • 27. Injecting Into an Existing Script – In the Wild O The value of the locale HTTP parameter is included directly in a javascript within the response and assigned to the s_prop18 variable: O <script>…var s_prop18="";alert(1);//“ … </script>
  • 29. Vulnerability Scanners O Many commercial tools O IBM AppScan O HP WebInspect O Etc. O Many free tools
  • 30. Exploitation tools: BeEF O The Browser Exploitation Framework
  • 33. Input/Output Sanitizaiton O Remove “bad” characters O Encode “bad” characters O Context dependent! O When input is given the code does not know in which context it would be displayed O When output is presented, the context is known, but coder may forget its untrusted origin
  • 34. Too many contexts… HTML Style Property Values (e.g., .pdiv a:hover {color: red; text- decoration: underline} ) JavaScript Data (e.g., <script> some javascript </script> ) HTML Attribute Values (e.g., <input name='person' type='TEXT' value='defaultValue'> ) HTML Element Content (e.g., <div> some text to display </div> ) URI Attribute Values (e.g., <a href="javascript:toggle('lesson')" ) #4: All non-alphanumeric < 256  HH ESAPI: encodeForCSS() #3: All non-alphanumeric < 256  xHH ESAPI: encodeForJavaScript() #1: ( &, <, >, " )  &entity; ( ', / )  &#xHH; ESAPI: encodeForHTML() #2: All non-alphanumeric < 256  &#xHH ESAPI: encodeForHTMLAttribute() #5: All non-alphanumeric < 256  %HH ESAPI: encodeForURL()
  • 35. CSP O Content Security Policy O Enables the website to specify with custom headers the allowed scripts in the page, so no new script can be injected O In order for CSP to be effective, the website code has to be refactored.
  • 36. NoScript O Client side plugin O Stops scripts, but usually kills user experience too
  • 37. Web Application Firewalls O Stop XSS vectors O Both reflected and persistent O Examples: O Imperva SecureSphere O ModSecurity
  • 38. Browser XSS filter O Checks for script invocation in user supplied data O Only effective against reflected XSS
  • 39. XSS in the wild
  • 44. Watering Hole O Waiting for the victim to come to the attacker http://tpzoo.files.wordpress.com/2013/02/lion-zebra-water-hole.jpg
  • 45. Watering Hole Attack O Break into a website O Plant a malicious script in it http://eromang.zataz.com/2013/02/20/facebook-apple-twitter-watering-hole-attack-additional-informations/
  • 46. MITM
  • 47. MITM
  • 48. MITM Can Inject Scripts O The victim requests “good.com” O The attacker serves arbitrary content as a response O Scripts served that way, are considered by the browser as coming from “good.com” context
  • 49. Attacker Don’t Have to Be MITM O Full MITM capabilities are not needed O “Man on the Side” is enough O It’s enough to be able: O Eavesdrop for requests O Be able to inject false responses O No need to stop messages
  • 50. The NSA Did It! O QUANTUM program O “..NSA relies on its secret partnerships with US telecoms companies… the NSA places secret servers, codenamed Quantum, at key places on the Internet backbone. This placement ensures that they can react faster than other websites can. By exploiting that speed difference, these servers can impersonate a visited website to the target before the legitimate website can respond.. https://www.schneier.com/blog/archives/2013/10 /how_the_nsa_att.html
  • 51. Web Client Side Security - Implementation Bugs
  • 52. Bugs In SOP O 2004: Malicious redirects break IE’s SOP implementation
  • 53. Universal XSS O Browser is not just the browser O Addons, extensions, plugins… O Some of them may have bugs in SOP
  • 54. Adobe PDF Universal XSS O Adobe PDF Reader universal XSS O http://host/file.pdf#anyname=javascript:yo ur_code_here O If a site hosts a PDF it has XSS vulnerability https://www.owasp.org/images/4/4b/OWASP_IL_The_Universal_XSS_PDF_Vulnerability.pdf
  • 57. Exploit Delivery O Introduced with a script O One of the Aforementioned Script Injection techniques O Checks for browser vendor, version and installed component to use the right exploit O Creates the exploited object

Editor's Notes

  • #8: http://blogs-images.forbes.com/roberthof/files/2012/06/iabadrev.gif
  • #9: http://blogs.wsj.com/digits/2011/06/06/online-ads-where-1240-companies-fit-in/
  • #10: http://2.bp.blogspot.com/-qyWHGQxwkPc/Tl0dNR-1g1I/AAAAAAAACdg/wsYFRVfM3NQ/s1600/malvertising%2Byieldmanager%2Bziddu%2Bwebsite.png
  • #26: http://www.w3schools.com/tags/ref_eventattributes.asp
  • #28: http://www.xssed.com/mirror/62826/
  • #32: http://192.168.43.130:3000/demos/butcher/index.html http://192.168.43.130:3000/ui/authentication
  • #42: https://www.whitehatsec.com/assets/WPstatsReport_052013.pdf
  • #43: http://www.acunetix.com/blog/web-security-zone/articles/xss-vulnerability-injected-google-analytics-executed-ioss-gmail-application/
  • #46: http://eromang.zataz.com/2013/02/20/facebook-apple-twitter-watering-hole-attack-additional-informations/
  • #53: https://www.kb.cert.org/vuls/id/713878