Reflected XSS & the Encoding Fix
Find where an app echoes your input straight back into the page, prove it executes arbitrary HTML/JS, then see exactly how output encoding shuts the hole — by comparing the vulnerable endpoint against its fixed twin.
- Advanced
- 45 min
- Security
- XSS
- Web
- OWASP
Overview
Cross-site scripting (XSS) is what happens when an application takes attacker input and writes it into a page without encoding it — letting the attacker's HTML or JavaScript run in the victim's browser. This lab makes the mechanism concrete and then shows the fix side by side.
On VulnShop (http://localhost:5000) you'll confirm that the /search endpoint reflects your input, prove it's exploitable by getting a literal <script> tag into the response, then hit /safe — the same feature with proper HTML output encoding — and watch the identical payload come back neutralised as <script>. That contrast is the whole lesson: encode on output.
What you will learn
- Detect input reflection in a server response
- Craft a payload that proves reflected XSS
- See a
<script>payload land in HTML unescaped - Compare against an endpoint that HTML-encodes its output
- Understand output encoding as the correct fix
Before you start
- Comfortable with
curl - A little HTML helps (what a
<script>tag is) - Authorised-target rule: only against your own private lab
Tasks
- 01Find the reflection
- 02Prove the XSS
- 03See the fix: output encoding