Redirect Discrepancies to leak secrets in URLs
A server-side redirect endpoint that only accepted a path could be made to loop indefinitely by supplying a fragment as the redirect target, because the browser adds the fragment to its URL while the server never receives it. After Chrome hit its redirect limit and showed an error page, an attacker with existing JavaScript execution could navigate an iframe back to a same-origin page and recover the URL containing a session token from the Navigation API.
ethiack.com
Published on ethiack.com
Passing secrets around embedded directly in URLs is not today’s news. Session tokens, magic links, redemption codes, and user identifiers have had a certain tendency to appear in query strings for years.
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 endpoint validated only the path and allowed a fragment-only target, so the browser-side URL changed while the server-side request stayed identical, creating an infinite redirect loop.
Impact
An attacker who already has JavaScript execution on the target origin could recover a session token from the URL after the redirect loop, though the technique requires that existing script execution and only works in Chrome.
What the attacker needed
JavaScript execution on the target origin; Chrome browser; Redirect endpoint accepts a path
The fix
Developers should avoid putting sensitive tokens in URLs and should strictly allowlist user-controlled redirect parameters.
How it was found
- The browser requests the share redirect endpoint with a path that redeems a session token.
- The server generates a session token and places it in the URL.
- The server responds with a redirect, causing the browser to request again with the token in the URL.
- The server redirects to a fragment, which the browser adds to its URL but does not send to the server.
- The server sees the same request and redirects again, looping until Chrome's redirect limit is reached.
- Chrome shows an error page containing the session token, and JavaScript on the same origin can recover the URL from the Navigation API.
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 web address can have a part after a '#' symbol called a fragment, which the browser keeps but never sends to the server. If a server redirects to a fragment, the browser and server disagree about the address, so the same request repeats until the browser gives up with an error page. If a secret was in that address, it can end up visible in the browser's history, which JavaScript on the same site can then read.
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.