agentleFS
ashrafiucseashrafiucse/security-audit-skills/skills/graphql-security/SKILL.md

graphql-security

Skill2 starsChanged 49 days agoMITView on GitHub

Audits GraphQL APIs for security misconfiguration and abuse — introspection/GraphiQL/playground exposed in production, missing query depth and complexity limits, resolver-level authorization gaps and IDOR, error/stacktrace/field-suggestion leakage, query-batching abuse, CSRF with cookie auth, and unbounded custom scalars. Covers Apollo, graphql-yoga, express-graphql, graphql-js, graphene/strawberry/ariadne, gqlgen, Hasura. Use when the project has a GraphQL server, .graphql schema files, or GraphQL dependencies.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Default pagination first/last unbounded (allUsers returns everything) → Medium

    line 58

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

GraphQL Security

Step 0 — Detect the stack

rg --files -g '*.graphql' -g '*.graphqls' | head
rg -n "apollo-server|@apollo/server|graphql-yoga|express-graphql|mercurius|graphene|strawberry-graphql|ariadne|gqlgen|hasura" -g 'package.json' -g 'requirements*.txt' -g 'pyproject.toml' -g '*.go' -g 'docker-compose*.yml' | head

Record: server library + version, whether schema is code-first or SDL, where resolvers live, how auth reaches context (header token vs session cookie).

Step 1 — Server configuration checks

Per-framework config locations: references/frameworks.md. Checks and default severities (adjust with context):

CheckFinding if present/absentSeverity
Introspection enabled in prod configfull attack-surface disclosureMedium (High if admin/internal types visible)
GraphiQL / Playground / Apollo Sandbox reachable in prodinteractive query console for attackersMedium
No query depth or complexity limitnested-query DoS ({a{b{c{...}}}} bombs)High
formatError returns originalError/stacktrace; Apollo includeStacktraceInErrorResponses/debug oninternal error leakageMedium
Field suggestions not masked in prod ("Did you mean..." hints)schema oracle for attackersLow/Medium
Query batching enabled unbounded (shouldBatch, array bodies)auth-brute-force in one requestMedium
Aliasing amplification — no cost/depth limit while the schema allows repeated aliases ({a: user(id:1) b: user(id:2) ...} x N in one query)batching DoS + brute-force vector bypassing rate limitsMedium/High
Cookie-session auth + no CSRF protection (Apollo v4 csrfPrevention: false/absent)cross-site mutation executionHigh
Mutations accepted over GET (express-graphql)CSRF + logging of creds in URLsHigh
No persisted operations / allowlist for public clientsarbitrary query craftingLow (note)

Step 2 — Resolver authorization (the #1 GraphQL bug source)

rg -n "Query:|Mutation:|Subscription:|resolve\(|fieldResolver|@auth|@hasRole|context\.user|ctx\.user" --type js --type ts --type py --type go | head -40

For every resolver returning or mutating objects:

  • Field-level authz missing: User.passwordHash, User.email, admin/internal types returned to unauthenticated callers → HIGH (CRITICAL for credentials/PII)
  • IDOR: user(id) resolved without ownership/scope check → same class as REST IDOR, HIGH
  • Subscription auth: subscribe handlers skipping auth → Medium/High
  • Trust of client args: role, isAdmin, price, userId taken from args without server-side derivation → HIGH

Step 3 — Schema & input review

rg -n -i "admin|secret|token|impersonate|delete|export|password" -g '*.graphql' -g '*.graphqls' | head -30
  • Sensitive-named types/mutations without a guard (directive or resolver check) → flag per Step 2
  • Custom scalars without validation (unbounded Int/String into loops/DB LIMIT) → Medium
  • Login/reset/signup mutations without rate limiting (GraphQL bypasses REST limiters!) → High
  • Default pagination first/last unbounded (allUsers returns everything) → Medium

Reporting

Evidence = config lines + resolver code + schema lines. Fixes are one-liners in most frameworks — give the exact snippet from references/frameworks.md (introspection: false, validationRules: [depthLimit(10)], csrfPrevention: true, masked formatError). Note positives (allowlists, persisted queries, field-level directives).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.