Skip to content

Add MaxSelectionSetSize option to prevent DDoS attacks#10

Merged
peterdeme merged 1 commit intomasterfrom
fix-recursion
Oct 15, 2025
Merged

Add MaxSelectionSetSize option to prevent DDoS attacks#10
peterdeme merged 1 commit intomasterfrom
fix-recursion

Conversation

@peterdeme
Copy link
Copy Markdown

Fixes a critical DDoS vulnerability where queries with thousands of
fields at the same level cause CPU overload due to O(n²) validation
complexity.

Changes:

  • Add MaxSelectionSetSize configuration option (default: 0/disabled)
  • Validate selection set size before expensive overlap checks
  • Reject malicious queries in ~1ms vs 30+ second timeout
  • Add comprehensive test suite for vulnerability and fix
  • Add GitHub Actions workflow for CI/CD

The fix is backward compatible and opt-in. Recommended values: 100-1000
depending on schema complexity.

Example usage:
schema := graphql.MustParseSchema(schemaString, resolver, graphql.MaxSelectionSetSize(100))

@peterdeme peterdeme requested review from WSpacelifT and b4k3r October 15, 2025 14:05
Comment thread .github/workflows/test.yml Fixed
  Fixes a critical DDoS vulnerability where queries with thousands of
  fields at the same level cause CPU overload due to O(n²) validation
  complexity.

  Changes:
  - Add MaxSelectionSetSize configuration option (default: 0/disabled)
  - Validate selection set size before expensive overlap checks
  - Reject malicious queries in ~1ms vs 30+ second timeout
  - Add comprehensive test suite for vulnerability and fix
  - Add GitHub Actions workflow for CI/CD

  The fix is backward compatible and opt-in. Recommended values: 100-1000
  depending on schema complexity.

  Example usage:
    schema := graphql.MustParseSchema(schemaString, resolver,
        graphql.MaxSelectionSetSize(100))

Signed-off-by: peterdeme <[email protected]>
@peterdeme peterdeme merged commit d028a05 into master Oct 15, 2025
5 checks passed
@peterdeme peterdeme deleted the fix-recursion branch October 15, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants