Skip to content
XSS Write-up Beginner

How I Found a Reflected XSS in a Government Website

A search parameter on a government website reflected user input without proper filtering, and the tester found that URL-encoding an image tag with an error handler bypassed the filter so the script ran in the browser. An attacker could use this to alter page content, build a fake login form for phishing, or redirect visitors elsewhere.

medium.com

Published on medium.com

While testing a government web application, I tried the usual XSS payloads in the main domain. Nothing worked.

Moamen Samir, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the input filter only matched plain-text script patterns and did not account for URL-encoded input being decoded and reflected into the page.

Impact

An attacker could run script in a victim's browser to rewrite the page, show a fake login form to steal credentials, or redirect the user to another site.

What the attacker needed

Victim visits a crafted link

How it was found

  1. Send a basic script tag in the search parameter and observe that it is blocked or not reflected.
  2. URL-encode an image tag with an error handler and pass it in the search parameter.
  3. Observe that the request is not rejected and the response reflects the input.
  4. See the browser decode the payload and execute the JavaScript.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A reflected cross-site scripting (XSS) bug happens when a website takes something you typed, such as a search term, and puts it straight back into the page without cleaning it. If that text is a small piece of code, the visitor's browser runs it as if the site itself wrote it. Here the site blocked obvious code but forgot that encoded text gets decoded by the browser later, so the code slipped through.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.