Skip to content

fix(auth): sanitize malformed workload OAuth token responses - #2468

Open
HAYDEN-OAI wants to merge 11 commits into
mainfrom
codex/workload-oauth-json-privacy-20260825-1912-2d1be4ab
Open

fix(auth): sanitize malformed workload OAuth token responses#2468
HAYDEN-OAI wants to merge 11 commits into
mainfrom
codex/workload-oauth-json-privacy-20260825-1912-2d1be4ab

Conversation

@HAYDEN-OAI

Copy link
Copy Markdown
Contributor
  • I understand that this repository is auto-generated and my pull request may not be merged

Summary

  • Sanitize malformed JSON diagnostics only at the successful workload-identity OAuth token-exchange response boundary.
  • Recognize native and cross-realm syntax errors, nested parser failures, and supported node-fetch invalid-JSON wrappers without retaining sensitive response previews.
  • Preserve custom response parsers, non-parser transport and provider error identity, rejected OAuth responses, token caching, and concurrent refresh behavior.

Validation

  • Regression-first public coverage: 26 failing privacy cases and 18 passing compatibility controls before the fix; all 44 pass afterward.
  • Four focused authentication suites: 378 tests passed, including real loopback OAuth responses, public OpenAI client requests, malformed-wrapper variants, hostile error objects, recovery, and concurrency.
  • Complete handwritten suite: 146 suites and 6,231 tests passed with CI-mode snapshot updates disabled.
  • Generated API suite: 82 suites and 556 tests passed against an isolated authenticated Steady server.
  • Repository formatting, lint, and source TypeScript checks passed.
  • Full production build and generated-package TypeScript 4.9 plus current TypeScript checks passed.
  • Published-package lint and packed CommonJS/ESM verification passed, including 1,256 source maps.
  • Independently verified the actual built CommonJS and ESM OpenAI clients sanitize both native and supported wrapped OAuth parser failures.

@HAYDEN-OAI
HAYDEN-OAI requested a review from a team as a code owner August 25, 2026 19:13
@openai-sdks

openai-sdks Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 11.11s for Node SDK PR #2468.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 203ms
tests/chat-completions-create.test.ts ✅ Passed 249ms
tests/chat-completions-stream.test.ts ✅ Passed 211ms
tests/files-content-binary.test.ts ✅ Passed 175ms
tests/files-create-multipart.test.ts ✅ Passed 163ms
tests/files-list-pagination.test.ts ✅ Passed 151ms
tests/initialize-config.test.ts ✅ Passed 180ms
tests/instance-isolation.test.ts ✅ Passed 114ms
tests/models-list.test.ts ✅ Passed 144ms
tests/responses-background-lifecycle.test.ts ✅ Passed 220ms
tests/responses-body-method-errors.test.ts ✅ Passed 352ms
tests/responses-cancel-timeout.test.ts ✅ Passed 259ms
tests/responses-cancel.test.ts ✅ Passed 317ms
tests/responses-compact-retries.test.ts ✅ Passed 251ms
tests/responses-compact.test.ts ✅ Passed 281ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 195ms
tests/responses-create-advanced.test.ts ✅ Passed 253ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.089s
tests/responses-create-errors.test.ts ✅ Passed 257ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 204ms
tests/responses-create-retries.test.ts ✅ Passed 240ms
tests/responses-create-stream-failures.test.ts ✅ Passed 215ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 2.165s
tests/responses-create-stream-wire.test.ts ✅ Passed 2.524s
tests/responses-create-stream.test.ts ✅ Passed 128ms
tests/responses-create-terminal-states.test.ts ✅ Passed 295ms
tests/responses-create-timeout.test.ts ✅ Passed 345ms
tests/responses-create.test.ts ✅ Passed 230ms
tests/responses-delete.test.ts ✅ Passed 205ms
tests/responses-input-items-errors.test.ts ✅ Passed 189ms
tests/responses-input-items-list.test.ts ✅ Passed 181ms
tests/responses-input-items-options.test.ts ✅ Passed 109ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 307ms
tests/responses-input-tokens-count.test.ts ✅ Passed 323ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.164s
tests/responses-not-found-errors.test.ts ✅ Passed 330ms
tests/responses-parse.test.ts ✅ Passed 221ms
tests/responses-retrieve-retries.test.ts ✅ Passed 247ms
tests/responses-retrieve.test.ts ✅ Passed 289ms
tests/responses-stored-method-errors.test.ts ✅ Passed 691ms
tests/retry-behavior.test.ts ✅ Passed 3.062s
tests/sdk-error-shape.test.ts ✅ Passed 352ms

View OkTest run #32911765338

SDK merge (8a418d9ed2ff) · head (e4714480aff9) · base (c6769fa9b28b) · OkTest (2b1bdfd25e98)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-25T23:42:25.935055Z e471448 New commits
🔒 Security Review Completed 2026-08-25T23:42:45.731903Z e471448 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

32 mixed files remain; 0 existing customizations changed.

Compared c6769fa9b28be4714480aff9. Generated baselines verified.

32 existing customizations unchanged
  • api.md
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.py
  • src/client.ts
  • src/resources/audio/transcriptions.ts
  • src/resources/audio/translations.ts
  • src/resources/beta/assistants.ts
  • src/resources/beta/beta.ts
  • src/resources/beta/index.ts
  • src/resources/beta/responses/internal-base.ts
  • src/resources/beta/responses/responses.ts
  • src/resources/beta/threads/index.ts
  • src/resources/beta/threads/runs/index.ts
  • src/resources/beta/threads/runs/runs.ts
  • src/resources/beta/threads/threads.ts
  • src/resources/chat/completions/completions.ts
  • src/resources/chat/completions/index.ts
  • src/resources/conversations/index.ts
  • src/resources/embeddings.ts
  • src/resources/files.ts
  • src/resources/fine-tuning/checkpoints/permissions.ts
  • src/resources/images.ts
  • src/resources/responses/internal-base.ts
  • src/resources/responses/responses.ts
  • src/resources/skills/skills.ts
  • src/resources/skills/versions/versions.ts
  • src/resources/vector-stores/file-batches.ts
  • src/resources/vector-stores/files.ts
  • src/resources/webhooks/index.ts
  • src/resources/webhooks/webhooks.ts
  • tests/lib/data-residency.test.ts

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 32911799313 --repo openai/openai-node \
  --name castiron-custom-code-32911799313-1 --dir /tmp/castiron-custom-code-32911799313-1
git apply --stat /tmp/castiron-custom-code-32911799313-1/custom-code.patch
cat /tmp/castiron-custom-code-32911799313-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin c6769fa9b28bbc6f10be81e2f87e18655dfdd008 e4714480aff99139e4ce7c829ac9d1aa04978192
python3 scripts/castiron/custom_code_report.py report \
  --base c6769fa9b28bbc6f10be81e2f87e18655dfdd008 \
  --head e4714480aff99139e4ce7c829ac9d1aa04978192 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-e4714480aff9
cat /tmp/castiron-custom-code-e4714480aff9/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

@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: 2d1be4ab16

ℹ️ 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".

Comment thread src/auth/workload-identity-auth.ts Outdated

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

Requesting changes for the existing P2 discussion at src/auth/workload-identity-auth.ts:85. Object.assign(Object.create(Error.prototype), { type: 'invalid-json' }) and Object.create(SyntaxError.prototype) satisfy instanceof despite lacking the native Error internal brand. The new classifier consequently replaces supported custom Response.json transport/business rejections with a sanitized SyntaxError instead of preserving their original identity. Verify genuine native Error branding before classifying parser markers or cross-realm prototypes, and add regressions for forged Error and SyntaxError prototypes while retaining real malformed-response privacy. The existing inline discussion already captures the issue.

@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: 4a2bfa6f10

ℹ️ 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".

Comment thread src/auth/workload-identity-auth.ts Outdated
Comment thread src/auth/workload-identity-auth.ts Outdated
Comment thread src/auth/workload-identity-auth.ts Outdated

@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: b48a9e0caf

ℹ️ 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".

Comment thread src/auth/malformed-json-error.ts Outdated
Comment thread src/internal/auth/malformed-json-error.ts
Comment thread src/auth/malformed-json-error.ts Outdated
Comment thread src/auth/malformed-json-error.ts Outdated

@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: 57f372f661

ℹ️ 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".

Comment thread src/internal/auth/malformed-json-error.ts
Comment thread src/internal/auth/malformed-json-error.ts Outdated
Comment thread src/internal/auth/malformed-json-error.ts Outdated

@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: 89ffaf4c7e

ℹ️ 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".

Comment thread src/internal/auth/malformed-json-error.ts Outdated
Comment thread src/internal/auth/malformed-json-error.ts Outdated

@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: 34adfac4f9

ℹ️ 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".

Comment thread src/internal/auth/malformed-json-error.ts Outdated
Comment thread src/internal/auth/malformed-json-error.ts Outdated

@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: 05c6b2dac9

ℹ️ 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".

Comment thread src/internal/auth/malformed-json-error.ts Outdated
Comment thread src/internal/auth/malformed-json-error.ts Outdated
Comment thread src/internal/auth/malformed-json-error.ts
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

const name = getErrorDescriptor(error, 'name');
return name && 'value' in name && name.value === 'SyntaxError' && name.configurable
? 'native-syntax'

P2 Badge Preserve Errors whose name is assigned SyntaxError

When a custom Response.json() rejects an ordinary native Error after setting error.name = 'SyntaxError'—a common pattern for custom error classes—the resulting own property is configurable, so this branch classifies it as a native syntax error without checking the error’s actual kind. Checked on supported Bun 1.2.14: both auth paths replace this unrelated rejection with the sanitized SyntaxError, breaking the custom parser’s rejection identity; the existing spoofing regression misses this because Object.defineProperty creates a non-configurable property by default. Use the already captured native/structured classification rather than configurability alone.

AGENTS.md reference: AGENTS.md:L52-L57


? (nativeErrorBrandDescriptor.value.bind(Error) as ErrorBrand)

P2 Badge Reject polyfilled Error.isError before classifying rejections

In a browser or worker that installs an Error.isError polyfill before SDK import, this accepts that function solely because it is an own data property. A polyfill implemented with Object.prototype.toString therefore invokes an untrusted Symbol.toStringTag getter when a custom Response.json() rejects an error-shaped object; this was reproduced on Bun 1.2.14 by installing such a polyfill before importing the classifier. Fresh evidence beyond the earlier native-brand fix is that the final code validates structuredClone source and behavior but still treats any preinstalled Error.isError function as an intrinsic, allowing classification to execute hostile accessors; verify this brand function’s native semantics or avoid calling it on the rejection.

AGENTS.md reference: AGENTS.md:L98-L105

ℹ️ 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".

@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: 922ee814c9

ℹ️ 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".

Comment thread src/internal/auth/malformed-json-error.ts Outdated
Comment thread src/internal/auth/malformed-json-error.ts Outdated
Comment thread scripts/test-packed-package.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants