Skip to content

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

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

fix(git): pin trusted executables across scan hosts#467
mldangelo-oai wants to merge 32 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 target validation, scans, the bundled workbench, and MCP hosts.

Fixes #129. Extends the proposal in #140.

Changes

  • Select Git before target validation and carry the same invocation and sanitized environment through ref resolution, bulk checkouts, checkout checks, repository discovery, and scan registration.
  • Honor explicit Git and ripgrep selections. An empty setting disables the tool; an invalid nonempty setting fails instead of silently falling back. Preserve invocation spelling only after checking its directory identities. Keep case-distinct POSIX variables and one effective Windows binding, and read tool settings afresh for each scan.
  • Forward the Git setting through the CLI history environment without widening its credential allowlist.
  • Reuse the existing executable checks in SDK and Python hosts. Keep repository-path exclusions, native Windows executable handling, extensionless selections and quoted PATH entries, optional Git, and safe user Git configuration.
  • Exclude repositories supplying the scan, knowledge-base documents, and bulk inventory from host tool selection. Bulk checkout also excludes every local inventory source and managed checkout. Preserve deliberate local-tool selections outside those repository inputs, including tools stored in private scan output or an unrelated launch directory. Resolve existing ancestors and dangling-link targets of linked or missing inputs while preserving safe PATH fallback, explicit invocation checks, local Git-file sources, and per-task failures. Keep missing filesystem roots and cyclic source links isolated to their own task. Treat cyclic saved targets as unavailable Git probes across supported Python versions, and require drive-qualified or complete UNC paths for explicit Windows tool selections.
  • Check the shared credential lock in the parallel-scan test after both simulated scans reach their existing barrier. Production authentication behavior and timeouts are unchanged.
  • When host ripgrep is unavailable, use only the running SDK's packaged native binary in the existing private runtime workspace. Check that workspace against every protected input before copying. Keep the existing cleanup and later-tool fallback.
  • Cover setting propagation with synthetic, isolated process mocks. Preserve the outer worktree output boundary even when Git is disabled. Merge main's shared session setup and Windows executable-discovery fixes additively, advancing the paired bundled-plugin version to 0.1.29 for the changed payload.
  • Exclude explicitly internal helpers and dependency-injection overloads from public declarations so strict TypeScript consumers do not load development-only upstream types.

Testing

On 055269586a148c0f0fc1fa08025deeb00ef3f434:

  • Focused selected-tool and staging controls: 17 passed.
  • Trusted-executable, target, workbench, multiscan, discovery, API, and CLI-export tests: 280 passed, 2 skipped, zero failures.
  • Types, formatting, and diff checks: passed. The bundled plugin tree and paired version 0.1.29 are unchanged from the published parent.
  • Build, package creation, installed-package smoke, strict NodeNext TypeScript consumer, and public target-helper signature checks: passed. The installed package check validated 226 entries and 106 bundled plugin files.
  • Normal and seed-12345 full Bun 1.3.14 suites: 1,400 passed, 14 skipped, zero failures in each run.
  • Three fresh whole-PR native review passes and an independent verifier: no remaining findings on this exact head.

Earlier results remain historical evidence, not validation of this follow-up.

Risk and rollout

Public root exports and runtime behavior are unchanged by the declaration correction. Code that depended on unsupported internal signatures may stop type-checking.

Git remains optional. An explicit disable now applies to early SDK Git operations as well as plugin hosts, so Git-dependent diff targets report that Git is unavailable. Invalid explicit selections fail before scan initialization. The existing snapshot, scan-completion, Python containment, and runtime-cleanup contracts remain in place. No dependency or npm-version change is included.

Integrate #449 first and preserve its streamed Git runner, cancellation behavior, private-spool handling, and immutable blob reads. Reconcile overlapping inventory changes in #320 and #472 when they land. Before merging, update both plugin version fields together to the next monotonic version after preceding plugin changes and rerun integration checks.

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

Please review current head e9afbd94023ab9e0ce5d0506feb1952f79b2ce4e. The additive update passed normal and randomized full suites, installed-package checks, strict TypeScript consumers, and the native prepublication review gate.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: e9afbd9402

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

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, 76b9e906611b3e9707d4e4b83f0e2bfad81419e7, after the additive main merge and compatibility fixes. Please check explicit Git and ripgrep settings, Windows path handling, Python Git probes, and the existing repository-input protections.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 76b9e90661

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

Copy link
Copy Markdown
Collaborator Author

@codex security review

Please review the current head 76b9e906611b3e9707d4e4b83f0e2bfad81419e7.

@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: 76b9e90661

ℹ️ 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/multiscan.ts Outdated

const gitRoots = await protectedGitInputRoots(
[
process.cwd(),

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 Protect only actual multiscan input roots

When multiscan is launched from a directory containing a deliberately configured Git executable—for example, CODEX_SECURITY_GIT=$PWD/tools/git while the inventory and task repositories are elsewhere—adding process.cwd() makes the entire launch worktree protected, so resolveGitCommand() rejects the requested executable and every pending checkout fails. Relative repository entries are resolved against the inventory directory, and the inventory file and local sources are already included separately, so the launch directory should not be protected unconditionally.

AGENTS.md reference: sdk/typescript/AGENTS.md:L22-L23

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 0552695. Bulk tool selection now excludes the actual inventory, scan, knowledge-base, local-source, and managed-checkout inputs without treating an unrelated launch directory as an input. The regression runs from a separate synthetic repository and intercepts the selected executable before execution. The affected tests pass.

Comment thread sdk/typescript/src/api.ts Outdated
runtime.bootstrapWorkspace !== undefined
) {
const workspace = await realpath(runtime.bootstrapWorkspace);
requireOutputOutsideRepository(protectedGitRoot, workspace, "runtime");

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 Validate the runtime workspace against all protected roots

When host ripgrep is unavailable and bootstrapWorkspace is beneath another protected input root—for example, TMPDIR points into the repository containing a knowledge-base document—this check validates only the scanned repository, so the SDK stages ripgrep inside that protected input tree. The subsequent inspection uses protectedGitRoots, rejects the staged executable, and leaves inventory generation without ripgrep; validate the workspace against every protected root before staging.

AGENTS.md reference: sdk/typescript/AGENTS.md:L22-L23

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 0552695. Bundled-ripgrep staging now checks the runtime workspace against every protected input before copying. The regression covers a separate knowledge-base repository with an empty PATH and an explicit CLI path, and confirms that an overlapping workspace fails before staging or launch. The affected tests pass.

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review exact head 0552695. The additive follow-up fixes the launch-directory exclusion and checks bundled-ripgrep staging against all actual protected inputs. The affected tests, installed-package checks, strict TypeScript consumers, and both full suites pass. The PR remains draft.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 055269586a

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

Copy link
Copy Markdown
Collaborator Author

@codex security review

Please review the current head 055269586a148c0f0fc1fa08025deeb00ef3f434.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 055269586a

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

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