Skip to content

fix(oauth-proxy): cap the register endpoint's body size - #6974

Open
pedrofrxncx wants to merge 1 commit into
mainfrom
fix/oauth-proxy-register-body-limit-w1
Open

fix(oauth-proxy): cap the register endpoint's body size#6974
pedrofrxncx wants to merge 1 commit into
mainfrom
fix/oauth-proxy-register-body-limit-w1

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Follows #6972/#6973 (serve DCR from a connection's pre-registered client, then echo the requester's metadata back). That new branch of oauthProxyHandler calls c.req.json() on the unauthenticated /oauth-proxy/:connectionId/register route — 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 bodyLimit middleware; this new route didn't get one, so anyone who knows (or brute-forces) a connectionId can force repeated large-body JSON parses with no auth.

Fix: added a shared oauthProxyBodyLimit (1MB cap, 413 on overflow) exported from oauth-proxy.ts and 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 /register and 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 via bunx tsc --noEmit (clean) and bunx oxlint on the 4 changed files (0 warnings/errors) instead).

Locally ran: bun run fmt, apps/api bunx tsc --noEmit, bunx oxlint on 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.

Review in cubic

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.
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.

1 participant