The Boomerang Attack
Imagine throwing a boomerang with a knife attached. You aim it at your target, they catch it (because it looks harmless), and suddenly they're holding a knife. That's reflected XSS in a nutshell.
In reflected XSS, your malicious payload travels to the server in a request (usually in the URL) and bounces right back in the response, where the victim's browser executes it. It's a one-shot attack - you need to trick someone into clicking your crafted link.
XSS Fundamentals
The Anatomy of a Reflected XSS Attack
Reflected XSS requires three participants: the attacker, the victim, and the vulnerable website. Let's trace the attack flow:
Where to Find Reflected XSS
Any place where user input is reflected back in the page without sanitization is a potential reflected XSS. Here are the most common:
1. Search Functions
2. Error Messages
3. URL Parameters in Forms
4. HTTP Headers Reflected
5. 404/Error Pages
Context is Everything
Where your input lands in the HTML determines what payload will work. This is called "context-aware XSS testing."
HTML Context
Attribute Context
JavaScript Context
URL Context
CSS Context
Bypassing Filters
Most modern applications have some form of XSS protection. Here's how to test if those filters can be bypassed:
Case Manipulation
Tag Alternatives
Encoding Tricks
Breaking Parser Logic
JavaScript Obfuscation
Testing Methodology
Reflected XSS Hunting Process
- Input a unique string like "CANARY123" in every parameter
- Search the response for your canary
- Note WHERE it appears (HTML, attribute, JS, etc.)
- Start simple: <script>alert(1)</script>
- If blocked, try: <img src=x onerror=alert(1)>
- Note what gets through and what's filtered
- What's being removed/encoded?
- Is it client-side or server-side?
- Is it a WAF or application-level filter?
- Match payload to the injection context
- Break out of strings/attributes if needed
- Use appropriate event handlers
- Replace alert() with actual malicious code
- Cookie theft, keylogging, phishing
- Create proof of concept URL
Useful Probe Payloads
Real-World Impact
"It's just an alert box" is what uninformed people say. Here's what reflected XSS can actually do:
Session Hijacking
Credential Theft via Phishing
Keylogging
Drive-by Download
Cryptocurrency Mining
Practice Challenges
Knowledge Check
Key Takeaways
- Reflected XSS requires social engineering - victims must click a malicious link
- Context matters: HTML, attribute, JavaScript, and URL contexts need different payloads
- Filter bypass often succeeds with alternative tags, event handlers, and encoding tricks
- Test systematically: Use a unique probe, find reflections, identify filters, craft context-aware payloads
- Real impact includes session hijacking, credential theft, malware distribution - not just alert boxes