Day 7 & 8: What Took 2 Days..
The application's CSRF token was tied to a non-session cookie, allowing an attacker to use a token and key from one session with another user's session cookie. By injecting a controlled CSRF key cookie via CRLF injection in the search parameter, an attacker could change a victim's email address.
Published on smartpicks4u.medium.com
so in the last 2 days i was just doing a single lab. just one. tried so many things or i can say tried the same thing like 50 times expecting different results. you know what they say about insanity.
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 CSRF token was validated against a separate cookie that was not bound to the user's session, and the search parameter allowed CRLF injection to set arbitrary cookies.
Impact
An attacker could change a victim's email address, potentially leading to account takeover, if the victim visits a malicious page.
What the attacker needed
Victim clicks a link or visits a malicious page; attacker has a valid account to obtain a token-key pair
The fix
The CSRF token should be tied to the user's session, and the search parameter should properly encode or reject CRLF characters to prevent header injection.
How it was found
- Identify that the CSRF token is tied to a CSRF key cookie, not the session cookie.
- Find that the search parameter is vulnerable to CRLF injection and reflects input into response headers.
- Craft a page with an image tag whose source triggers the CRLF injection to set a chosen CSRF key cookie.
- Use the onerror event of the image to submit a form that changes the victim's email, including a matching CSRF token.
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 CSRF token is a secret code a website puts in forms to make sure the request really came from its own pages. Here, the code was checked against a cookie that was not tied to the user's login session, so an attacker could pair their own code and cookie with a victim's session. The attacker also found a way to set that cookie in the victim's browser by injecting a fake header through the search box.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.