What are the security vulnerabilities specific to GraphQL?
Answer
GraphQL introduces unique security risks: (1) Introspection abuse: attackers enumerate the full schema. Mitigation: disable introspection in production, or use allow-listing. (2) Denial of Service via complex queries: deeply nested or expensive queries overwhelm the server. Mitigation: query depth limiting, complexity analysis, timeout, query size limit. (3) Batching attacks: send many operations in one request. Mitigation: limit operation count per request. (4) Field suggestion exploitation: error messages suggest similar field names, aiding schema discovery. Mitigation: disable field suggestions in production. (5) SQL/NoSQL injection: via args passed unsanitized to databases. Mitigation: use parameterized queries/ORM. (6) Authorization bypass: accessing fields or data without proper resolver-level auth checks. Mitigation: check auth in every resolver or use shield/directives. (7) Mass assignment: input types accepting too many fields. Mitigation: validate and whitelist input fields. Tools: graphql-armor adds multiple protections in one package.
Previous
How do you implement entity resolution in Apollo Federation?
Next
How does the GraphQL query planning and execution pipeline work?
More GraphQL Questions
View all →- Advanced What is Apollo Federation v2 and how does the supergraph work?
- Advanced How do you implement entity resolution in Apollo Federation?
- Advanced How does the GraphQL query planning and execution pipeline work?
- Advanced What is the @defer and @stream directive and how do they work?
- Advanced How do you design a scalable GraphQL schema?