Skip to content

fix(security): stop delayed and additional tool callbacks after cancellation - #2430

Open
HAYDEN-OAI wants to merge 2 commits into
mainfrom
autoimprove/runtools-cancelled-callbacks-20260820-0311-856743
Open

fix(security): stop delayed and additional tool callbacks after cancellation#2430
HAYDEN-OAI wants to merge 2 commits into
mainfrom
autoimprove/runtools-cancelled-callbacks-20260820-0311-856743

Conversation

@HAYDEN-OAI

Copy link
Copy Markdown
Contributor

Summary

  • Prevent chat.completions.runTools() from starting a privileged parsed tool callback after cancellation occurs during asynchronous argument parsing.
  • Prevent cancellation from starting the next sequential or later parallel tool callback, for both non-streaming and streaming runners and both external abort signals and runner.abort().
  • Surface the existing public APIUserAbortError, wait for callbacks that were already running, and retain results/messages for callbacks that began before cancellation.
  • Preserve the SDK's documented completed-buffered-turn compatibility contract: when a completed response is already buffered as cancellation becomes visible, its first immediate, non-parsing callback may still run. This exception is consumed once, never permits an asynchronously parsed callback, and never permits a second callback.

Regression-first proof

Before the change, the new real-public-client suite produced 10 failing security cases and 6 passing compatibility controls: synthetic privileged transfer callbacks ran with the runner signal already aborted. The final 20-case suite covers non-streaming and streaming public clients, external abort signals and direct runner cancellation, delayed parsers, sequential callbacks, in-flight parallel callback completion, one-shot buffered-turn compatibility, context, parser feedback, and afterCompletion.

Verification

  • Focused public runner coverage: 58 tests passed (20 new security/compatibility cases plus all 38 existing runner cases).
  • Complete handwritten suite: 127 files / 4,064 tests passed.
  • Complete generated suite against an isolated private-port Steady server: 82 suites / 559 tests passed.
  • Repository formatting and all 415 lint rules passed.
  • Strict source TypeScript checking and the complete CJS/ESM package build passed.
  • Published-source type checking passed with TypeScript 4.9 and TypeScript 6.
  • publint passed with only the pre-existing vendor-export warning.
  • Packed artifact checks passed across 1,216 source maps and 267 browser-safe mapped sources.
  • Built-distribution public smoke checks passed for non-streaming and streaming runners, covering both delayed parsing and cancellation between sequential callbacks.

@HAYDEN-OAI
HAYDEN-OAI requested a review from a team as a code owner August 20, 2026 03:16
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 20, 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-20T03:19:02.179625Z 20219f5 PR opened
🔒 Security Review Completed 2026-08-20T03:18:34.683736Z 20219f5 PR opened
ℹ️ 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.

@openai-sdks

openai-sdks Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 9.963s for Node SDK PR #2430.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 151ms
tests/chat-completions-create.test.ts ✅ Passed 182ms
tests/chat-completions-stream.test.ts ✅ Passed 106ms
tests/files-content-binary.test.ts ✅ Passed 140ms
tests/files-create-multipart.test.ts ✅ Passed 181ms
tests/files-list-pagination.test.ts ✅ Passed 122ms
tests/initialize-config.test.ts ✅ Passed 126ms
tests/instance-isolation.test.ts ✅ Passed 83ms
tests/models-list.test.ts ✅ Passed 123ms
tests/responses-background-lifecycle.test.ts ✅ Passed 104ms
tests/responses-body-method-errors.test.ts ✅ Passed 250ms
tests/responses-cancel-timeout.test.ts ✅ Passed 190ms
tests/responses-cancel.test.ts ✅ Passed 190ms
tests/responses-compact-retries.test.ts ✅ Passed 216ms
tests/responses-compact.test.ts ✅ Passed 200ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 87ms
tests/responses-create-advanced.test.ts ✅ Passed 179ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.063s
tests/responses-create-errors.test.ts ✅ Passed 135ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 99ms
tests/responses-create-retries.test.ts ✅ Passed 554ms
tests/responses-create-stream-failures.test.ts ✅ Passed 167ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 2.139s
tests/responses-create-stream-wire.test.ts ✅ Passed 2.547s
tests/responses-create-stream.test.ts ✅ Passed 63ms
tests/responses-create-terminal-states.test.ts ✅ Passed 170ms
tests/responses-create-timeout.test.ts ✅ Passed 186ms
tests/responses-create.test.ts ✅ Passed 165ms
tests/responses-delete.test.ts ✅ Passed 143ms
tests/responses-input-items-errors.test.ts ✅ Passed 137ms
tests/responses-input-items-list.test.ts ✅ Passed 144ms
tests/responses-input-items-options.test.ts ✅ Passed 84ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 205ms
tests/responses-input-tokens-count.test.ts ✅ Passed 101ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.142s
tests/responses-not-found-errors.test.ts ✅ Passed 203ms
tests/responses-parse.test.ts ✅ Passed 134ms
tests/responses-retrieve-retries.test.ts ✅ Passed 299ms
tests/responses-retrieve.test.ts ✅ Passed 184ms
tests/responses-stored-method-errors.test.ts ✅ Passed 477ms
tests/retry-behavior.test.ts ✅ Passed 3.03s
tests/sdk-error-shape.test.ts ✅ Passed 718ms

View OkTest run #32412084373

SDK merge (8809d77db076) · head (32d1c19a9835) · base (a0d68cc53125) · OkTest (2b1bdfd25e98)

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

34 mixed files remain; 0 existing customizations changed.

Compared a0d68cc5312532d1c19a9835. Generated baselines verified.

34 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/api-resources/embeddings.test.ts
  • tests/api-resources/responses/responses.test.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 32412082344 --repo openai/openai-node \
  --name castiron-custom-code-32412082344-1 --dir /tmp/castiron-custom-code-32412082344-1
git apply --stat /tmp/castiron-custom-code-32412082344-1/custom-code.patch
cat /tmp/castiron-custom-code-32412082344-1/custom-code.patch

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

git fetch --no-tags origin a0d68cc53125c2cb82eab31271b8984b8d65d4b2 32d1c19a983598b67fe6e2449ea1e3b361306c63
python3 scripts/castiron/custom_code_report.py report \
  --base a0d68cc53125c2cb82eab31271b8984b8d65d4b2 \
  --head 32d1c19a983598b67fe6e2449ea1e3b361306c63 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-32d1c19a9835
cat /tmp/castiron-custom-code-32d1c19a9835/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: 20219f5f61

ℹ️ 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/lib/AbstractChatCompletionRunner.ts
Comment thread src/lib/AbstractChatCompletionRunner.ts Outdated
Comment thread src/lib/AbstractChatCompletionRunner.ts

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

Independent two-pass security review validates the three existing cancellation findings, including a High post-abort callback bypass, and identifies one additional Medium result-preservation regression documented inline.

Comment thread src/lib/AbstractChatCompletionRunner.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