DOM based open redirect to the leak of a JWT token
A logout landing page used a JavaScript redirect that took a user-supplied URL parameter and passed it to an OAuth API, which built a redirect to that value. By supplying a URL containing an @ sign, an attacker could redirect the victim to their own server, and the authentication JWT token leaked in the Referer header, allowing account takeover.
Published on medium.com
Dom-based open redirects can be underestimated on pentests/bug bounty programs. However, depending on the application’s context, this kind of security vulnerability can lead to critical impacts as some information can leak through the referrer header.
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 application trusted the originalUrl parameter and passed it to an OAuth redirect without validating that the resulting URL stayed on the trusted domain, and the redirect response included the JWT in a way that leaked via the Referer header.
Impact
An attacker could obtain the victim's JWT token and use it to log into the victim's account, leading to account takeover.
What the attacker needed
Victim clicks a crafted logout link; victim clicks the 'Click here' link
How it was found
- Log out of the session to reach the logout landing page with the originalUrl parameter.
- Inspect the page and find the JavaScript event listener on the 'Click here' link that performs the redirect.
- Set the originalUrl parameter to a value containing an @ sign followed by an attacker-controlled domain.
- Click the 'Click here' link, which redirects to the attacker's server.
- Observe that the authentication JWT token is sent in the Referer header to the attacker's server.
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 you log out, the site sends you to a page with a 'Click here' link that redirects you to the login page. The address it redirects to is taken from a value in the page's URL, and the site did not check that this value stayed on its own domain. An attacker could put their own web address there, so when the victim clicked the link they went to the attacker's site, and the browser also sent the victim's login token to that site in the Referer header.
What is Open redirect?
A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.