How I found 3 CSRFs on a Public Program
The server accepted JSON request bodies sent with a text/plain content type, so an attacker could craft an HTML form that submits JSON data cross-site without triggering CORS preflight. This allowed an attacker to change a victim's email address, delete their account, or change their phone number via CSRF.
medium.com
Published on medium.com
Hello, this is shellreaper again and I’m walking you through 3 CSRFs I found on a public program using the same technique , but on different features. we’re going to use redacted.com instead of the program’s domain to follow disclosure standards .
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 enforce the Content-Type header and parsed JSON bodies even when sent as text/plain, bypassing CORS protections.
Impact
An attacker could change a victim's email address, delete their account, or change their phone number without the victim's consent, potentially leading to account takeover.
What the attacker needed
Victim is logged in; victim visits attacker's page
How it was found
- Notice that the email update request uses a JSON body but the server also accepts it with Content-Type text/plain.
- Create an HTML page with a form that has enctype text/plain and inputs crafted to produce a JSON body.
- Set the form action to the email update endpoint with the victim's userId and auto-submit it.
- The victim visits the page while logged in, and their email is changed to the attacker's address.
- Repeat the same technique on the account deletion and phone number change features.
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 attack tricks a logged-in user's browser into sending a request to a site they are already signed into, without the user meaning to. Normally, browsers block cross-site requests that use JSON because of a security check called CORS. Here, the server also accepted the same JSON data when it was labelled as plain text, which browsers do not block, so the attacker could make the victim's browser send the request.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.