OWasp GraphQL Cheat Sheet Flashcards
Real time AJAX security evaluation for learners based on content at https://cheatsheetseries.owasp.org/cheatsheets/GraphQL_Cheat_Sheet
Common Attacks
What types of injection attacks are common?
SQL/NoSQL injection, OS command injection, SSRF, CRLF injection, and request smuggling.
Common Attacks
What is an IDOR attack?
It’s abuse of broken authorization, granting improper or excessive access.
Common Attacks
What are GraphQL-specific attacks?
Batching attacks and abuse of insecure default configurations.
Input Validation
How does strict input validation help?
It prevents injection and DoS attacks by ensuring user input is safe before it’s used in HTTP requests, database queries, or other calls.
Input Validation
What should incoming data be validated against?
A strict allow-list of valid values, avoiding deny-lists.
Input Validation
How should invalid inputs be handled?
Gracefully reject them without revealing excessive information about API validation.
Injection Prevention
What tools should be used to handle input meant for other interpreters (e.g., SQL, OS)?
Libraries offering safe APIs like parameterized statements or ORM/ODM tools, used correctly.
Injection Prevention
What should be done if tools aren’t available?
Escape/encode input data using actively maintained libraries.
DoS Prevention
What measures can limit GraphQL DoS attacks?
Depth and amount limiting for queries.
Adding pagination to responses.
Enforcing timeouts at the application or infrastructure level.
Implementing query cost analysis.
DoS Prevention
What is the purpose of rate limiting?
To prevent a single user from spamming requests and degrading service performance.
DoS Prevention
How can server-side batching and caching help?
It prevents duplicate data requests within a short time frame, improving efficiency.
Query Limiting (Depth & Amount)
Why should query depth and amount be limited in GraphQL?
Unlimited depth or amounts can overwhelm the server, leading to DoS vulnerabilities.
Query Limiting (Depth & Amount)
How can query limiting be implemented in GraphQL?
Using tools like graphql-depth-limit for JavaScript or MaxQueryDepthInstrumentation for Java.
Timeouts
How do application-level timeouts help prevent DoS?
They limit the resources a single request can consume, stopping excessive queries mid-process.
Timeouts
Why are infrastructure timeouts less effective?
They can be bypassed more easily and may activate too late.
Rate Limiting
How can rate limiting be enforced?
Per IP or user basis, using a WAF, API gateway, or web server configuration like Nginx.
Server-Side Practices
Why should resources like CPU and memory be limited for APIs?
To prevent excessive resource consumption that could lead to DoS attacks.
Server-Side Practices
How can resource limits be enforced on Linux?
Use Control Groups (cgroups), User Limits (ulimits), and Linux Containers (LXC).
Access Control
How can a GraphQL API ensure proper access control?
Validate the requester’s authorization to view or modify data using mechanisms like RBAC.
Access Control
What issues are prevented by enforcing access control?
IDOR issues, including Broken Object Level Authorization (BOLA) and Broken Function Level Authorization (BFLA).
Access Control
Why should authorization checks be enforced on both edges and nodes?
To ensure all parts of the GraphQL schema are protected, preventing unauthorized access.
Access Control
How can structured data types improve access control?
Use Interfaces and Unions to return object properties based on requester permissions.
Access Control
What tools can be used to perform access control validation in resolvers?
Query and Mutation Resolvers, potentially integrated with RBAC middleware.
Access Control
What should be disabled in production environments?
Introspection queries, GraphiQL, and other schema exploration tools.