fix(oauth-proxy): cap the register endpoint's body size - #6974
Open
pedrofrxncx wants to merge 1 commit into
Open
fix(oauth-proxy): cap the register endpoint's body size#6974pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
The /oauth-proxy/:connectionId/register branch added in #6972/#6973 reads c.req.json() on an unauthenticated route before any auth check, with no size limit. Every other unauthenticated body-reading route in this repo (jira-webhook, trigger-callback, github-webhook, stripe-webhook, kv, sandbox-proxy, org-fs) caps its body with hono's bodyLimit middleware; this one didn't get one. Adds a shared oauthProxyBodyLimit (1MB, 413 on overflow) and mounts it on both the legacy /oauth-proxy and canonical /api/:org/oauth-proxy routes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows #6972/#6973 (serve DCR from a connection's pre-registered client, then echo the requester's metadata back). That new branch of
oauthProxyHandlercallsc.req.json()on the unauthenticated/oauth-proxy/:connectionId/registerroute — before any auth or ownership check — with no cap on the body it parses.Every other unauthenticated/webhook-style body-reading route in this repo (jira-webhook, trigger-callback, github-webhook, stripe-webhook, kv, sandbox-proxy, org-fs) already wraps its parse in hono's
bodyLimitmiddleware; this new route didn't get one, so anyone who knows (or brute-forces) aconnectionIdcan force repeated large-body JSON parses with no auth.Fix: added a shared
oauthProxyBodyLimit(1MB cap, 413 on overflow) exported fromoauth-proxy.tsand mounted on both the legacy/oauth-proxy/:connectionId/*and canonical/api/:org/oauth-proxy/:connectionId/*routes, matching the existing pattern.Regression test:
oauth-proxy.integration.test.ts— "rejects an oversized register body with 413 before parsing it", posting a >1MB JSON body to/registerand asserting a 413.To verify:
bun test apps/api/src/api/routes/oauth-proxy.integration.test.ts(needs a real Postgres — CI has one; this sandbox doesn't, so I verified viabunx tsc --noEmit(clean) andbunx oxlinton the 4 changed files (0 warnings/errors) instead).Locally ran:
bun run fmt,apps/apibunx tsc --noEmit,bunx oxlinton the changed files. Full CI (including this integration test against real Postgres) validates the rest.Summary by cubic
Caps the request body size on the oauth-proxy register endpoint so unauthenticated callers can't force large JSON parses. The route now rejects bodies over 1MB with a 413, matching the pattern used by other unauthenticated body-reading routes. The limit applies to both the legacy
/oauth-proxy/:connectionId/*and canonical/api/:org/oauth-proxy/:connectionId/*routes. Adds a regression test for the 413 response.Written for commit 44fde03. Summary will update on new commits.