Skip to content
XSS Write-up Intermediate

⚔️ Unsafe Eval = Unlimited Control: How a JS Sink Let Me Run

A JavaScript file used eval() on data from an API response, allowing an attacker who could modify that response to execute arbitrary JavaScript in the victim's browser. This could lead to theft of cookies, local storage, and session tokens.

iski Follow

Published on infosecwriteups.com

Free Link 🎈

Iski, 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

The application used eval() on data from an API response without validating or sanitising it.

Impact

An attacker could execute arbitrary JavaScript in a victim's browser, leading to session takeover, theft of tokens and API keys, and potential hijacking of any logged-in user.

What the attacker needed

Ability to modify API response; victim visits a malicious page or clicks a link

The fix

The eval() call should be removed and replaced with safe parsing or validation of the data.

How it was found

  1. Find the JavaScript file containing the eval() call.
  2. Identify the API endpoint that returns the data used by eval().
  3. Intercept the API response and modify the action parameter to contain JavaScript code.
  4. Forward the modified response and observe the JavaScript execution.

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.

The website took some data from its own API and ran it as JavaScript code using a function called eval. Because the data wasn't checked, an attacker who could change the API response could make the browser run their own code, stealing private information like login cookies.

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 iski

View all

186 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.