Reflected XSS Attacks
What you'll learn: How reflected XSS exploits vulnerabilities by injecting malicious scripts into URLs that are immediately echoed back in the server's response.
What is Reflected XSS?
Reflected XSS (Cross-Site Scripting) is like a malicious boomerang. An attacker crafts a URL containing a script, tricks a victim into clicking it, and the server unwittingly "reflects" that script back in its response—where the victim's browser executes it.
How It Works
Imagine a search feature on a website. When you search for "cookies," the page displays: "Results for: cookies." The server takes your input from the URL (?search=cookies) and embeds it directly into the HTML response.
An attacker exploits this by creating a URL like:
https://example.com/search?q=<script>alert('XSS')</script>
If the server doesn't sanitize the input, it generates HTML containing:
<p>Results for: <script>alert('XSS')</script></p>
The victim's browser executes the script immediately upon loading the page. The attacker can steal session cookies, redirect to phishing sites, or manipulate page content—all because the malicious payload was "reflected" from the URL into the rendered page.
Why "Reflected"?
Unlike stored XSS (where the payload persists in a database), reflected XSS exists only in that specific request-response cycle. The malicious code isn't stored—it's immediately bounced back. The attacker typically delivers the poisoned URL via email, social media, or other channels to trick victims into clicking.
The Real Danger
The victim sees a legitimate domain in the URL bar, making the attack stealthy. Since the script runs in the context of the trusted site, it has full access to cookies, session tokens, and page content.
Key Takeaway: Reflected XSS attacks inject malicious scripts through URL parameters that the server immediately echoes back without proper sanitization, causing the victim's browser to execute attacker-controlled code in the context of the vulnerable site.