Skip to content
CSRF Write-up Beginner

Performing CSRF Exploits Over GraphQL

A GraphQL endpoint accepted form-encoded requests, so a malicious page could submit a state-changing mutation using the victim's session cookie. An attacker could change the victim's email address, potentially leading to account takeover.

infosecwriteups.com

Published on infosecwriteups.com

The lab demonstrates a CSRF vulnerability in a GraphQL-based user management system. Unlike traditional RESTful endpoints, this GraphQL endpoint is configured to accept application/x-www-form-urlencoded content types.

Bash Overflow, on infosecwriteups.com

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

Impact

An attacker could change the victim's email address, potentially leading to account takeover via password reset.

What the attacker needed

Victim logged in; victim visits malicious page

The fix

The endpoint should reject form-encoded requests or require a CSRF token for state-changing mutations.

How it was found

  1. Log in to the lab and change the email address, capturing the GraphQL mutation request.
  2. Send the request to Repeater and confirm the session cookie still allows email changes.
  3. Change the Content-Type header to application/x-www-form-urlencoded.
  4. Replace the request body with a form-encoded GraphQL mutation.
  5. Use Burp's CSRF PoC generator to create an HTML page.
  6. Host the page on the exploit server and deliver it to the victim, then check the access log.

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 website normally uses a secret token to stop other sites from making changes on your behalf, a protection called CSRF. Here, the GraphQL endpoint accepted a simple form submission, which browsers send with cookies automatically, so an attacker's page could change your email without your knowledge.

What is CSRF?

Another site makes a signed-in user's browser perform an action they did not intend.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.