Day 29 — CSRF Bypass Using Domain Confusion Leads To Accoun
The application accepted JSON requests without enforcing the Content-Type header, allowing a cross-site request forgery attack via a text/plain form. Combined with a Referer header bypass using a URL with an @ symbol, an attacker could change a victim's phone number and achieve account takeover.
In today’s write-up, I’m sharing an interesting case of Account Takeover (ATO) caused by a CSRF (Cross-Site Request Forgery) bypass using domain confusion. The original finding was reported by Osama Aly in a private bug bounty program.
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 server did not strictly enforce the Content-Type header and improperly validated the Referer header, allowing a crafted cross-origin request to be processed.
Impact
An attacker could change the victim's phone number, leading to account takeover, and also perform other actions like changing username, managing API keys, enabling MFA with attacker's key, locking the account, and disconnecting platforms.
What the attacker needed
Victim logged in; victim visits attacker's page
The fix
The server should strictly enforce the Content-Type header and properly validate the Referer or Origin headers to prevent domain confusion.
How it was found
- Register a new user and log in.
- Capture requests in Burp Suite and observe JSON endpoints without CSRF tokens.
- Craft an HTML form with enctype text/plain to send a JSON body to the phone update endpoint.
- Bypass the Referer check by setting the URL to include an @ symbol before the target domain.
- Submit the form to change the victim's phone number.
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.
This is about a website that lets you change your phone number. Normally, a malicious site shouldn't be able to make your browser send a request to change it, because the request is in a format (JSON) that browsers block from other sites. But the server didn't check the format properly, so an attacker could trick your browser into sending the request. They also bypassed a check on where the request came from by using a tricky web address.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.