OWasp GraphQL Cheat Sheet Flashcards

Real time AJAX security evaluation for learners based on content at https://cheatsheetseries.owasp.org/cheatsheets/GraphQL_Cheat_Sheet

1
Q

Common Attacks

What types of injection attacks are common?

A

SQL/NoSQL injection, OS command injection, SSRF, CRLF injection, and request smuggling.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Common Attacks

What is an IDOR attack?

A

It’s abuse of broken authorization, granting improper or excessive access.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Common Attacks

What are GraphQL-specific attacks?

A

Batching attacks and abuse of insecure default configurations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Input Validation

How does strict input validation help?

A

It prevents injection and DoS attacks by ensuring user input is safe before it’s used in HTTP requests, database queries, or other calls.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Input Validation

What should incoming data be validated against?

A

A strict allow-list of valid values, avoiding deny-lists.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Input Validation

How should invalid inputs be handled?

A

Gracefully reject them without revealing excessive information about API validation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Injection Prevention

What tools should be used to handle input meant for other interpreters (e.g., SQL, OS)?

A

Libraries offering safe APIs like parameterized statements or ORM/ODM tools, used correctly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Injection Prevention

What should be done if tools aren’t available?

A

Escape/encode input data using actively maintained libraries.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

DoS Prevention

What measures can limit GraphQL DoS attacks?

A

Depth and amount limiting for queries.

Adding pagination to responses.
Enforcing timeouts at the application or infrastructure level.
Implementing query cost analysis.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

DoS Prevention

What is the purpose of rate limiting?

A

To prevent a single user from spamming requests and degrading service performance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

DoS Prevention

How can server-side batching and caching help?

A

It prevents duplicate data requests within a short time frame, improving efficiency.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Query Limiting (Depth & Amount)

Why should query depth and amount be limited in GraphQL?

A

Unlimited depth or amounts can overwhelm the server, leading to DoS vulnerabilities.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Query Limiting (Depth & Amount)

How can query limiting be implemented in GraphQL?

A

Using tools like graphql-depth-limit for JavaScript or MaxQueryDepthInstrumentation for Java.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Timeouts

How do application-level timeouts help prevent DoS?

A

They limit the resources a single request can consume, stopping excessive queries mid-process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Timeouts

Why are infrastructure timeouts less effective?

A

They can be bypassed more easily and may activate too late.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Rate Limiting

How can rate limiting be enforced?

A

Per IP or user basis, using a WAF, API gateway, or web server configuration like Nginx.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Server-Side Practices

Why should resources like CPU and memory be limited for APIs?

A

To prevent excessive resource consumption that could lead to DoS attacks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Server-Side Practices

How can resource limits be enforced on Linux?

A

Use Control Groups (cgroups), User Limits (ulimits), and Linux Containers (LXC).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Access Control

How can a GraphQL API ensure proper access control?

A

Validate the requester’s authorization to view or modify data using mechanisms like RBAC.

20
Q

Access Control

What issues are prevented by enforcing access control?

A

IDOR issues, including Broken Object Level Authorization (BOLA) and Broken Function Level Authorization (BFLA).

21
Q

Access Control

Why should authorization checks be enforced on both edges and nodes?

A

To ensure all parts of the GraphQL schema are protected, preventing unauthorized access.

22
Q

Access Control

How can structured data types improve access control?

A

Use Interfaces and Unions to return object properties based on requester permissions.

23
Q

Access Control

What tools can be used to perform access control validation in resolvers?

A

Query and Mutation Resolvers, potentially integrated with RBAC middleware.

24
Q

Access Control

What should be disabled in production environments?

A

Introspection queries, GraphiQL, and other schema exploration tools.

25
Q

General Data Access

What mistake leads to Broken Object Level Authentication (IDOR)?

A

Assuming possession of an object’s ID means the caller has access to that object without proper verification.

26
Q

General Data Access

How can accidental access via node or nodes fields in GraphQL be prevented?

A

Check the schema for these fields and remove them if unintended, while applying authorization checks.

27
Q

Query Access (Data Fetching)

How can access to specific data fields be restricted?

A

Add checks to validate that the requester is authorized to fetch specific fields.

28
Q

Mutation Access (Data Manipulation)

Why is mutation access control important?

A

It ensures only authorized requesters can modify data or specific fields within the API.

29
Q

Mutation Access (Data Manipulation)

When is mutation access control especially necessary?

A

For APIs where only read access is intended or where modification rights are limited to specific parties.

30
Q

Batching Attacks

What is a batching attack in GraphQL?

A

A brute force attack that exploits GraphQL’s ability to batch multiple queries or object requests in a single network call, making exploits faster and less detectable.

31
Q

Batching Attacks

How does batching enable enumeration?

A

Callers can request multiple objects (e.g., droids) in one request, enabling object enumeration with fewer network calls compared to REST APIs.

32
Q

Batching Attacks

What are potential issues caused by batching attacks?

A

Application-level DoS from excessive queries or requests.
Enumeration of sensitive objects (users, emails, IDs).
Brute-forcing passwords, OTPs, tokens, or other sensitive data.
Bypassing rate limits and security tools like WAFs or IDS/IPS.

33
Q

Mitigating Batching Attacks

What are the main strategies to mitigate batching attacks?

A

Add object request rate limiting in code.
Prevent batching for sensitive objects.
Limit the number of queries that can run in one batch.

34
Q

Mitigating Batching Attacks

How can rate limiting help against batching attacks?

A

By tracking the number of object requests from a caller and blocking excessive requests, even within a single network call.

35
Q

Mitigating Batching Attacks

Why disable batching for sensitive objects?

A

To force attackers to make individual network calls, enabling standard controls like rate limiting to function effectively.

36
Q

Mitigating Batching Attacks

What is the purpose of limiting query operations in batching?

A

To reduce the risk of excessive queries and enhance overall security.

37
Q

Secure Configurations

What should GraphQL APIs in production avoid returning?

A

Excessive error messages, such as stack traces, and they should not be in debug mode.

38
Q

Secure Configurations

How can excessive errors be disabled in Apollo Server?

A

Pass debug: false to the Apollo Server constructor or set the NODE_ENV variable to ‘production’ or ‘test.’

39
Q

Introspection and GraphiQL

Why should introspection and GraphiQL be disabled or restricted?

A

By default, these features allow consumers to learn details about your API, including schemas, mutations, and even private fields.

40
Q

Introspection and GraphiQL

When might disabling introspection be appropriate?

A

For internal APIs or when unauthorized users should not access API details.

41
Q

Introspection and GraphiQL

How can introspection be disabled in Java?

A

Use NoIntrospectionGraphqlFieldVisibility in the GraphQLSchema configuration.

42
Q

Introspection and GraphiQL

How can introspection and GraphiQL be disabled in JavaScript?

A

Use middleware with validation rules like NoIntrospection and disable GraphiQL in production.

43
Q

Mis-Typed Fields

Why disable field name suggestion if introspection is disabled?

A

It decreases exposure by preventing attackers from guessing field names.

44
Q

Tools

What is InQL Scanner?

A

A security scanner for GraphQL that can generate queries and mutations automatically from a given schema and feed them to the scanner.

45
Q

Tools

What is GraphiQL?

A

A tool for schema and object exploration in GraphQL environments.

46
Q

Tools

What is GraphQL Voyager?

A

Another tool for schema and object exploration, providing a visual overview of GraphQL schemas.