GraphQL gives product teams a clean contract between frontend and backend by collapsing dozens of REST routes into a single typed schema served at /graphql. From a security standpoint, that design shifts authorization away from URL-based gateway middleware and down into individual resolvers. Because an automated scanner does not understand your tenant model or object ownership rules, it can hammer a GraphQL endpoint with injection payloads all afternoon and report zero findings while a cross-tenant data leak sits in plain sight.
Object-level vs. edge-level authorization drift
The most frequent critical vulnerability we see in multi-tenant SaaS and fintech GraphQL APIs is asymmetric authorization across graph edges. An engineering team correctly protects the obvious root entry point, such as Query.project(id), by checking that the authenticated user belongs to the project's organization. Months later, another feature adds a reverse relationship or nested field such as User.projects, Organization.invoices or Comment.parent.
If those nested field resolvers query the database directly by foreign key without re-applying the same tenant policy, any caller who can reach the parent or sibling node traverses straight into another tenant's records. The root query stays secure while the graph edge leaks the exact same sensitive data. A closely related pattern appears in Relay-style global node queries (Query.node(id)): base64-encoded identifiers such as UHJvamVjdDoxMDQ= decode directly to Project:104, allowing a caller to guess sequential primary keys and resolve arbitrary records if the generic node resolver bypasses the authorization checks placed on domain-specific root queries.
# Query.project(id) enforces tenant check -> returns 403
# Comment.parent resolves directly by parentId -> leaks cross-tenant project
query TraverseEdge {
comment(id: "cmt_public_4091") {
id
parent {
... on Project {
id
name
billingEmail
apiKeys { prefix createdAt }
}
}
}
}Alias batching, query complexity and HTTP rate-limit bypasses
Perimeter rate limiters typically count HTTP requests per IP or per session token. GraphQL accepts multiple aliased operations inside a single HTTP POST body. Without operation-level throttling, an attacker can pack 50 or 100 login attempts, one-time-password verifications, password-reset token checks or coupon redemptions into one HTTP request that your WAF counts as a single hit.
The same mechanism enables application-layer denial of service through deeply nested cyclic queries (such as organization -> members -> projects -> organization) that multiply database queries exponentially from a 400-byte payload. Setting an HTTP body-size cap does nothing to stop a compact cyclic query from exhausting connection pools.
# Single HTTP POST counted as 1 request by perimeter WAF
mutation BruteForceOtp {
a1: verifyOtp(challengeId: "ch_991", code: "000001") { token }
a2: verifyOtp(challengeId: "ch_991", code: "000002") { token }
a3: verifyOtp(challengeId: "ch_991", code: "000003") { token }
# ... repeated with distinct aliases in one payload
}Mutation invariants and field-level mass assignment
Read-side authorization leaks are only half of the GraphQL attack surface. On the write side, teams often reuse broad GraphQL InputObject types across both administrative and self-service mutations, then pass args.input straight into an ORM update call. If an input type includes optional fields such as role, organizationId, planTier or discountPercent, a standard user can inject those fields into a profile update mutation and silently elevate privileges or alter billing state. Likewise, relying on GraphQL Float or Int scalar validation instead of domain value objects allows negative transfer amounts, zero-price checkout totals or skipped workflow states whenever a mutation trusts client-supplied numbers.
Introspection vs. real schema reconstruction
Turning off GraphQL introspection in production is good hygiene, yet teams often overestimate the protection it buys. Even with __schema disabled, many GraphQL engines leave field suggestion error messages enabled by default (Did you mean 'internalAuditLogs'?), which lets an attacker reconstruct hidden queries and mutations word by word. Frontend JavaScript bundles, mobile binaries and TypeScript codegen artifacts also expose almost the entire operational schema. Disable field suggestions explicitly in your GraphQL validation pipeline, strip stack traces from production error responses, and treat introspection removal as defense in depth rather than an access control boundary.
Testing systematically with an authorization matrix
Manual GraphQL testing replaces guesswork with structure. We extract the full type system and build an authorization matrix mapping every root query, mutation, union interface and sensitive nested edge against every application role (unauthenticated, standard member, billing admin, cross-tenant user and revoked account). Every cell is exercised with real sessions, testing both direct ID references and nested paths, alongside mutation invariants such as negative amounts, client-supplied role fields, replayable approval transitions and race conditions on concurrent requests.
Architectural fix: move policy into the domain and DataLoader layer
Sprinkling if (ctx.user.orgId !== obj.orgId) checks inside individual resolvers is brittle because the next engineer who adds a new edge will eventually forget one. The durable architectural fix is to push authorization below GraphQL into a tenant-scoped domain service and DataLoader layer. Every read path must accept the authenticated viewer context and filter by tenant at the repository or SQL boundary, so no resolver can accidentally materialize an unauthorized object regardless of which edge reached it.
// Centralize tenant scoping inside the domain loader, not each resolver
export function createProjectLoader(viewer: ViewerContext, db: Database) {
return new DataLoader<string, Project | null>(async (ids) => {
const rows = await db.projects.findMany({
where: {
id: { in: [...ids] },
organizationId: viewer.organizationId, // mandatory tenant invariant
},
});
const byId = new Map(rows.map((p) => [p.id, p]));
return ids.map((id) => byId.get(id) ?? null);
});
}Pair that domain policy with four hard gateway controls: enforce query depth and calculated cost limits before execution, cap alias counts on sensitive mutations, apply rate limiting per resolved mutation invocation rather than per HTTP request, and adopt persisted operations (allowlisted query hashes) for first-party clients. With authorization enforced at the data boundary and execution cost bounded up front, GraphQL becomes an asset rather than a blind spot.