GraphQL exposes a typed graph. The client chooses the shape of the response, so the server must authorize every node and field, not just the entry point.
Introspection reveals types and fields. A resolver accepts an ID and returns data without checking ownership. The attacker queries another user's object and requests an admin-only field.
We secure the endpoint and forget the graph.
What is actually at stake?
Before touching a payload, map the assets, the actors and the boundary that is supposed to protect them. A finding only becomes a vulnerability when you can connect the failed boundary to a real asset.
Assets
- User and tenant objects
- Admin-only fields
- Mutations and bulk operations
- Schema metadata and internal types
Actors
- Authenticated user with a normal role
- Attacker using introspection or field guessing
- Malicious client sending batched or deeply nested queries
Trust boundaries
- Query field to resolver policy
- Parent object to child object
- Alias to rate limit
- Introspection to production schema
- Mutation input to privileged field
Abuse cases
- Query user(id) for another tenant
- Request an admin-only field on a visible object
- Use aliases to bypass a per-query limit
- Chain nested objects to reach private data
- Abuse verbose errors to infer schema
Follow the decision, not the payload
Every family has a moment where trusted data becomes an authorization, parsing or state decision. Learn to point at that moment in the request path.
- 01
Parse
The server parses a query document with fields, aliases, fragments and variables.
- 02
Validate
The schema validates shape, but validation is not authorization.
- 03
Resolve
Each field calls a resolver with a parent object and context.
- 04
Authorize
Every resolver must check whether the subject may read this field on this object.
- 05
Return
The response may include partial data and detailed errors, creating new inference channels.
The field that skipped the policy
Composite case study from public GraphQL disclosuresA composite case based on recurring GraphQL disclosures: the top-level query checked tenant access, but a nested field resolver returned a sensitive relation without its own check.
A tester queried their own order, then added a nested customer field. The parent resolver authorized the order, but the child resolver trusted the parent and returned another tenant's customer record.
Cross-tenant data exposure through a single query. The same pattern affected mutations where an input field reached a privileged relationship.
Authorization was applied at the route or top-level resolver instead of every field and mutation that could cross an object boundary.
Enforce policy in every resolver or a shared authorization directive, scope queries by tenant, disable or protect introspection in production, and add depth and alias limits.
Read it as a chain: discovery → failed decision → impact → fix. Then ask which link would have broken earliest.
A repeatable testing sequence
- Run an introspection query and map types, fields and arguments.
- Query your own object, then change the ID.
- Request hidden or admin-only fields.
- Use aliases, fragments and batching to test many paths at once.
Where smart people get fooled
- One endpoint does not mean one authorization check.
- The UI hides a field; the schema still exposes it.
- Introspection is often enabled in production.
What would the logs show?
A control is stronger when someone can see it fail. These signals are starting points for a detection rule, not a complete SIEM use case.
- Introspection queries in production
- Many aliases or deeply nested selections from one client
- Queries that request fields outside the caller's role
- Repeated errors naming internal types or resolvers
- A single operation touching multiple tenants
index=web sourcetype=graphql | eval risky=if(match(query,"(__schema|__type|aliases|tenantId)"),1,0) | where risky=1 | stats count values(operation_name) by user_id, clientip | where count > 10Fix the decision, then prove it stays fixed
- Enforce field-level and object-level authorization in resolvers.
- Disable introspection in production and limit query depth/cost.
- Use persisted queries and rate limits.
order: (_, { id }, ctx) => db.order.findUnique({ where: { id } })order: async (_, { id }, ctx) => {
const order = await db.order.findFirst({ where: { id, tenantId: ctx.user.tenantId } });
if (!order) throw new GraphQLError("Not found");
return order;
}
// child resolvers also receive ctx and enforce field-level policyTreat every resolver as an API endpoint. Apply tenant and role checks in the resolver or a shared directive, not only at the HTTP route.
Regression tests a reviewer would ask for
Cross-tenant object
GivenTwo tenants each own an order
WhenTenant A queries Tenant B's order ID
ThenThe resolver returns not found or forbidden
Nested field
GivenA visible parent object has a sensitive child relation
WhenA normal user selects the child field
ThenThe child resolver enforces its own policy
Mutation input
GivenA mutation accepts an input object
WhenThe input includes tenantId or role
ThenThe schema rejects or ignores privileged fields
Alias abuse
GivenA client sends many aliases in one operation
WhenThe query count exceeds the limit
ThenThe server rejects the operation before resolving fields
What this finding is not
Strong testers kill their own findings before someone else does. These are the shortcuts that turn a real bug into a weak report — or a false alarm into a wasted escalation.
- Introspection is enabled: this is a hardening issue, not automatically a data breach; test field-level authorization next.
- A query returns an error for another user's ID: test nested fields, aliases and mutations before concluding the schema is safe.
- A field is hidden from the docs: the schema may still expose it, and field names can be guessed.
- The response omits a field: partial errors may reveal whether it exists or whether authorization failed.
Terms you should be able to use precisely
- Resolver
- The function that returns data for a GraphQL field.
- Introspection
- A GraphQL query that returns the schema's types and fields.
- Alias
- A client-chosen response key that lets one operation request the same field multiple times.
- Fragment
- A reusable selection set shared across queries.
- Field-level authorization
- A policy decision applied to each field, not only the top-level query.
- Query depth limit
- A control that rejects excessively nested operations to limit cost and abuse.
Answer these without reciting a payload
Why is introspection not the main GraphQL security problem?
It reveals the schema, but the real risk is missing field-level authorization. Even without introspection, field names can be guessed or learned from clients.
Where should authorization live in GraphQL?
In every resolver or a shared authorization layer/directive that receives the subject, object and field context. Top-level route checks are not sufficient.
How do aliases create abuse?
A single operation can request the same expensive field many times with different aliases, bypassing naive per-query rate limits.
Can you separate the mechanism from the payload?
Four questions, graded on the server. Answers and explanations are released only after you submit, and signed-in learners keep a best score.
GraphQL يبدو واجهة واحدة، لكنه في الحقيقة عشرات نقاط الوصول: كل حقل وكل resolver قرار صلاحية مستقل.
الخطأ الشائع هو حماية الاستعلام الأعلى ثم ترك الحقول المتداخلة تثق بالأب. طبّق السياسة في كل resolver، أو عبر توجيه مركزي، وقيّد الاستعلامات بالعمق والـaliases والتكلفة. تعطيل introspection مجرد تحصين، وليس بديلًا عن التحقق من الصلاحيات.
Which resolver checked ownership for this field?