๐ Executive Threat Summary
detailsdetailssummary.quiz-card { background: #131d31; border: 1px dashed #38bdf8; border-radius: 8px; padding: 14px; margin-top: 8px; } .quiz-q { font-weight: 600; color: #f1f5f9; margin-bottom: 10px; font-size: 13.5px; } .quiz-opt { padding: 6px 10px; margin: 4px 0; background: #1e293b; border-radius: 4px; color: #cbd5e1; font-size: 13px; } .answer-box { margin-top: 10px; padding: 10px; background: rgba(16, 185, 129, 0.15); border-left: 3px solid #10b981; border-radius: 4px; color: #6ee7b7; font-size: 13px; } ๐ก๏ธ GraphQL Security: Introspection Attacks, Query Depth, and Batching Abuse Web Hacking & Pentesting Intermediate โฑ๏ธ 13 Mins Read ๐ฏ Executive Briefing & Core Concept GraphQL is a query language for APIs that gives clients the power to request exactly the data they need. Unlike REST, GraphQL operates via a single endpoint (typically '/graphql'). Leaving schema introspection enabled or failing to enforce query depth limits exposes internal schemas and causes denial of service. ๐ง Technical Deep-Dive & Architecture GraphQL includes a built-in introspection system ('__schema', '__type') designed for development tooling. In production, an attacker can query the full schema, instantly exposing all hidden types, mutations, relationships, and administrative fields. Furthermore, circular nested queries (e.g. author -> posts -> author -> posts) can overwhelm database resources (Query Depth Abuse). ๐ ๏ธ Hands-On Step-by-Step Lab Walkthrough Step 1: Identify GraphQL endpoints: Probe /graphql, /api/graphql, or /v1/altairStep 2: Test if Introspection is enabled: Send {"query":"{__schema{types{name}}}"}Step 3: Extract full schema using GraphQL Voyager or InQL extension.Step 4: Inspect extracted mutations for hidden admin functions: mutation { deleteUser(id: 1) }Step 5: Test Query Depth Denial of Service: Submit a 20-level deeply nested query.Step 6: Test Batching Abuse: Submit an array of 500 password guesses in a single HTTP request to bypass rate limiting. CLI SIMULATION - TERMINAL OUTPUT $ curl -s -X POST 'https://target.lab/graphql' -H 'Content-Type: application/json' -d '{"query":"{__schema{queryType{name,fields{name}}}}"}' | jq . { "data": { "__schema": { "queryType": { "name": "Query", "fields": [ {"name": "allUsers"}, {"name": "internalSecrets"}, {"name": "exportAuditLog"} ] } } } } ๐จ Real-World Incident Case Study Historical Impact & Analysis: A bug bounty audit of an online banking app uncovered an enabled GraphQL introspection query that revealed an undocumented 'updateAccountBalance' mutation, allowing authorized testers to demonstrate complete account manipulation. ๐ก๏ธ Enterprise Defense & Hardening Rules Disable GraphQL schema introspection in production environments. Enforce Query Depth Limiting (e.g., max depth of 5) and Query Complexity Analysis. Restrict query batching thresholds to prevent brute-force amplification. ๐งช Interactive Knowledge Check (Quiz) Question: What built-in GraphQL feature exposes the complete API schema, including all types, queries, and mutations? A: Schema Introspection (__schema) B: GraphQL Tracer C: Apollo Engine D: REST Bridge ๐ Click to Reveal Answer & Detailed Analysis Correct Option: (A) GraphQL Introspection allows clients to query the schema itself using special meta-fields like '__schema'. โก Terminal Challenge / Practical Exercise Lab Objective: Write a simple GraphQL query that tests whether an endpoint has circular relationship depth limits enabled.
๐ป Diagnostic CLI Verification (Termux / Linux)
Inspect and audit related indicators of compromise:
๐ก๏ธ Defensive Takeaways & Action Plan
Audit endpoint telemetry, restrict unauthorized remote access agents, enforce principle of least privilege, and deploy timely security patches.