Skip to content

fix(sdk): bind post-scan artifact restoration - #468

Draft
mldangelo-oai wants to merge 6 commits into
mainfrom
mdangelo/codex/confine-postscan-artifact-restoration-20260815
Draft

fix(sdk): bind post-scan artifact restoration#468
mldangelo-oai wants to merge 6 commits into
mainfrom
mdangelo/codex/confine-postscan-artifact-restoration-20260815

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Keep completed scan artifacts inside the validated scan output tree when a post-scan follow-up fails.

Changes

  • Snapshot sealed artifacts through checked file handles before starting the follow-up.
  • Capture the canonical scan-root identity before the follow-up and bind restoration to that identity.
  • Restore through descriptor-relative POSIX operations and held Windows handles so replacement roots, linked parents, and parent swaps cannot redirect a write.
  • Skip rewriting unchanged artifacts while preserving recovery for missing, damaged, unreadable, nested, and binary artifacts.
  • Treat restoration setup failures as warnings and return the completed scan without starting the follow-up.
  • Merge current main and remove unrelated credential-lock changes from this branch; that work remains in fix(runtime): use process-owned credential-home locks #613.

Testing

  • bun test --timeout 30000 tests-ts/api-post-scan.test.ts tests-ts/contract.test.ts: 56 passed
  • bun test --timeout 30000 tests-ts/api.test.ts: 118 passed, 2 platform skips
  • bun test --timeout 30000 tests-ts/api-credentials.test.ts: 5 passed
  • pnpm run types
  • pnpm run format
  • pnpm run build
  • uv run ruff check _bundled_plugin/scripts/finalize_scan_contract.py _bundled_plugin/scripts/windows_scan_local_files.py
  • pnpm pack --pack-destination ../../dist
  • pnpm run check:package ../../dist/openai-codex-security-0.1.16.tgz: installed-package smoke passed and 255 entries validated
  • git diff --check and git diff --cached --check

Native Windows execution remains covered by CI; I did not wait for CI before moving to the next PR.

Risk and rollout

This does not change the documented SDK surface, CLI, flags, environment variables, dependencies, or state format. Failed follow-ups may atomically replace damaged sealed artifacts, then the completed contract is revalidated. Unchanged artifacts keep their existing file identity and timestamps.

If the scan root or an artifact parent changes identity, restoration fails closed instead of writing through the replacement path. If restoration setup itself is unavailable, the follow-up is skipped and the completed scan is returned with a warning.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

The second attestation remains unchecked because already-published history includes an author email, access-restricted report links, and public review discussion of the vulnerability. This update does not rewrite public history.

@github-actions github-actions Bot added the bug Something isn't working label Aug 15, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 6e0e19c3b8

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

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 6e0e19c3b8

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head, 4ca4c82b4f14ede84e666742c52639391a127384.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 4ca4c82b4f

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

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 4ca4c82b4f

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review commit 3368d07e98709dc1096f3d31f5f41b025b4727cb.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 3368d07e98

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

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 3368d07e98

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head e8fc845591364b41ac8da88462098e90852df680. This additive follow-up fixes transient Windows credential-lock reads and test cleanup. The artifact-restoration implementation is unchanged.

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: e8fc845591

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

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

ℹ️ 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 sdk/typescript/src/contract.ts Outdated
Comment thread sdk/typescript/src/runtime.ts Outdated
@mldangelo-oai mldangelo-oai changed the title fix(sdk): keep restored scan artifacts within their output directory fix(sdk): bind post-scan artifact restoration Aug 22, 2026
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review exact head 1664172 against current main.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex security review

Please review exact head 1664172 against current main.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 22, 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-22T06:32:35.278945Z 1664172 Manual request
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 1664172ca7

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

@kmbroai kmbroai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Critical review

Reviewed head 1664172ca719ae1f4dc07ed23e6e228aab900324 and compared the overlapping newer #626 implementation.

Recommendation: supersede this PR with #626 rather than merging both. The underlying restoration fix is necessary, but this older version changes an unrelated write contract and ties recovery to the selected plugin's helper API.

[P2] Restrict unchanged-content short-circuiting to restoration

The new comparison in write_scan_local_bytes returns early for all identical writes, including ordinary callers that previously received a new private file. I executed the actual helper against an existing 0644 artifact with identical contents: this head left both its mode and inode unchanged. The corresponding #626 helper replaced it and produced mode 0600. Gate the optimization on restoration identity being supplied, as #626 does. Content equality is not equivalent to preserving the original writer's metadata/replacement contract.

Custom-plugin and bundle compatibility

prepareScanArtifactRestorer invokes options.pluginRoot and assumes that plugin contains the newly introduced scan_root_identity API. An otherwise compatible existing custom plugin will fail restoration setup and therefore skip requested post-scan instructions. Recovery is an SDK guarantee, so use the SDK-owned helper independently of the selected scan plugin. This PR also changes bundled Python code without advancing the bundled version markers; the version-keyed install/cache path needs an upgrade plan. #626 addresses both points and avoids the unbounded whole-file equality read in this version.

Existing feedback and verification

The earlier checked-path/rename race is addressed in the current implementation by held descriptors/handles; the unrelated credential-lock edit was removed. I am not re-reporting those old comments as current defects.

Ran the checked-in post-scan suite: 13 passed, 0 failed, plus the paired ordinary-write reproduction above. Linux with Bun 1.3.14 / Node 22.13.1 and cached dependencies; no native Windows or live model run. Keep the regression fixtures, but consolidate the production fix into #626.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants