Skip to content

fix(security): authenticate Cloudflare tests and restrict streaming proxies - #2413

Merged
HAYDEN-OAI merged 3 commits into
mainfrom
codex/batch6-worker-stream-security
Aug 19, 2026
Merged

HAYDEN-OAI merged 3 commits into
mainfrom
codex/batch6-worker-stream-security

Conversation

@HAYDEN-OAI

Copy link
Copy Markdown
Contributor

Security findings

  • HIGH csf_b2a30884d82a15bcf615d10b: the Cloudflare ecosystem worker allowed unauthenticated requests to trigger billed operations and leave five persistent uploaded files.
  • MEDIUM csf_9c3fb2578837b982e013cf84: both chat-completion streaming examples exposed unauthenticated billed proxies on every network interface.

Changes

  • Disable public Workers.dev and preview URLs; accept only nonce-bound, short-lived HMAC-signed POST /test requests before importing the SDK or constructing a client.
  • Reject tampered, expired, replayed, and future-window-replayed signatures; bound per-isolate concurrency and always delete all five uploaded files, including assertion failures.
  • Bind both streaming examples to 127.0.0.1 by default. Require explicit remote opt-in and a strong bearer token validated in constant time before request-body parsing.
  • Add focused authorization, replay, concurrency, cleanup, localhost binding, remote authentication, and sanitized-error regressions.

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 false and corepack pnpm build passed.
  • Scoped Oxlint/format checks and a Wrangler deployment dry run passed.
  • The streaming regressions demonstrated 16 failing cases before the fix.

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.

@HAYDEN-OAI
HAYDEN-OAI requested a review from a team as a code owner August 18, 2026 23:39
@openai-sdks

openai-sdks Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

OkTest Summary

✅ 237/237 SDK tests passed in 10.331s for Node SDK PR #2413.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 144ms
tests/chat-completions-create.test.ts ✅ Passed 213ms
tests/chat-completions-stream.test.ts ✅ Passed 210ms
tests/files-content-binary.test.ts ✅ Passed 163ms
tests/files-create-multipart.test.ts ✅ Passed 135ms
tests/files-list-pagination.test.ts ✅ Passed 156ms
tests/initialize-config.test.ts ✅ Passed 163ms
tests/instance-isolation.test.ts ✅ Passed 127ms
tests/models-list.test.ts ✅ Passed 135ms
tests/responses-background-lifecycle.test.ts ✅ Passed 248ms
tests/responses-body-method-errors.test.ts ✅ Passed 340ms
tests/responses-cancel-timeout.test.ts ✅ Passed 204ms
tests/responses-cancel.test.ts ✅ Passed 186ms
tests/responses-compact-retries.test.ts ✅ Passed 274ms
tests/responses-compact.test.ts ✅ Passed 224ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 117ms
tests/responses-create-advanced.test.ts ✅ Passed 195ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.212s
tests/responses-create-errors.test.ts ✅ Passed 201ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 141ms
tests/responses-create-retries.test.ts ✅ Passed 278ms
tests/responses-create-stream-failures.test.ts ✅ Passed 212ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 2.163s
tests/responses-create-stream-wire.test.ts ✅ Passed 2.527s
tests/responses-create-stream.test.ts ✅ Passed 102ms
tests/responses-create-terminal-states.test.ts ✅ Passed 224ms
tests/responses-create-timeout.test.ts ✅ Passed 254ms
tests/responses-create.test.ts ✅ Passed 144ms
tests/responses-delete.test.ts ✅ Passed 269ms
tests/responses-input-items-errors.test.ts ✅ Passed 246ms
tests/responses-input-items-list.test.ts ✅ Passed 174ms
tests/responses-input-items-options.test.ts ✅ Passed 109ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 273ms
tests/responses-input-tokens-count.test.ts ✅ Passed 202ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.212s
tests/responses-not-found-errors.test.ts ✅ Passed 269ms
tests/responses-parse.test.ts ✅ Passed 199ms
tests/responses-retrieve-retries.test.ts ✅ Passed 268ms
tests/responses-retrieve.test.ts ✅ Passed 209ms
tests/responses-stored-method-errors.test.ts ✅ Passed 453ms
tests/retry-behavior.test.ts ✅ Passed 2.885s
tests/sdk-error-shape.test.ts ✅ Passed 259ms

View OkTest run #32201256124

SDK merge (7f9ed54b521e) · head (969cc6417518) · base (b7a0bd6144ed) · OkTest (7e7850017529)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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 jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[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 jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@HAYDEN-OAI
HAYDEN-OAI added this pull request to the merge queue Aug 19, 2026
Merged via the queue into main with commit 9286fdb Aug 19, 2026
29 checks passed
@HAYDEN-OAI
HAYDEN-OAI deleted the codex/batch6-worker-stream-security branch August 19, 2026 16:28
@openai-sdks openai-sdks Bot mentioned this pull request Aug 19, 2026
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.

2 participants