Summary
Keystone's GraphQL findMany resolver can accept a negative take value whose magnitude exceeds the configured record limit. An unauthenticated client may use this behavior to retrieve more records than intended, including through relationship queries, potentially exhausting service resources.
Affected context
The issue occurs in Keystone deployments that expose the GraphQL findMany resolver and rely on graphql.maxTake to limit result sizes. It is relevant when client-supplied take values, including negative values, are compared without normalizing their sign or validating their effective magnitude before query execution. Relationship queries may be subject to the same behavior.
Exploit preconditions
- Attack surface: Publicly reachable GraphQL API - Required access: No authentication may be required when the affected query
is exposed anonymously
- Trigger point: Processing a client-controlled take argument in the findMany
resolver or a relationship query
- Why exploitation is possible: The resolver compares the signed value
directly with the configured maximum, allowing a negative value whose
magnitude exceeds the intended bound
Why this happens
The underlying bug is improper validation of a signed numeric input. The resolver treats a comparison against the configured maximum as sufficient validation without enforcing the expected non-negative domain or checking the absolute effective result size. This reflects CWE-20, Improper Input Validation, and is also related to CWE-480 where an inappropriate operation or comparison contributes to the security decision.
Potential impact
- An attacker may retrieve more records than application developers intended.
- A client could cause excessive database work or response generation.
- Service availability may be degraded through resource exhaustion.
- Relationship queries could amplify query cost across connected records.
- Large responses could increase memory, bandwidth, and downstream processing demands.
General mitigation guidance
Mitigation generally focuses on validating pagination inputs according to a strict numeric schema before query construction. Secure-by-default patterns include accepting only non-negative integer values, applying limits to the effective result size rather than relying on signed comparisons, and enforcing equivalent bounds for relationship queries. Input trust can be reduced by using server-controlled pagination caps, bounded defaults, query-cost limits, response-size controls, and rate limiting. Least-privilege database permissions and resource quotas can further limit the consequences of expensive queries.
How teams detect issues like this
Detection approaches include static analysis and code review checks for comparisons of signed pagination values without domain or magnitude validation. Reviewers can look for negative-value handling, inconsistent limits between top-level and relationship resolvers, unbounded query construction, and missing query-cost controls. Dynamic testing can exercise boundary, negative, oversized, and nested relationship inputs while monitoring database load, response size, and request latency. GraphQL policy enforcement and automated security review tools can help identify these patterns.

