Chaining a self XSS to Account Takeover
A redirect endpoint accepted a javascript: URL and executed it when the user clicked a continue button, but only when the URL was loaded directly. By framing the page and swapping the iframe source after load, the attacker could bypass a regex filter and run script in the victim's session, leading to account takeover.
Published on github.com
Hello, It's been a really long time since I shared any of my research/ findings lately, but in this writeup I'll share a vulnerability I found which was quite interesting to me and might change your perception towards "SELF XSS"
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 redirect page executed javascript: URLs without proper sanitisation, and the client-side regex filter could be bypassed by changing the iframe source after the initial page load.
Impact
An attacker could take over any authenticated user's account with one click, because the script runs in the victim's session and can read their cookies.
What the attacker needed
Victim clicks a link to attacker's site; victim clicks the continue button; endpoint lacks X-Frame-Options
The fix
The redirect endpoint should not execute javascript: URLs and should set X-Frame-Options to prevent framing.
How it was found
- Find the redirect endpoint that shows a warning and a continue button.
- Notice that a javascript: URL runs when the continue button is clicked.
- Observe that opening the same URL in a fresh browser removes the continue button because a regex blocks special characters.
- Check that the endpoint lacks X-Frame-Options and can be framed.
- Host a page that loads the endpoint in an iframe and swaps the iframe source to a javascript: URL after load.
- Send the hosted page to a victim; when they click continue, the script runs with their cookies.
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.
A self-XSS is a script that only runs if you paste it into your own browser, so it normally has no impact. Here the site had a redirect page that would run a javascript: link when you clicked 'continue', but a filter blocked it when opened directly. The researcher put the page inside a frame on their own site and changed the frame's address after it loaded, so the filter did not see the dangerous characters and the script ran in the victim's logged-in session.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.