Skip to content

fix(git): pin trusted executables across scan hosts - #467

Draft
mldangelo-oai wants to merge 12 commits into
mainfrom
mdangelo/codex/trust-repository-git-executable
Draft

fix(git): pin trusted executables across scan hosts#467
mldangelo-oai wants to merge 12 commits into
mainfrom
mdangelo/codex/trust-repository-git-executable

Conversation

@mldangelo-oai

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

Copy link
Copy Markdown
Collaborator

Summary

Use one trusted Git executable consistently across SDK scans, the bundled workbench, and MCP hosts.

Fixes #129. Extends the still-open proposal in #140.

Changes

  • Carry selected absolute tool invocations and the sanitized environment through scan hosts, including committed inventory and changed-file ranking.
  • Keep executable selection anchored to the scanned repository while preserving safe user Git configuration, optional-Git behavior, and trusted wrapper invocation names.
  • Use one executable-inspection result instead of resolving Git twice. Preserve platform-default lookup when PATH is omitted without broadening an explicitly empty or rejected path.
  • Preserve an explicitly empty CODEX_SECURITY_GIT binding while still sanitizing PATH for ripgrep. Emit one effective binding on Windows and retain case-distinct POSIX variables.
  • Reject canonical Windows batch-file targets during host executable inspection, continue searching later candidates, and retain native aliases with extensionless canonical targets. This keeps host selection consistent with the bundled helper and preserves packaged-ripgrep fallback.
  • Share Python executable checks between Git and ripgrep, retaining repository-path and Windows native-executable protections. Inventory helpers report an unavailable tool before spawning and can safely use tools added later by Codex.
  • When trusted host ripgrep is unavailable, copy only the running SDK's packaged native ripgrep into its existing private runtime workspace and validate the copied absolute path. This preserves repository-local npm installations without allowing executable lookup inside the scanned repository.
  • Preserve case-distinct POSIX environment variables and normalize Windows PATH aliases consistently.
  • Treat missing or non-directory historical targets as unavailable Git probes so completed history and repository matching remain usable. Unrelated filesystem errors still propagate.
  • Check startup-lock absence only after both clients reach the existing parallel-scan test barrier. Keep the concurrency, configuration-isolation, and timeout assertions unchanged.
  • Start the already-selected Python with its normal interpreter environment, then install the restricted test environment before importing the workbench. Preserve the existing mock cases and assertions.
  • Keep both bundled-plugin version fields at 0.1.22 so cached hosts refresh the helper changes.
  • Merge the recorded main additively.

Testing

Current head b83d18e5:

  • bun --no-env-file test --timeout 30000 tests-ts/workbench-tool-environment.test.ts — nine passed, zero failures, and 17 Bun assertions with Bun 1.3.14. The existing Python mock cases and assertions are unchanged; no interpreter shim or executable fixture was added.
  • pnpm run types, pnpm run format, and git diff --check — passed on the committed head.
  • bun --no-env-file test --randomize --seed 12345 --timeout 30000 ./tests-ts — 1,317 passed, 11 skipped, zero failures, and 9,287 assertions with Bun 1.3.14. Live integration and machine-policy opt-ins were disabled.
  • pnpm run build, pnpm pack, pnpm run check:package, and the separate pnpm run test:package on the resulting openai-codex-security-0.1.14.tgz — passed. The package validator checked 218 archive entries and 106 bundled-plugin files. Both installed checks ran the actual nested worker with its original timeout. The archive is byte-identical to the preceding published-head archive.
  • Independent exact-head source rereview and three fresh native reviews plus independent verification — clean, with no confirmed findings.

The follow-up changes only the test helper; production source and bundled-plugin files are unchanged. The source head and tree stayed clean through every current-head local gate. Remote CI has not yet run on this new head.

Historical published head 62bfcd13:

  • bun --no-env-file test --randomize --seed 12345 --timeout 30000 ./tests-ts — 1,317 passed, 11 skipped, zero failures, and 9,287 assertions with Bun 1.3.14. Live integration and machine-policy opt-ins were disabled.
  • pnpm run build, pnpm pack, pnpm run check:package, and the separate pnpm run test:package — passed. The package validator checked 218 archive entries and 106 bundled-plugin files. Both installed checks ran the actual nested worker with its original timeout.
  • Three native reviews plus independent verification were clean. Exact-head remote CI completed with 29 successful and five skipped logical checks; the Security Review was clear.

The earlier 743e32f0 CI attempt exposed a preexisting parallel-test assertion race corrected in c0142c57 and an unlocalized Windows credential-lock owner-file EPERM. The later c0142c57 and 62bfcd13 matrices passed. Production locking, ownership, and ACL behavior remain unchanged, and no old-head retry was run. Earlier source-head records are preserved; no historical result is claimed for the current head.

Risk and rollout

Git remains optional, safe user settings remain available, and the existing snapshot and scan-completion contracts are unchanged. The packaged-ripgrep fallback uses the installed application's native-package provenance and existing runtime cleanup; it does not relax the Python repository exclusion or add a persistent executable cache. Explicit disable bindings remain effective on POSIX and Windows. The missing-PATH behavior follows the documented Node command-lookup defaults.

Integrate #449 first and retain its streamed Git command support, private-spool pipe handling, distinct cancellation and writable-state error handling, committed-object immutability, and offline-read policy. Preserve its shared-runner routing and immutable blob-read flags. Reconcile the shared inventory and containment changes in #320 and #472 when they land. This branch uses paired plugin version 0.1.22; the recorded #449, #462, and #472 heads carried competing 0.1.21 updates. Before merging, update both version fields together to the next monotonic version after the preceding plugin changes, then rerun the integration checks on the resulting head.

Public disclosure review

Newly authored material was reviewed for public disclosure. Existing automated review comments contain access-restricted report references; maintainer cleanup remains outstanding.

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

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

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

@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: 5dc0f1c298

ℹ️ 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/api.ts Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 5dc0f1c298

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

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 9be47a60bb

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: 9be47a60bb

ℹ️ 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/api.ts Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/workbench_target.py Outdated
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 49000ab013

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: 49000ab013

ℹ️ 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/_bundled_plugin/scripts/workbench_target.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/workbench_target.py Outdated
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 78123a7e99

ℹ️ 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: 78123a7e99

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, 743e32f028ab8bb71e5d2607f1b30832269aabba.

@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: 743e32f028

ℹ️ 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/api.ts
Comment on lines +651 to +655
const git = await inspectTrustedExecutable(
"git",
pluginEnvironment,
protectedGitRoot,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor explicit Git disable bindings

When the SDK environment sets CODEX_SECURITY_GIT="" to disable optional Git, this lookup ignores the binding, discovers Git from PATH, and later replaces the empty value with that executable. Codebase scans therefore use a Git snapshot instead of the requested directory fallback, while diff scans proceed rather than reporting Git as unavailable. Check the binding before lookup, including case-insensitive aliases on Windows, as is already done for ripgrep.

AGENTS.md reference: sdk/typescript/AGENTS.md:L19-L20

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 743e32f028

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, c0142c5739652cff10467b6b5285ca5193c013a9.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: c0142c5739

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: c0142c5739

ℹ️ 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/api.ts
Comment on lines +656 to +660
let ripgrep = await inspectTrustedExecutable(
"rg",
git.environment,
protectedGitRoot,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject batch targets before binding Windows ripgrep

On Windows, when PATH contains an rg.exe symlink targeting an rg.cmd or rg.bat file and no later trusted ripgrep exists, inspectTrustedExecutable treats the .exe invocation as runnable and this call therefore skips the bundled-ripgrep fallback. The Python resolver subsequently rejects the canonical batch target in _is_native_executable, causing inventory generation—and thus the scan—to fail. Reject canonical batch targets during host inspection while continuing to allow extensionless native targets.

AGENTS.md reference: sdk/typescript/AGENTS.md:L24-L24

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: 62bfcd13d4

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

`,
join(PLUGIN_ROOT, "scripts"),
],
{ encoding: "utf8", env: childEnvironment(dirname(python!)) },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Launch shimmed Python before narrowing PATH

When Bun.which returns a pyenv/asdf-style shim implemented with #!/usr/bin/env bash, replacing PATH with only dirname(python) prevents /usr/bin/env from locating bash, so every runPythonMocks case exits with status 127 before Python starts. Start the interpreter with a PATH capable of executing the shim and narrow os.environ["PATH"] inside Python, or resolve the underlying interpreter first, so these tests remain deterministic across developer installations.

AGENTS.md reference: sdk/typescript/AGENTS.md:L32-L32

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 62bfcd13d4

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: b83d18e574

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

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.

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

Draft feedback: preserve explicitly configured trusted executable selections.

Comment thread sdk/typescript/src/api.ts
modelProvider,
);
const protectedGitRoot = await outermostGitMarkerRoot(repo, signal);
const git = await inspectTrustedExecutable(

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] Honor nonempty explicit Git and ripgrep executable bindings

Could we validate and preserve nonempty CODEX_SECURITY_GIT and CODEX_SECURITY_RG selections before searching PATH? The workbench supports explicit trusted absolute executable paths, but this code always resolves literal git and rg, then overwrites the configured bindings. A valid custom Git outside PATH is silently disabled or replaced, and an explicitly selected ripgrep can be replaced by the bundled fallback. The existing empty-disable behavior should stay unchanged.

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.

Bundled workbench resolves Git from inherited PATH instead of the trusted executable boundary

2 participants