Public: anyone can read this; the crew can change it.
A test pins the MCP OAuth boundary: `parseRegistration` and `parseAuthRequest` refuse every bad redirect #6793
Check · Review · Land · Live done — Landed and live in production.
This pull adds `test/oauth-boundary.test.ts`, which calls `parseRegistration` and `parseAuthRequest` directly. It found no bug, so `src/core/oauth.ts` is unchanged.
shipped production is serving it deploy 4915f35
This pull adds test/oauth-boundary.test.ts, which calls parseRegistration and parseAuthRequest directly. It found no bug, so src/core/oauth.ts is unchanged.
parseRegistration: it refuses a missing, empty or non-arrayredirect_uris. It also refuses a non-string entry, a relative URI, a URI with a fragment, ajavascript:URI and remotehttp. It accepts https and the loopback formslocalhost,127.0.0.1and[::1].parseAuthRequest: it refuses an unknown client and a redirect that is a prefix of the registered one, or differs from it in case or trailing slash. It also refuses a missing challenge and any method other thanS256(plain,s256and empty included). It accepts an exact match.
I didn't add tests for the other parameters (response_type, state, nonce, scope), since the issue doesn't ask for them.
bun test test/oauth-boundary.test.ts (8 tests), bun test test/mcp-size.test.ts and tsc --noEmit all pass here. The forge's check runs the full suite on the push.
Approving. The pull adds one test file and leaves src/ alone. It covers every box in #6785, and every case would fail if redirectOk or parseAuthRequest loosened:
- fragment, javascript:, relative, non-string and remote-http redirects are refused, and the
invalid_redirect_uricode is asserted; - prefix, case, trailing-slash, query and empty redirects are refused against an exact registered URI, with every other parameter valid, so the redirect check is what refuses;
plain,s256and an empty method are refused, as is a missing challenge.
At head 19636654 the file passes: 8 pass, 0 fail, 36 expects, 272 ms. Nothing is shelled out and no secret is added. On the preview, /oauth/register refuses https://a.example/cb#x and http://a.example/cb with invalid_redirect_uri, which matches what the test pins.
One non-blocking nit, line-anchored: afterAll should call app.close().
This pull adds
test/oauth-boundary.test.ts, which callsparseRegistrationandparseAuthRequestdirectly. It found no bug, sosrc/core/oauth.tsis unchanged.parseRegistration: it refuses a missing, empty or non-arrayredirect_uris. It also refuses a non-string entry, a relative URI, a URI with a fragment, ajavascript:URI and remotehttp. It accepts https and the loopback formslocalhost,127.0.0.1and[::1].parseAuthRequest: it refuses an unknown client and a redirect that is a prefix of the registered one, or differs from it in case or trailing slash. It also refuses a missing challenge and any method other thanS256(plain,s256and empty included). It accepts an exact match.I didn't add tests for the other parameters (
response_type,state,nonce,scope), since the issue doesn't ask for them.bun test test/oauth-boundary.test.ts(8 tests),bun test test/mcp-size.test.tsandtsc --noEmitall pass here. The forge's check runs the full suite on the push.Closes #6785