Skip to content
XSS Write-up Beginner

Improper Input Handling Leading to Client Side Code Execution and

A search function reflected user input into the HTML response without encoding, allowing reflected and DOM-based cross-site scripting. An attacker could run arbitrary JavaScript in a victim's browser, potentially leading to session hijacking or account takeover.

Aditya Bhatt Follow

Published on infosecwriteups.com

This testing was conducted strictly for educational and security research purposes. I do not support or encourage testing on systems without proper authorization.

Aditya Bhatt, on infosecwriteups.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 application reflected user input into HTML without output encoding and used unsafe DOM manipulation, so the browser treated input as code.

Impact

An attacker could execute arbitrary JavaScript in a victim's browser, potentially leading to session hijacking and account takeover, and the responses also disclosed internal infrastructure details; attempts at SSRF, command injection and SSTI were unsuccessful.

What the attacker needed

Victim clicks a crafted link; search functionality accessible

The fix

The application should apply strict output encoding for all user inputs, avoid unsafe DOM APIs with untrusted data, add a Content Security Policy, and suppress backend processing details from responses.

How it was found

  1. Enter a simple HTML heading tag into the search field and observe it rendered in the response.
  2. Enter a script tag into the search field and observe the script execute in the browser.
  3. Enter a payload that breaks out of an attribute and injects an image with an error handler, and observe it execute through client-side processing.
  4. Enter a localhost address and observe internal IP addresses in the response.
  5. Enter a command-injection style payload and observe it reflected but not executed.
  6. Enter a template-injection style payload and observe it reflected without evaluation.

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.

When a website takes what you type and puts it straight into the page without cleaning it, an attacker can type code instead of normal text. That code then runs in the browser of anyone who clicks a crafted link, letting the attacker act as that user. This is called cross-site scripting, or XSS.

What is XSS?

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

More by Aditya Bhatt

View all

25 more disclosed reports, best first.

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.