Skip to content

fix: Harden GitHub webhook endpoint against large-body DoS and unauthenticated flood traffic - #197

Merged
JSONbored merged 4 commits into
JSONbored:mainfrom
jonathanchang31:fix/unauthenticated-github-webhook
Jun 1, 2026
Merged

fix: Harden GitHub webhook endpoint against large-body DoS and unauthenticated flood traffic#197
JSONbored merged 4 commits into
JSONbored:mainfrom
jonathanchang31:fix/unauthenticated-github-webhook

Conversation

@jonathanchang31

Copy link
Copy Markdown
Contributor

Summary

This change fixes issue #196 by protecting /v1/github/webhook with:

  • Strict webhook rate limiting
  • Request body size limits with 413 Payload Too Large
  • Bounded body reading to prevent unbounded memory/CPU work before signature rejection

The endpoint now rejects abusive webhook traffic earlier and more predictably while preserving normal signed webhook behavior.

Related Issue

Fixes: #196

Change Type

  • Bug fix
  • Security hardening
  • API behavior change (error handling for oversized payloads)
  • Tests added/updated
  • Breaking change

Real Behavior Proof

1) Oversized payload is rejected

Request: 50MB body to /v1/github/webhook
Observed:

  • HTTP 413
  • Response: {"error":"payload_too_large","maxBytes":1048576}

2) Flood traffic is throttled

Repeated invalid-signature webhook requests observed:

  • Initial responses: 401 Unauthorized
  • After strict threshold: 429 Too Many Requests

3) Service remains healthy

GET /health returned 200 OK during/after webhook abuse replay.

Security Impact

  • Reduces unauthenticated resource-exhaustion risk on public webhook endpoint.
  • Prevents large request bodies from being fully processed before rejection.
  • Adds deterministic throttling for abusive repeated webhook traffic.

Checklist

  • Reproduced issue locally
  • Implemented fix in runtime code
  • Added/updated automated tests
  • Verified behavior with live local worker
  • Confirmed health endpoint stability during abuse replay
  • No unrelated code changes

@jonathanchang31
jonathanchang31 force-pushed the fix/unauthenticated-github-webhook branch from d696d68 to 223d3a6 Compare June 1, 2026 17:18
@jonathanchang31

Copy link
Copy Markdown
Contributor Author

@JSONbored Could you review my PR?

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathanchang31 This is ready from my side. This is the earlier viable webhook hardening PR, current checks are green, and the merge tree is clean.

A few notes:

  • It covers webhook body-size limits plus stricter webhook rate-limit handling.
  • Integration and webhook unit tests cover the protected paths.
  • Under the duplicate-submission policy, this should be preferred over the later overlapping webhook-body-only PR unless a specific superseding reason is identified.

@dosubot dosubot Bot added the lgtm label Jun 1, 2026
@JSONbored
JSONbored merged commit add8fe0 into JSONbored:main Jun 1, 2026
3 checks passed
@JSONbored JSONbored added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jun 10, 2026
loopover-orb Bot added a commit that referenced this pull request Jul 26, 2026
…8940)

handleGitHubWebhook rejects an oversized request via a content-length header check (413 fast-path)
before touching the body (#197). handleOrbRelay, processing the identical GitHub payload shape, went
straight to readBodyWithLimit — enforcing the cap only after buffering up to it. Add the same
content-length pre-check so an oversized relay request is rejected at the header stage, matching
handleGitHubWebhook's DoS-hardening pattern exactly.

Closes #8888

Co-authored-by: RealDiligent <brave.challenge007@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: loopover-orb[bot] <296761690+loopover-orb[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Unauthenticated GitHub Webhook DoS via Large Request Bodies

2 participants