Skip to content
XSS Write-up Intermediate

Bugs and Sorting out

A Next.js application passed a URL parameter called redir into a client-side navigation function that ultimately called window.location.assign, allowing an attacker to inject a javascript: URL and achieve XSS. The author traced the parameter through minified JavaScript modules to find the sink.

medium.com

Published on medium.com

One of the bugs I recently found was like this: The site had a route named /upgrade. When we visited this route, a new JS file would load.

Balki Maharaj, 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

Impact

An attacker could execute arbitrary JavaScript in a victim's browser by crafting a link with a malicious redir parameter, potentially leading to session compromise or other client-side attacks.

What the attacker needed

Victim clicks a crafted link

How it was found

  1. Visit the /upgrade route and observe a new JavaScript file loading.
  2. Find the line that reads the redir parameter from page parameters.
  3. Trace the function n.lr to module 251495 in the _app file.
  4. Follow the returned function to see it builds a URLSearchParams object from page parameters.
  5. Trace the final function d() to see it calls window.location.assign with the redir value.

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 had a feature that took a value from the web address (the 'redir' parameter) and used it to send the user to another page. Because the code did not check what that value was, an attacker could put a special link that runs their own JavaScript in the victim's browser. This is called cross-site scripting (XSS): running code in someone else's session.

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.