Skip to content
XSS Write-up Intermediate

Vulnerable Application

A reflected XSS vulnerability existed in a JavaScript context where user input was sanitised with HTML entity encoding and semicolon removal. An attacker could execute arbitrary JavaScript by using arithmetic operators or optional chaining to avoid semicolons and bypass a weak WAF rule.

secjuice.com

Published on secjuice.com

Using JavaScript Arithmetic Operators and Optional Chaining to bypass input validation, sanitization and HTML Entity Encoding when injection occurs in the JavaScript context. To know how to exploit an injection that could lead to an XSS vulnerability, it's important to understand in which context the injected payload…

The author, on secjuice.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 developer used HTML entity encoding and semicolon removal as a substitute for context-aware output encoding, which is ineffective in a JavaScript context.

Impact

An attacker could execute arbitrary JavaScript in a victim's browser, potentially leading to session hijacking or other client-side attacks.

What the attacker needed

Victim clicks a crafted link

How it was found

  1. Identify that the user parameter is reflected inside a JavaScript function.
  2. Observe that semicolons are removed and special characters are HTML-entity encoded.
  3. Craft a payload using an arithmetic operator (e.g., subtraction) to execute a function without a semicolon.
  4. Deliver the crafted URL to a victim to trigger the XSS.

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 puts user input directly into a script, special characters can break out and run code. Here, the developer tried to clean the input by turning quotes into HTML entities and removing semicolons, but the browser still decodes those entities. The attacker found other ways to run JavaScript without semicolons, so the cleaning failed.

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.