Repository navigation
fix(security): authenticate Cloudflare tests and restrict streaming proxies - #2413
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 077ce298a0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
jbeckwith-oai
left a comment
There was a problem hiding this comment.
[P2] Both streaming-proxy examples disable all authentication and browser-origin checks when listening on loopback. A cross-origin text/plain POST can therefore invoke the local billed model endpoint; response CORS restrictions do not prevent request execution or charges. Chrome now adds a local-network permission prompt, but this does not cover browsers without equivalent protection, approved permissions, or another loopback origin. Reject mismatched Origin or cross-site Fetch Metadata even on loopback, while continuing to allow tokenless local CLI requests that send no Origin. Add regressions for both Express and raw variants.
jbeckwith-oai
left a comment
There was a problem hiding this comment.
Re-reviewed all security boundaries. The previous loopback cross-origin issue is fixed with Origin and Fetch Metadata checks before parsing; remote binding now requires explicit opt-in, HTTPS, and constant-time authentication. Worker requests use bounded replay-resistant HMAC authentication, upload cleanup is covered, and loopback IPv4/IPv6 behavior is preserved. All prior findings are resolved and checks pass.
Security findings
csf_b2a30884d82a15bcf615d10b: the Cloudflare ecosystem worker allowed unauthenticated requests to trigger billed operations and leave five persistent uploaded files.csf_9c3fb2578837b982e013cf84: both chat-completion streaming examples exposed unauthenticated billed proxies on every network interface.Changes
POST /testrequests before importing the SDK or constructing a client.127.0.0.1by default. Require explicit remote opt-in and a strong bearer token validated in constant time before request-body parsing.Verification
npm test -- --runInBand tests/error-response.test.js tests/worker-security.test.js tests/streaming-example-security.test.js --testTimeout=15000— 32 tests passed.npm run tsc— both Cloudflare-worker TypeScript configurations passed.corepack pnpm exec tsc --noEmit --pretty falseandcorepack pnpm buildpassed.Compatibility and rollout
Changes are limited to the Cloudflare ecosystem fixture and the two owned examples; no generated SDK files, public SDK APIs, or shared ecosystem CLI were changed. The existing Cloudflare harness signs requests using its already-provisioned
OPENAI_API_KEY, so no new secret or cross-batch configuration is required. Non-loopback example binding now intentionally requires explicit opt-in plus bearer authentication.