---
title: "1. Overview"
date: 2024-10-02
draft: false
---

https://owasp.org/www-community/attacks/xss/
- XSS vulns take advantage of user input sanitization to `write` JS code into a page and execute it on the clientside. 

Web apps work by:
1. receiving HTML code from backend server
2. Rendering it on clientside browser

When vuln webapps dont sanitize user input, we can inject extra JS code in an input field (like a comment or reply) so that when other users view the same page they execute the code on their machine. 

XSS solely executed on clientside. 
Do not directly affect backend
Only affects user who executes

Direct impact on backend, low. Very commonly found in webapps. 
Equates to medium risk:
- low impact + high probability = med risk

Always reduce risk by detecting remediating and proactively preventing these vulns

---
#### XSS attacks
- Basic example - Target user unwittingly sends session cookie to attacker-controlled webserver. 
- Having target user browser execute API calls that lead to a malicious action - like changing user's password to password we choose. 

XSS attacks executed with Js are limited to within the browser JS engine. 
- V8 in Chrome for example
Cannot execute sys-wide JS code to do something like sys-level code execution
In modern web browsers, they're also limited to domain of original website 

If a skilled researcher identifies a binary vuln in a web browser (heap overflow in chrome for example) xss can be leveraged to exec JS exploit on browser that breaks out of sandbox and executes code on machine 

Wellknown xss example is Samy worm 
https://en.wikipedia.org/wiki/Samy_(computer_worm)
- Myspace effected
- Stored XSS 
- When viewing infected page, posted msg on victims page saying 'Samy is my hero' 
- Msg itself contained same JS payload to repost the same message when viewed by others

https://blog.sucuri.net/2014/06/serious-cross-site-scripting-vulnerability-in-tweetdeck-twitter.html
- Tweetdeck xss 
- self-retweeting tweet 

#### Types of XSS matrix

|Type|Description|
|---|---|
|`Stored (Persistent) XSS`|The most critical type of XSS, which occurs when user input is stored on the back-end database and then displayed upon retrieval (e.g., posts or comments)|
|`Reflected (Non-Persistent) XSS`|Occurs when user input is displayed on the page after being processed by the backend server, but without being stored (e.g., search result or error message)|
|`DOM-based XSS`|Another Non-Persistent XSS type that occurs when user input is directly shown in the browser and is completely processed on the client-side, without reaching the back-end server (e.g., through client-side HTTP parameters or anchor tags)|

---
