Skip to main content
LowAPIOWASP A01:2021CWE-540

How to fix: GraphQL schema served as raw SDL

The response is a GraphQL schema document in Schema Definition Language form, served as plain text. That is the schema itself, not an HTML page that happens to show one.

Why it matters

An SDL dump hands over the same map that introspection would, without needing introspection to be enabled. Every type, field, argument, enum value and input object is readable, including internal fields the public client never queries, which is the starting point for finding an operation whose authorization was never written.

Disabling introspection is a common hardening step, and it is quietly undone when the build also publishes schema.graphql next to the bundle. The detector requires the response not to be HTML and to contain a real type Query { ... } block plus a second SDL construct (a Mutation type, a schema block, an input, or an enum), so a tutorial page showing a schema in a code block does not match.

How to fix it

  1. 1Remove the .graphql / .gql schema file from anything the web server can serve, and from the published build output.
  2. 2If a schema artifact is needed by CI or by a client codegen step, publish it to a private registry or an authenticated endpoint instead of the public origin.
  3. 3Confirm introspection is disabled too: an attacker only needs one of the two paths.

Code examples

Next.js: keep schema files out of the public directory

bash
# Schema files belong beside the server code, not under public/
mv public/schema.graphql server/schema.graphql

# Verify nothing else ships one
grep -rl 'type Query' .next/static public 2>/dev/null

Nginx: refuse to serve schema artifacts

nginx
location ~* \.(graphql|gql)$ {
    return 404;
}

References

Detected automatically by VulnRadar. The check id is api-graphql-schema-sdl-exposed, stable across every scan so you can filter or diff on it.

See every api check

Questions

How severe is GraphQL schema served as raw SDL?
VulnRadar rates this low severity in the api category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id api-graphql-schema-sdl-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does GraphQL schema served as raw SDL map to?
It maps to CWE-540. In the OWASP Top 10 it falls under A01:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for graphql schema served as raw sdl

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: GraphQL schema served as raw SDL | VulnRadar