SlideShare una empresa de Scribd logo
1 de 101
Descargar para leer sin conexión
CNIT 129S: Securing
Web Applications
Ch 12: Attacking Users
:

Cross-Site Scripting (XSS
)

Part 1
Updated 4-22-2021
Attacking Clients
• Vulnerabilities in browser
s

• May result in session hijacking,
unauthorized actions, and disclosure of
personal data, keylogging, remote code
executio
n

• XSS is the most prevalent web
application vulnerability in the world
Varieties of XSS
• Re
fl
ected XS
S

• Stored XS
S

• DOM-Based XSS
Re
fl
ected XSS
• Example: an error message that takes text from
user and displays it back to the user in its
respons
e

• 75% of all XSS vulnerabilities are this type
URL with data
Re
fl
ected XSS
R
e
q
u
e
s
t
w
i
t
h
d
a
t
a
R
e
s
p
o
n
s
e
Cod
e

Execution
Persistent Cookies
• If user has a persistent cookie, implementing
"remember me
"

• Step 1 is not neede
d

• User need not be currently logged in
Same-Origin Policy
• evil.com cannot get your target.com cookies
from your browse
r

• Only a page in the same domain (target.com
)

• But XSS lets the attacker add scripting to a page
that comes from target.co
m

• Hence the name Cross-Site Scripting
Stored XSS Vulnerabilities
• A message is store
d

• Executed on any user who views i
t

• May attack a large number of users
D
a
t
a
Stored XSS
R
e
q
u
e
s
t
R
e
s
p
o
n
s
e
Cod
e

Execution
DOM-Based XSS
DOM-Based XSS
Request
Response with data
Data stored
on pag
e

used
elsewhere
on pag
e

Code
Execution
The Vulnerability
• Client-side JavaScript can access the browser's
Document Object Mode
l

• Can determine the URL used to load the current
pag
e

• A script the developer put there may extract
data from the URL and display it, dynamically
updating the page's contents
Example: Dynamically
Generated Error Message
• Writes message to pag
e

• Can also write script to page
12a
Real-World XSS Attacks
Apache (2010)
• XSS in issue-tracking application
 

• Attacker injected code, obscured it with a URL
shortene
r

• Administrator clicked the lin
k

• Attacker stole the administrator's cooki
e

• Attacker altered the upload folder for the project
and placed a Trojan login form there
Apache (2010)
• Attacker captured usernames and passwords
for Apache privileged user
s

• Found passwords that were re-used on other
systems within the infrastructur
e

• Fully compromised those systems, escalating
the attack beyond the vulnerable Web
applicatio
n

• Link Ch 12a
MySpace (2005)
• Samy evaded
fi
lters intended to block
XS
S

• Added JavaScript to his user pro
fi
le, that
made every viewe
r

• Add Samy as a frien
d

• Copied the script to the user's pro
fi
l
e

• Gained over 1 million friends within hours
 

• Link Ch 12b
• Stored XSS in email allowed attackers to send a
malicious email to the CE
O

• Stealing his session cookie
Twitter (2009)
• Link Ch 12d
Other Payloads for XSS
• Virtual Defacemen
t

• Add images, code, or other content to a page
Injecting Trojan Functionality
• Inject actual working functionality into the
vulnerable applicatio
n

• Such as a fake login form to capture credential
s

• Or the fake Google purchase form on the next
slide, from 2004
Disadvantages of Session
Hijacking
• Attacker must monitor her server and collect
cookie
s

• Then carry out actions on behalf of target user
s

• Labor-intensiv
e

• Leaves traces in server logs
Inducing User Actions
• Use attack payload script to carry out actions
directl
y

• MySpace XSS worm did thi
s

• If the goal is to perform an administrative
action, each user can be forced to try it until an
administrator is compromised
Exploiting Trust Relationships
• Browsers trust JavaScript with cookies from the
same websit
e

• Autocomplete in the browser can
fi
ll in
fi
elds,
which are then read by JavaScrip
t

• Some sites require being added to Internet
Explorer's "Trusted Sites"; those sites can run
arbitrary code like this
Exploiting Trust Relationships
• ActiveX controls often contain powerful
method
s

• They may check to see that requests came
from the expected sit
e

• With XSS, that condition is satis
fi
ed
Escalating the Client-Side
Attack
• Website may attack users b
y

• Logging keystroke
s

• Capturing browsing histor
y

• Port-scanning the local network
12b
Delivery Mechanisms for
XSS Attacks
Delivering Re
fl
ected and
DOM-Based XSS Attacks
• Phishing email containing a crafted UR
L

• Targeted attack with custom emai
l

• Instant message containing a UR
L

• Code posted on websites that allow user to post
HTML
Watering Hole Attack
• Attacker creates a website with content that will
interest the target user
s

• Use search engine optimization to attract
viewer
s

• Page contains content that causes the user's
browser to make requests containing XSS
payloads to the vulnerable application
• Purchase ad space, put malicious URL in the a
d

• The ad may appear in pages about the app
you are attacking, because of keyword
matche
s

• Web apps often have "tell a friend" or "send
feedback" feature
s

• Leverage this to deliver an XSS attack via an
email that originates from the organization's
server
Delivering Re
fl
ected and
DOM-Based XSS Attacks
Delivering Stored XSS
Attacks
• In-band (most common)
Delivering Stored XSS
Attacks
• Out-of-ban
d

• Anything other than viewing the target ap
p

• Such as email from its server
Chaining XSS
• XSS vulnerability itself may be low-ris
k

• But chaining it together with other
vulnerabilities can cause serious compromise
Example
• XSS allows script to be inserted into user's
displayed nam
e

• Access control
fl
aw lets attacker change other
users' name
s

• Add token-stealing XSS to every usernam
e

• Gain administrator credentials: total control of
application
Finding and Exploiting XSS
Vunerabilities
Basic Approach
• Inject this string into every parameter on every
page of the applicatio
n

• If the attack string appears unmodi
fi
ed in the
response, that indicates an XSS vulnerabilit
y

• This is the fastest way to
fi
nd an XSS, but it
won't
fi
nd them all
When the Simple Attack
Fails
• Applications with rudimentary blacklist-based
fi
lter
s

• Remove <script>, or < > "
/

• Crafted attacks may still work
Response Different from
Input
• XSS attacks that don't simply return the attack
strin
g

• Sometimes input string is sanitized, decoded,
or otherwise modi
fi
e
d

• In DOM-based XSS, the input string isn't
necessarily returned in the browser's
immediate response, but is retained in the
DOM and accessed via client-side JavaScript
Finding and Exploiting
Re
fl
ected XSS Vulnerabilities
Identifying Re
fl
ections of
User Input
• Choose a unique string that doesn't appear
anyhere in the application and includes only
alphabetical characters that won't be
fi
ltered,
like "myxsstestdmqlwp
"

• Submit it as every parameter, one at a time,
including GET, POST, query string, and headers
such as User-Agen
t

• Monitor responses for any appearance of the
string
Testing Re
fl
ections to
Introduce Script
• Manually test each instance of re
fl
ected input to
see if it's exploitabl
e

• You'll have to customize the attack for each
situation
Demos (Use Firefox)
Demo 5. A Tag Attribute
Value
• Here are two ways to exploit it
Demo 6. A JavaScript String
• This attack works
Demo 7. An Attribute Containing
a URL
• Use the javascript: handler to make your script
into a UR
L

• Or use the onclick event handler
Probing Defensive Filters
• Three common types
Beating Signature-Based
Filters
• You may see an error message like this
Remove Parts of the String
• Until the error goes awa
y

• Find the substring that triggered the error,
usually something like <script
>

• Test bypass methods
Ways to Introduce Script
Code
Script Tags
• If <script> is blocked, try these
Event Handlers
• All these run without user interaction
Event Handlers in HTML 5
• Autofocu
s

• In closing tag
s

• New tags
Script Pseudo-Protocols
• Used where a URL is expecte
d

• IE allows the vbs: protoco
l

• HTML 5 provides these new ways:
Dynamically Evaluated
Styles
• IE 7 and earlier allowed this
:

• Later IE versions allow this:
Bypassing Filters: HTML
• Ways to obfuscate this attack
Inserted NULL Butes
• Causes C code to terminate the strin
g

• Will bypass many
fi
lter
s

• IE allows NULL bytes anywher
e

• Web App Firewalls (WAFs) are typically coded in
C for performance and this trick fools them
Invalid Tags
• Browser will let it ru
n

• Filter may not see it due to invalid tag "x"
Base Tag Hijacking
• Set <base> and later relative-path URLs will be
resolved relative to it
Space Following the Tag Name
• Replace the space with other character
s

• Add extra characters when there's no space
NULL Byte in Attribute
Name
• Attribute delimiter
s

• Backtick works in IE
Attribute Delimiters
• If
fi
lter is unaware that backticks work as attribute
delimiters, it treats this as a single attribute, not
realizing that the "onerror" will execut
e

• Attack with no spaces
Attribute Values
• Insert NULL, or HTML-encode characters
HTML Encoding
• Can use decimal and hexadecimal format, add
leading zeroes, omit trailing semicolo
n

• Some browsers will accept these
Tag Brackets
• Some applications perform URL decoding twice,
so this inpu
t

• becomes this, which has no < or
>

• and it's then decoded to this
• Some app frameworks translate unusual
Unicode characters into their nearest ASCII
equivalents, so double-angle quotation marks
%u00AB and %u00BB work:
Tag Brackets
• Browsers tolerate extra bracket
s

• This strange format is accepted by Firefox,
despite not having a valid <script> tag
Tag Brackets
Web Developer Add-on
• View Generated Source shows HTML after
Firefox has tried to "
fi
x" the code
Character Sets
Telling Browser the
Character Set
• Set it in the HTTP Content-Type heade
r

• Or an HTTP META ta
g

• Or a CHARSET parameter, if one is used
Shift-JIS
• A 16-byte encoding scheme developed for Japanese
character
s

• Suppose two pieces of input are used in the app's
respons
e

• input1 blocks quotes, input2 blocks < and
>

• This attack works, because %f0 starts a two-byte
character, breaking the quotation mark
Bypassing Filters: Script
Code
JavaScript Escaping
• Unicod
e

• Eva
l

• Super
fl
uous escape characters
AtoB
• Link Ch 12i
Dynamically Constructing
Strings
• Third example works in Firefo
x

• And in other browsers too, according to link Ch
12f
Alternatives
• Alternatives to eva
l

• Alternatives to dots
Combining Multiple
Techniques
• The "e" in "alert" uses Unicode escaping:
u006
5

• The backslash is URL-encoded: &#x5c
;

• With more HTML-encoding
VBScript
• Skip this sectio
n

• Microsoft abandoned VBScript with Edg
e

• Link Ch 12g
Beating Sanitization
• Encoding certain character
s

• < becomes &lt
;

• > becomes &gt
;

• Test to see what characters are sanitize
d

• Try to make an attack string without those
characters
Examples
• Your injection may already be in a script, so you
don't need <script> ta
g

• Sneak in <script> using layers of encoding, null
bytes, nonstandard syntax, or obfuscated script
code
Mistakes in Sanitizing Code
• Not removing all instance
s

• Not acting recursively
Stages of Encoding
• Filter
fi
rst strips <script> recursivel
y

• Then strips <object> recursivel
y

• This attack succeeds
Injecting into an Event
Handler
• You control fo
o

• This attack strin
g

• Turns into this, and executes in some browsers
Beating Length Limits


1. Short Attacks
• This sends cookies to server with hostname
a

• This tag executes a script from the server with
hostname a
JavaScript Packer
• Link Ch 12h
• Use multiple injection points
 

• Inject part of the code in each poin
t

• Consider this URL
Beating Length Limits


2. Span Multiple Locations
• It returns three hidden
fi
eld
s

• Inject this way
Beating Length Limits


2. Span Multiple Locations
• Result
Beating Length Limits


2. Span Multiple Locations
• Inject this JavaScript, which evaluates the
fragment string from the UR
L

• The part after #
Beating Length Limits


3. Convert Re
fl
ected XSS to DOM
• First attack works in a straightforward manne
r

• Second one works because http: is interpreted
as a code label, // as a comment, and %0A
terminates the comment
Beating Length Limits


3. Convert Re
fl
ected XSS to DOM
10c

Más contenido relacionado

La actualidad más candente

CNIT 152: 1 Real-World Incidents
CNIT 152: 1 Real-World IncidentsCNIT 152: 1 Real-World Incidents
CNIT 152: 1 Real-World IncidentsSam Bowne
 
CNIT 128: Android Implementation Issues (Part 2)
CNIT 128: Android Implementation Issues (Part 2)CNIT 128: Android Implementation Issues (Part 2)
CNIT 128: Android Implementation Issues (Part 2)Sam Bowne
 
CNIT 128 3. Attacking iOS Applications (Part 1)
CNIT 128 3. Attacking iOS Applications (Part 1)CNIT 128 3. Attacking iOS Applications (Part 1)
CNIT 128 3. Attacking iOS Applications (Part 1)Sam Bowne
 
CNIT 129S Ch 7: Attacking Session Management
CNIT 129S Ch 7: Attacking Session ManagementCNIT 129S Ch 7: Attacking Session Management
CNIT 129S Ch 7: Attacking Session ManagementSam Bowne
 
CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 7. Attacking Android Applications (Part 2)CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 7. Attacking Android Applications (Part 2)Sam Bowne
 
Ch 6: Attacking Authentication
Ch 6: Attacking AuthenticationCh 6: Attacking Authentication
Ch 6: Attacking AuthenticationSam Bowne
 
CNIT 128 8. Android Implementation Issues (Part 2)
CNIT 128 8. Android Implementation Issues (Part 2)CNIT 128 8. Android Implementation Issues (Part 2)
CNIT 128 8. Android Implementation Issues (Part 2)Sam Bowne
 
Ch 10: Hacking Web Servers
Ch 10: Hacking Web ServersCh 10: Hacking Web Servers
Ch 10: Hacking Web ServersSam Bowne
 
CNIT 128 7. Attacking Android Applications (Part 1)
CNIT 128 7. Attacking Android Applications (Part 1)CNIT 128 7. Attacking Android Applications (Part 1)
CNIT 128 7. Attacking Android Applications (Part 1)Sam Bowne
 
2012 S&P Paper Reading Session1
2012 S&P Paper Reading Session12012 S&P Paper Reading Session1
2012 S&P Paper Reading Session1Chong-Kuan Chen
 
The Dark Side of PowerShell by George Dobrea
The Dark Side of PowerShell by George DobreaThe Dark Side of PowerShell by George Dobrea
The Dark Side of PowerShell by George DobreaEC-Council
 
CNIT 128 6. Analyzing Android Applications (Part 2 of 3)
CNIT 128 6. Analyzing Android Applications (Part 2 of 3)CNIT 128 6. Analyzing Android Applications (Part 2 of 3)
CNIT 128 6. Analyzing Android Applications (Part 2 of 3)Sam Bowne
 
CNIT 128 6. Analyzing Android Applications (Part 3 of 3)
CNIT 128 6. Analyzing Android Applications (Part 3 of 3)CNIT 128 6. Analyzing Android Applications (Part 3 of 3)
CNIT 128 6. Analyzing Android Applications (Part 3 of 3)Sam Bowne
 
07182013 Hacking Appliances: Ironic exploits in security products
07182013 Hacking Appliances: Ironic exploits in security products07182013 Hacking Appliances: Ironic exploits in security products
07182013 Hacking Appliances: Ironic exploits in security productsNCC Group
 
CNIT 128 9. Writing Secure Android Applications
CNIT 128 9. Writing Secure Android ApplicationsCNIT 128 9. Writing Secure Android Applications
CNIT 128 9. Writing Secure Android ApplicationsSam Bowne
 
CNIT 124 Ch10-12: Local Exploits through Bypassing AV
CNIT 124 Ch10-12: Local Exploits through Bypassing AVCNIT 124 Ch10-12: Local Exploits through Bypassing AV
CNIT 124 Ch10-12: Local Exploits through Bypassing AVSam Bowne
 
CNIT 123 Ch 10: Hacking Web Servers
CNIT 123 Ch 10: Hacking Web ServersCNIT 123 Ch 10: Hacking Web Servers
CNIT 123 Ch 10: Hacking Web ServersSam Bowne
 
BSIDES-PR Keynote Hunting for Bad Guys
BSIDES-PR Keynote Hunting for Bad GuysBSIDES-PR Keynote Hunting for Bad Guys
BSIDES-PR Keynote Hunting for Bad GuysJoff Thyer
 
Sticky Keys to the Kingdom
Sticky Keys to the KingdomSticky Keys to the Kingdom
Sticky Keys to the KingdomDennis Maldonado
 

La actualidad más candente (20)

CNIT 152: 1 Real-World Incidents
CNIT 152: 1 Real-World IncidentsCNIT 152: 1 Real-World Incidents
CNIT 152: 1 Real-World Incidents
 
CNIT 128: Android Implementation Issues (Part 2)
CNIT 128: Android Implementation Issues (Part 2)CNIT 128: Android Implementation Issues (Part 2)
CNIT 128: Android Implementation Issues (Part 2)
 
CNIT 128 3. Attacking iOS Applications (Part 1)
CNIT 128 3. Attacking iOS Applications (Part 1)CNIT 128 3. Attacking iOS Applications (Part 1)
CNIT 128 3. Attacking iOS Applications (Part 1)
 
CNIT 129S Ch 7: Attacking Session Management
CNIT 129S Ch 7: Attacking Session ManagementCNIT 129S Ch 7: Attacking Session Management
CNIT 129S Ch 7: Attacking Session Management
 
CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 7. Attacking Android Applications (Part 2)CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 7. Attacking Android Applications (Part 2)
 
Ch 6: Attacking Authentication
Ch 6: Attacking AuthenticationCh 6: Attacking Authentication
Ch 6: Attacking Authentication
 
CNIT 128 8. Android Implementation Issues (Part 2)
CNIT 128 8. Android Implementation Issues (Part 2)CNIT 128 8. Android Implementation Issues (Part 2)
CNIT 128 8. Android Implementation Issues (Part 2)
 
Ch 10: Hacking Web Servers
Ch 10: Hacking Web ServersCh 10: Hacking Web Servers
Ch 10: Hacking Web Servers
 
CNIT 128 7. Attacking Android Applications (Part 1)
CNIT 128 7. Attacking Android Applications (Part 1)CNIT 128 7. Attacking Android Applications (Part 1)
CNIT 128 7. Attacking Android Applications (Part 1)
 
2012 S&P Paper Reading Session1
2012 S&P Paper Reading Session12012 S&P Paper Reading Session1
2012 S&P Paper Reading Session1
 
The Dark Side of PowerShell by George Dobrea
The Dark Side of PowerShell by George DobreaThe Dark Side of PowerShell by George Dobrea
The Dark Side of PowerShell by George Dobrea
 
CNIT 128 6. Analyzing Android Applications (Part 2 of 3)
CNIT 128 6. Analyzing Android Applications (Part 2 of 3)CNIT 128 6. Analyzing Android Applications (Part 2 of 3)
CNIT 128 6. Analyzing Android Applications (Part 2 of 3)
 
CNIT 128 6. Analyzing Android Applications (Part 3 of 3)
CNIT 128 6. Analyzing Android Applications (Part 3 of 3)CNIT 128 6. Analyzing Android Applications (Part 3 of 3)
CNIT 128 6. Analyzing Android Applications (Part 3 of 3)
 
07182013 Hacking Appliances: Ironic exploits in security products
07182013 Hacking Appliances: Ironic exploits in security products07182013 Hacking Appliances: Ironic exploits in security products
07182013 Hacking Appliances: Ironic exploits in security products
 
CNIT 128 9. Writing Secure Android Applications
CNIT 128 9. Writing Secure Android ApplicationsCNIT 128 9. Writing Secure Android Applications
CNIT 128 9. Writing Secure Android Applications
 
CNIT 124 Ch10-12: Local Exploits through Bypassing AV
CNIT 124 Ch10-12: Local Exploits through Bypassing AVCNIT 124 Ch10-12: Local Exploits through Bypassing AV
CNIT 124 Ch10-12: Local Exploits through Bypassing AV
 
Addios!
Addios!Addios!
Addios!
 
CNIT 123 Ch 10: Hacking Web Servers
CNIT 123 Ch 10: Hacking Web ServersCNIT 123 Ch 10: Hacking Web Servers
CNIT 123 Ch 10: Hacking Web Servers
 
BSIDES-PR Keynote Hunting for Bad Guys
BSIDES-PR Keynote Hunting for Bad GuysBSIDES-PR Keynote Hunting for Bad Guys
BSIDES-PR Keynote Hunting for Bad Guys
 
Sticky Keys to the Kingdom
Sticky Keys to the KingdomSticky Keys to the Kingdom
Sticky Keys to the Kingdom
 

Similar a CNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting

Ch 12 Attacking Users - XSS
Ch 12 Attacking Users - XSSCh 12 Attacking Users - XSS
Ch 12 Attacking Users - XSSSam Bowne
 
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)Sam Bowne
 
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)Sam Bowne
 
Django (Web Applications that are Secure by Default)
Django �(Web Applications that are Secure by Default�)Django �(Web Applications that are Secure by Default�)
Django (Web Applications that are Secure by Default)Kishor Kumar
 
Mr. Mohammed Aldoub - A case study of django web applications that are secur...
Mr. Mohammed Aldoub  - A case study of django web applications that are secur...Mr. Mohammed Aldoub  - A case study of django web applications that are secur...
Mr. Mohammed Aldoub - A case study of django web applications that are secur...nooralmousa
 
Workshop on Network Security
Workshop on Network SecurityWorkshop on Network Security
Workshop on Network SecurityUC San Diego
 
Case Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultCase Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultMohammed ALDOUB
 
Web application security part 01
Web application security part 01Web application security part 01
Web application security part 01G Prachi
 
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)Sam Bowne
 
Ch 13: Attacking Users: Other Techniques (Part 2)
Ch 13: Attacking Users: Other Techniques (Part 2)Ch 13: Attacking Users: Other Techniques (Part 2)
Ch 13: Attacking Users: Other Techniques (Part 2)Sam Bowne
 
www.webre24h.com - Ajax security
www.webre24h.com - Ajax securitywww.webre24h.com - Ajax security
www.webre24h.com - Ajax securitywebre24h
 
External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) Volkan Özçelik
 
Browser Security 101
Browser Security 101 Browser Security 101
Browser Security 101 Stormpath
 
Web Hacking Series Part 4
Web Hacking Series Part 4Web Hacking Series Part 4
Web Hacking Series Part 4Aditya Kamat
 
OWASP top 10-2013
OWASP top 10-2013OWASP top 10-2013
OWASP top 10-2013tmd800
 
Hacking sites for fun and profit
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profitDavid Stockton
 
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)Sam Bowne
 
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 a CNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting (20)

Ch 12 Attacking Users - XSS
Ch 12 Attacking Users - XSSCh 12 Attacking Users - XSS
Ch 12 Attacking Users - XSS
 
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
 
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)
 
Django (Web Applications that are Secure by Default)
Django �(Web Applications that are Secure by Default�)Django �(Web Applications that are Secure by Default�)
Django (Web Applications that are Secure by Default)
 
Mr. Mohammed Aldoub - A case study of django web applications that are secur...
Mr. Mohammed Aldoub  - A case study of django web applications that are secur...Mr. Mohammed Aldoub  - A case study of django web applications that are secur...
Mr. Mohammed Aldoub - A case study of django web applications that are secur...
 
Workshop on Network Security
Workshop on Network SecurityWorkshop on Network Security
Workshop on Network Security
 
Case Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultCase Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by Default
 
Web application security part 01
Web application security part 01Web application security part 01
Web application security part 01
 
Vulnerabilities in Web Applications
Vulnerabilities in Web ApplicationsVulnerabilities in Web Applications
Vulnerabilities in Web Applications
 
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
 
Cross site scripting XSS
Cross site scripting XSSCross site scripting XSS
Cross site scripting XSS
 
Ch 13: Attacking Users: Other Techniques (Part 2)
Ch 13: Attacking Users: Other Techniques (Part 2)Ch 13: Attacking Users: Other Techniques (Part 2)
Ch 13: Attacking Users: Other Techniques (Part 2)
 
www.webre24h.com - Ajax security
www.webre24h.com - Ajax securitywww.webre24h.com - Ajax security
www.webre24h.com - Ajax security
 
External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1)
 
Browser Security 101
Browser Security 101 Browser Security 101
Browser Security 101
 
Web Hacking Series Part 4
Web Hacking Series Part 4Web Hacking Series Part 4
Web Hacking Series Part 4
 
OWASP top 10-2013
OWASP top 10-2013OWASP top 10-2013
OWASP top 10-2013
 
Hacking sites for fun and profit
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profit
 
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
 
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)
 

Más de Sam Bowne

3: DNS vulnerabilities
3: DNS vulnerabilities 3: DNS vulnerabilities
3: DNS vulnerabilities Sam Bowne
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development SecuritySam Bowne
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the ApplicationSam Bowne
 
3. Attacking iOS Applications (Part 2)
 3. Attacking iOS Applications (Part 2) 3. Attacking iOS Applications (Part 2)
3. Attacking iOS Applications (Part 2)Sam Bowne
 
12 Elliptic Curves
12 Elliptic Curves12 Elliptic Curves
12 Elliptic CurvesSam Bowne
 
11. Diffie-Hellman
11. Diffie-Hellman11. Diffie-Hellman
11. Diffie-HellmanSam Bowne
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1Sam Bowne
 
9 Writing Secure Android Applications
9 Writing Secure Android Applications9 Writing Secure Android Applications
9 Writing Secure Android ApplicationsSam Bowne
 
12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)Sam Bowne
 
12 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 312 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 3Sam Bowne
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard ProblemsSam Bowne
 
8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)Sam Bowne
 
11 Analysis Methodology
11 Analysis Methodology11 Analysis Methodology
11 Analysis MethodologySam Bowne
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated EncryptionSam Bowne
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)Sam Bowne
 
7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)Sam Bowne
 
5. Stream Ciphers
5. Stream Ciphers5. Stream Ciphers
5. Stream CiphersSam Bowne
 
6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data CollectionSam Bowne
 

Más de Sam Bowne (20)

Cyberwar
CyberwarCyberwar
Cyberwar
 
3: DNS vulnerabilities
3: DNS vulnerabilities 3: DNS vulnerabilities
3: DNS vulnerabilities
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the Application
 
3. Attacking iOS Applications (Part 2)
 3. Attacking iOS Applications (Part 2) 3. Attacking iOS Applications (Part 2)
3. Attacking iOS Applications (Part 2)
 
12 Elliptic Curves
12 Elliptic Curves12 Elliptic Curves
12 Elliptic Curves
 
11. Diffie-Hellman
11. Diffie-Hellman11. Diffie-Hellman
11. Diffie-Hellman
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1
 
9 Writing Secure Android Applications
9 Writing Secure Android Applications9 Writing Secure Android Applications
9 Writing Secure Android Applications
 
12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)
 
10 RSA
10 RSA10 RSA
10 RSA
 
12 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 312 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 3
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard Problems
 
8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)
 
11 Analysis Methodology
11 Analysis Methodology11 Analysis Methodology
11 Analysis Methodology
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated Encryption
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)
 
7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)
 
5. Stream Ciphers
5. Stream Ciphers5. Stream Ciphers
5. Stream Ciphers
 
6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection
 

Último

How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleCeline George
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...DhatriParmar
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsPooky Knightsmith
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 

Último (20)

How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP Module
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young minds
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 

CNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting

  • 1. CNIT 129S: Securing Web Applications Ch 12: Attacking Users : Cross-Site Scripting (XSS ) Part 1 Updated 4-22-2021
  • 2. Attacking Clients • Vulnerabilities in browser s • May result in session hijacking, unauthorized actions, and disclosure of personal data, keylogging, remote code executio n • XSS is the most prevalent web application vulnerability in the world
  • 3. Varieties of XSS • Re fl ected XS S • Stored XS S • DOM-Based XSS
  • 4. Re fl ected XSS • Example: an error message that takes text from user and displays it back to the user in its respons e • 75% of all XSS vulnerabilities are this type
  • 5.
  • 6. URL with data Re fl ected XSS R e q u e s t w i t h d a t a R e s p o n s e Cod e Execution
  • 7.
  • 8.
  • 9. Persistent Cookies • If user has a persistent cookie, implementing "remember me " • Step 1 is not neede d • User need not be currently logged in
  • 10. Same-Origin Policy • evil.com cannot get your target.com cookies from your browse r • Only a page in the same domain (target.com ) • But XSS lets the attacker add scripting to a page that comes from target.co m • Hence the name Cross-Site Scripting
  • 11. Stored XSS Vulnerabilities • A message is store d • Executed on any user who views i t • May attack a large number of users
  • 12.
  • 15. DOM-Based XSS Request Response with data Data stored on pag e used elsewhere on pag e Code Execution
  • 16. The Vulnerability • Client-side JavaScript can access the browser's Document Object Mode l • Can determine the URL used to load the current pag e • A script the developer put there may extract data from the URL and display it, dynamically updating the page's contents
  • 17. Example: Dynamically Generated Error Message • Writes message to pag e • Can also write script to page
  • 18.
  • 19. 12a
  • 21. Apache (2010) • XSS in issue-tracking application • Attacker injected code, obscured it with a URL shortene r • Administrator clicked the lin k • Attacker stole the administrator's cooki e • Attacker altered the upload folder for the project and placed a Trojan login form there
  • 22. Apache (2010) • Attacker captured usernames and passwords for Apache privileged user s • Found passwords that were re-used on other systems within the infrastructur e • Fully compromised those systems, escalating the attack beyond the vulnerable Web applicatio n • Link Ch 12a
  • 23. MySpace (2005) • Samy evaded fi lters intended to block XS S • Added JavaScript to his user pro fi le, that made every viewe r • Add Samy as a frien d • Copied the script to the user's pro fi l e • Gained over 1 million friends within hours • Link Ch 12b
  • 24. • Stored XSS in email allowed attackers to send a malicious email to the CE O • Stealing his session cookie
  • 26. Other Payloads for XSS • Virtual Defacemen t • Add images, code, or other content to a page
  • 27.
  • 28. Injecting Trojan Functionality • Inject actual working functionality into the vulnerable applicatio n • Such as a fake login form to capture credential s • Or the fake Google purchase form on the next slide, from 2004
  • 29.
  • 30. Disadvantages of Session Hijacking • Attacker must monitor her server and collect cookie s • Then carry out actions on behalf of target user s • Labor-intensiv e • Leaves traces in server logs
  • 31. Inducing User Actions • Use attack payload script to carry out actions directl y • MySpace XSS worm did thi s • If the goal is to perform an administrative action, each user can be forced to try it until an administrator is compromised
  • 32. Exploiting Trust Relationships • Browsers trust JavaScript with cookies from the same websit e • Autocomplete in the browser can fi ll in fi elds, which are then read by JavaScrip t • Some sites require being added to Internet Explorer's "Trusted Sites"; those sites can run arbitrary code like this
  • 33. Exploiting Trust Relationships • ActiveX controls often contain powerful method s • They may check to see that requests came from the expected sit e • With XSS, that condition is satis fi ed
  • 34. Escalating the Client-Side Attack • Website may attack users b y • Logging keystroke s • Capturing browsing histor y • Port-scanning the local network
  • 35. 12b
  • 37. Delivering Re fl ected and DOM-Based XSS Attacks • Phishing email containing a crafted UR L • Targeted attack with custom emai l • Instant message containing a UR L • Code posted on websites that allow user to post HTML
  • 38. Watering Hole Attack • Attacker creates a website with content that will interest the target user s • Use search engine optimization to attract viewer s • Page contains content that causes the user's browser to make requests containing XSS payloads to the vulnerable application
  • 39. • Purchase ad space, put malicious URL in the a d • The ad may appear in pages about the app you are attacking, because of keyword matche s • Web apps often have "tell a friend" or "send feedback" feature s • Leverage this to deliver an XSS attack via an email that originates from the organization's server Delivering Re fl ected and DOM-Based XSS Attacks
  • 40. Delivering Stored XSS Attacks • In-band (most common)
  • 41. Delivering Stored XSS Attacks • Out-of-ban d • Anything other than viewing the target ap p • Such as email from its server
  • 42. Chaining XSS • XSS vulnerability itself may be low-ris k • But chaining it together with other vulnerabilities can cause serious compromise
  • 43. Example • XSS allows script to be inserted into user's displayed nam e • Access control fl aw lets attacker change other users' name s • Add token-stealing XSS to every usernam e • Gain administrator credentials: total control of application
  • 44. Finding and Exploiting XSS Vunerabilities
  • 45. Basic Approach • Inject this string into every parameter on every page of the applicatio n • If the attack string appears unmodi fi ed in the response, that indicates an XSS vulnerabilit y • This is the fastest way to fi nd an XSS, but it won't fi nd them all
  • 46. When the Simple Attack Fails • Applications with rudimentary blacklist-based fi lter s • Remove <script>, or < > " / • Crafted attacks may still work
  • 47. Response Different from Input • XSS attacks that don't simply return the attack strin g • Sometimes input string is sanitized, decoded, or otherwise modi fi e d • In DOM-based XSS, the input string isn't necessarily returned in the browser's immediate response, but is retained in the DOM and accessed via client-side JavaScript
  • 48. Finding and Exploiting Re fl ected XSS Vulnerabilities
  • 49. Identifying Re fl ections of User Input • Choose a unique string that doesn't appear anyhere in the application and includes only alphabetical characters that won't be fi ltered, like "myxsstestdmqlwp " • Submit it as every parameter, one at a time, including GET, POST, query string, and headers such as User-Agen t • Monitor responses for any appearance of the string
  • 50. Testing Re fl ections to Introduce Script • Manually test each instance of re fl ected input to see if it's exploitabl e • You'll have to customize the attack for each situation
  • 52. Demo 5. A Tag Attribute Value • Here are two ways to exploit it
  • 53. Demo 6. A JavaScript String • This attack works
  • 54. Demo 7. An Attribute Containing a URL • Use the javascript: handler to make your script into a UR L • Or use the onclick event handler
  • 55. Probing Defensive Filters • Three common types
  • 56. Beating Signature-Based Filters • You may see an error message like this
  • 57. Remove Parts of the String • Until the error goes awa y • Find the substring that triggered the error, usually something like <script > • Test bypass methods
  • 58. Ways to Introduce Script Code
  • 59. Script Tags • If <script> is blocked, try these
  • 60.
  • 61. Event Handlers • All these run without user interaction
  • 62. Event Handlers in HTML 5 • Autofocu s • In closing tag s • New tags
  • 63. Script Pseudo-Protocols • Used where a URL is expecte d • IE allows the vbs: protoco l • HTML 5 provides these new ways:
  • 64. Dynamically Evaluated Styles • IE 7 and earlier allowed this : • Later IE versions allow this:
  • 65. Bypassing Filters: HTML • Ways to obfuscate this attack
  • 66. Inserted NULL Butes • Causes C code to terminate the strin g • Will bypass many fi lter s • IE allows NULL bytes anywher e • Web App Firewalls (WAFs) are typically coded in C for performance and this trick fools them
  • 67. Invalid Tags • Browser will let it ru n • Filter may not see it due to invalid tag "x"
  • 68. Base Tag Hijacking • Set <base> and later relative-path URLs will be resolved relative to it
  • 69. Space Following the Tag Name • Replace the space with other character s • Add extra characters when there's no space
  • 70. NULL Byte in Attribute Name • Attribute delimiter s • Backtick works in IE
  • 71. Attribute Delimiters • If fi lter is unaware that backticks work as attribute delimiters, it treats this as a single attribute, not realizing that the "onerror" will execut e • Attack with no spaces
  • 72. Attribute Values • Insert NULL, or HTML-encode characters
  • 73. HTML Encoding • Can use decimal and hexadecimal format, add leading zeroes, omit trailing semicolo n • Some browsers will accept these
  • 74. Tag Brackets • Some applications perform URL decoding twice, so this inpu t • becomes this, which has no < or > • and it's then decoded to this
  • 75. • Some app frameworks translate unusual Unicode characters into their nearest ASCII equivalents, so double-angle quotation marks %u00AB and %u00BB work: Tag Brackets
  • 76. • Browsers tolerate extra bracket s • This strange format is accepted by Firefox, despite not having a valid <script> tag Tag Brackets
  • 77. Web Developer Add-on • View Generated Source shows HTML after Firefox has tried to " fi x" the code
  • 79. Telling Browser the Character Set • Set it in the HTTP Content-Type heade r • Or an HTTP META ta g • Or a CHARSET parameter, if one is used
  • 80. Shift-JIS • A 16-byte encoding scheme developed for Japanese character s • Suppose two pieces of input are used in the app's respons e • input1 blocks quotes, input2 blocks < and > • This attack works, because %f0 starts a two-byte character, breaking the quotation mark
  • 82. JavaScript Escaping • Unicod e • Eva l • Super fl uous escape characters
  • 84. Dynamically Constructing Strings • Third example works in Firefo x • And in other browsers too, according to link Ch 12f
  • 85. Alternatives • Alternatives to eva l • Alternatives to dots
  • 86.
  • 87. Combining Multiple Techniques • The "e" in "alert" uses Unicode escaping: u006 5 • The backslash is URL-encoded: &#x5c ; • With more HTML-encoding
  • 88. VBScript • Skip this sectio n • Microsoft abandoned VBScript with Edg e • Link Ch 12g
  • 89. Beating Sanitization • Encoding certain character s • < becomes &lt ; • > becomes &gt ; • Test to see what characters are sanitize d • Try to make an attack string without those characters
  • 90. Examples • Your injection may already be in a script, so you don't need <script> ta g • Sneak in <script> using layers of encoding, null bytes, nonstandard syntax, or obfuscated script code
  • 91. Mistakes in Sanitizing Code • Not removing all instance s • Not acting recursively
  • 92. Stages of Encoding • Filter fi rst strips <script> recursivel y • Then strips <object> recursivel y • This attack succeeds
  • 93. Injecting into an Event Handler • You control fo o • This attack strin g • Turns into this, and executes in some browsers
  • 94. Beating Length Limits 1. Short Attacks • This sends cookies to server with hostname a • This tag executes a script from the server with hostname a
  • 96. • Use multiple injection points • Inject part of the code in each poin t • Consider this URL Beating Length Limits 2. Span Multiple Locations
  • 97. • It returns three hidden fi eld s • Inject this way Beating Length Limits 2. Span Multiple Locations
  • 98. • Result Beating Length Limits 2. Span Multiple Locations
  • 99. • Inject this JavaScript, which evaluates the fragment string from the UR L • The part after # Beating Length Limits 3. Convert Re fl ected XSS to DOM
  • 100. • First attack works in a straightforward manne r • Second one works because http: is interpreted as a code label, // as a comment, and %0A terminates the comment Beating Length Limits 3. Convert Re fl ected XSS to DOM
  • 101. 10c