Skip to content
CSRF Disclosed report Intermediate

Revocation API Token by Bypassing The XSRF Token

alpernae Follow

Originally disclosed on HackerOne

Critical View original
  • Disclosed after 8 days

Summary by the program

@alpernae was able to demonstrate that the Enjin Platform's GraphQL interface was missing the appropriate CSRF protection when using a session token.

Summary by the researcher

The attack is performed by crafting a malicious HTML form that, when submitted, sends a request to the Enjin platform to revoke the API token. The form is designed to bypass the Cross-Site Request Forgery (CSRF) protection mechanisms in place, such as the XSRF token. This allows the attacker to force the victim's browser to make a request to the Enjin platform on their behalf, leading to the revocation of the API token

The original report as published on HackerOne, by alpernae. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 5 min read.

What the report shows

The target is the Enjin Platform, specifically its GraphQL interface. The program's summary states that this interface was missing the appropriate CSRF protection when a session token was used. The researcher, alpernae, demonstrated the gap and the report was rated critical, with the weakness classified as Cross-Site Request Forgery (CSRF). It was disclosed on 19 January 2024.

The researcher's summary describes the attack in a single mechanism. The attacker crafts a malicious HTML form. When that form is submitted, it sends a request to the Enjin platform to revoke the API token. The form is designed to bypass the CSRF protection mechanisms in place, such as the XSRF token. The result is that the attacker forces the victim's browser to make a request to the Enjin platform on the victim's behalf, and the API token is revoked.

The report does not include the form markup, the endpoint, the request headers, the token values or the server responses. It also does not give a bounty amount or describe the fix. What it establishes is the class of flaw and the outcome: a state-changing GraphQL operation, reachable with a session token, could be triggered cross-site because the XSRF token check could be bypassed.

Root cause

The program's summary says the GraphQL interface was missing the appropriate CSRF protection when a session token was used. The report says the form was designed to bypass the XSRF token mechanism, which implies the server's validation of that token could be avoided, for example because the check was absent on this route, applied only to some content types, or satisfied by a value the attacker could influence. The report does not say which of these applied.

Impact

The demonstrated impact is the revocation of the victim's API token. An attacker who can make a logged-in user's browser submit the crafted form can revoke that user's API token. The report frames the result as forcing the victim's browser to act on the attacker's behalf; it does not describe any further use of the revoked state, such as denial of service against integrations or account takeover.

How this kind of bug works

CSRF abuses the browser's habit of attaching credentials, typically cookies, to requests regardless of which site initiated them. If a server treats a request as authenticated purely because a valid session cookie is present, any page the victim visits can cause the browser to issue that request. The attacker does not need to read the response; the side effect is the goal.

Defences work by making the request unforgeable. The synchroniser token pattern issues a random value tied to the session and requires it in a header or body that cross-origin pages cannot set or guess. Double-submit cookies compare a cookie value with a request value. SameSite cookie attributes stop the browser sending cookies on cross-site requests. Checking the Origin or Referer header rejects requests that did not come from the expected site. GraphQL APIs need the same treatment as REST: a mutation is a state-changing request and must be protected even when it is sent as JSON or as form data.

How to test for it

  1. Identify state-changing operations: mutations that create, update, delete or revoke resources, change email or password, or modify permissions. Note which ones authenticate with cookies rather than bearer tokens.
  2. Log in as a test user and capture a legitimate request for one of these operations, including the session cookie and any XSRF header or parameter.
  3. Replay the request with the XSRF token removed, then with a random value, then with a value from a different session. A response that still performs the action indicates the check is missing or weak.
  4. Build a cross-origin page that submits the same operation, using a form with enctype values the endpoint accepts, and load it in a browser where the victim is logged in. Observe whether the action occurs.
  5. Repeat with different content types and methods, since protections are often applied per route or per parser.

A positive result is a state change on the server after a request that carried no valid token, or a cross-site page that triggers the change in a real browser. Common false positives are endpoints that require a custom header the browser will not send cross-origin, cookies already marked SameSite=Strict or Lax for the relevant method, and operations that only appear to succeed because the client shows a cached state. Confirm the effect server-side before reporting.

How it is fixed

Require a per-session, unpredictable anti-CSRF token on every state-changing request, validated server-side, and reject requests where it is missing or wrong. Set session cookies with SameSite=Lax or Strict and the Secure and HttpOnly attributes. Validate the Origin header, or Referer as a fallback, against an allowlist. Avoid accepting simple form content types for mutations where a JSON body with a required custom header would force a preflight. Apply these checks uniformly across REST and GraphQL routes.

Hunting notes

CSRF tends to hide where authentication is cookie-based and the surface is large: GraphQL endpoints with many mutations, legacy form handlers, account settings pages, and API routes that accept both JSON and form encodings. Recon signals include session cookies without SameSite, endpoints that accept application/x-www-form-urlencoded or multipart/form-data, and mutations whose only protection is a header the front end adds. To make a report land, show the exact request without the token succeeding, show the cross-site page that triggers it in a browser, and state the concrete state change and its consequence for the victim. Programs accept reports that demonstrate a real side effect, not just a missing header.

Difficulty: intermediate. The concept is simple, but finding a mutation where the token check can actually be bypassed and proving it in a browser takes methodical testing.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 6 min read.

What happened, in plain words

The target is the Enjin Platform. It has a GraphQL interface, which is a way for programs to ask a server for data or tell it to do something. The program's own summary says this interface was missing the right protection against a class of attack called Cross-Site Request Forgery (CSRF) when a session token was used. The researcher, alpernae, showed the gap, and the report was rated critical. It was disclosed on 19 January 2024.

To follow this, you need three everyday ideas:

  • A request is a message your browser sends to a website, for example "please show my account page" or "please delete this item".
  • A cookie is a small piece of data the website stores in your browser after you log in, so the site can recognise you on the next request. Think of it as a wristband you get at an event: show it and staff know you are allowed in.
  • A token here is a secret string that a program uses to talk to the platform on your behalf, like a spare key. Revoking it means cancelling that key so it no longer works.

The researcher's summary describes the attack in one mechanism. The attacker crafts a malicious HTML form. When that form is submitted, it sends a request to the Enjin platform to revoke the API token. The form is designed to bypass the CSRF protection mechanisms in place, such as the XSRF token. The result is that the attacker forces the victim's browser to make a request to the Enjin platform on the victim's behalf, and the API token is revoked.

Why does this matter? Because the victim does not have to click "revoke" themselves. The victim does not have to click "revoke" themselves: the crafted form sends the request on their behalf. The attacker never needs to see the reply; the damage is the side effect on the server.

The report does not include the form markup, the endpoint, the request headers, the token values or the server responses. It also does not give a bounty amount or describe the fix. What it establishes is the class of flaw and the outcome: a state-changing GraphQL operation, reachable with a session token, could be triggered from another site because the XSRF token check could be bypassed.

In general, how this kind of bug works

CSRF abuses a habit of browsers: they attach your cookies to requests no matter which site started them. If a server treats a request as logged in purely because a valid session cookie is present, then any page you visit can make your browser send that request. The attacker does not need to read the response; the side effect is the goal.

Defences work by making the request impossible to forge:

  1. The synchroniser token pattern gives each session a random value and requires it in a header or body that another site cannot set or guess.
  2. Double-submit cookies compare a cookie value with a value in the request.
  3. The SameSite cookie attribute stops the browser sending cookies on cross-site requests.
  4. Checking the Origin or Referer header rejects requests that did not come from the expected site.

GraphQL APIs need the same treatment as ordinary web APIs: a mutation, meaning an operation that changes something, is a state-changing request and must be protected even when it is sent as JSON or as form data.

How to test for it

  1. Identify state-changing operations: mutations that create, update, delete or revoke resources, change email or password, or modify permissions. Note which ones authenticate with cookies rather than bearer tokens.
  2. Log in as a test user and capture a legitimate request for one of these operations, including the session cookie and any XSRF header or parameter.
  3. Replay the request with the XSRF token removed, then with a random value, then with a value from a different session. A response that still performs the action indicates the check is missing or weak.
  4. Build a cross-origin page that submits the same operation, using a form with enctype values the endpoint accepts, and load it in a browser where the victim is logged in. Observe whether the action occurs.
  5. Repeat with different content types and methods, since protections are often applied per route or per parser.

A positive result is a state change on the server after a request that carried no valid token, or a cross-site page that triggers the change in a real browser. Common false positives are endpoints that require a custom header the browser will not send cross-origin, cookies already marked SameSite=Strict or Lax for the relevant method, and operations that only appear to succeed because the client shows a cached state. Confirm the effect server-side before reporting.

How it is fixed

Require a per-session, unpredictable anti-CSRF token on every state-changing request, validated server-side, and reject requests where it is missing or wrong. Set session cookies with SameSite=Lax or Strict and the Secure and HttpOnly attributes. Validate the Origin header, or Referer as a fallback, against an allowlist. Avoid accepting simple form content types for mutations where a JSON body with a required custom header would force a preflight. Apply these checks uniformly across REST and GraphQL routes.

Where to look

CSRF tends to hide where authentication is cookie-based and the surface is large: GraphQL endpoints with many mutations, legacy form handlers, account settings pages, and API routes that accept both JSON and form encodings. Signals worth watching for include session cookies without SameSite, endpoints that accept application/x-www-form-urlencoded or multipart/form-data, and mutations whose only protection is a header the front end adds. To make a report land, show the exact request without the token succeeding, show the cross-site page that triggers it in a browser, and state the concrete state change and its consequence for the victim. Programs accept reports that demonstrate a real side effect, not just a missing header.

Difficulty: intermediate. The concept is simple, but finding a mutation where the token check can actually be bypassed and proving it in a browser takes methodical testing.

Glossary

  • API: a way for one program to talk to another, here the interface the Enjin Platform exposes.
  • API token: a secret string a program uses to act on your behalf, like a spare key.
  • Cookie: a small piece of data a site stores in your browser to recognise you later.
  • CORS preflight: an automatic check the browser makes before sending certain cross-site requests, to ask the server whether they are allowed.
  • Cross-origin: coming from a different website than the one being contacted.
  • CSRF (Cross-Site Request Forgery): tricking a logged-in user's browser into sending a request the user did not intend.
  • Double-submit cookie: a defence that compares a value in a cookie with the same value in the request.
  • Endpoint: a specific address on a server that accepts requests.
  • GraphQL: a query language and interface style for APIs, where clients ask for exactly the data or action they need.
  • Header: extra information attached to a request or response, such as the content type or a token.
  • HTML form: the part of a web page that collects input and sends it to a server when submitted.
  • HttpOnly: a cookie attribute that stops page scripts from reading the cookie.
  • Mutation: in GraphQL, an operation that changes data rather than only reading it.
  • Origin / Referer: headers that tell the server which site a request came from.
  • Request: a message a browser sends to a server asking it to do something.
  • Revoke: to cancel a token so it no longer works.
  • SameSite: a cookie attribute that controls whether the cookie is sent on cross-site requests.
  • Secure: a cookie attribute that sends the cookie only over encrypted connections.
  • Session: the period during which a site remembers you as logged in.
  • Session token: the value that identifies your logged-in session.
  • Synchroniser token pattern: a defence that requires a random per-session value in each state-changing request.
  • XSRF token: another name for an anti-CSRF token, a value the server checks to confirm a request is genuine.

More by alpernae

View all

2 more disclosed reports, best first.

More from Enjin

View all

The newest disclosed reports for this program.

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.