BugBounty | A Dom Xss
A JavaScript file built an AJAX request URL from the browser's location.pathname, which an attacker could control by using a path starting with two slashes. This caused the page to fetch content from the attacker's domain and write it into the page, leading to DOM-based cross-site scripting.
I checked the js file by the way when I checked the request. Found a suspicious piece of code
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 code used the attacker-controllable location.pathname to construct an AJAX URL without validation, allowing a protocol-relative URL to redirect the request to an external domain.
Impact
An attacker could execute arbitrary JavaScript in the context of the vulnerable site when a victim visits a crafted URL, potentially stealing data or performing actions as the victim.
What the attacker needed
Victim clicks a crafted link; attacker controls a web server
How it was found
- Visit the vulnerable page path with a double-slash prefix pointing to an attacker domain.
- The page's JavaScript reads location.pathname and builds an AJAX request to that external URL.
- The attacker's server responds with HTML containing a script.
- The AJAX success handler writes the response into the page, executing the script.
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's code took part of the address bar (the path) and used it to build a request to its own server. By putting a special path that starts with two slashes, an attacker could make the browser request a page from their own site instead. The site then inserted that response into the page, so the attacker's script ran in the victim's browser.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.