Security: block exec host overrides when tools.exec.host is auto#58897
Conversation
Greptile SummaryThis PR fixes a sandbox-bypass regression by tightening
Confidence Score: 5/5Safe to merge — the security fix is correct and no regressions are introduced; remaining findings are P2 quality/UX suggestions. The core logic change is simple, correct, and well-targeted. Both findings are P2: the error message hint is cosmetic/informational and the test gaps are minor coverage improvements rather than evidence of broken behaviour. No P0/P1 issues found. No files require special attention for merge safety, but src/agents/bash-tools.exec-runtime.ts lines 248–251 contain the misleading error message worth fixing in a follow-up.
|
| it("rejects host overrides when configured host is auto", () => { | ||
| expect(() => | ||
| resolveExecTarget({ | ||
| configuredTarget: "auto", | ||
| requestedTarget: "node", | ||
| elevatedRequested: false, | ||
| sandboxAvailable: false, | ||
| }), | ||
| ).toMatchObject({ | ||
| configuredTarget: "auto", | ||
| selectedTarget: "node", | ||
| effectiveHost: "node", | ||
| }); | ||
| ).toThrow("exec host not allowed"); | ||
| }); |
There was a problem hiding this comment.
Narrow test coverage for the new restriction
The single test only asserts that requestedTarget: "node" is rejected. The symmetrical gateway override (requestedTarget: "gateway") and the still-valid auto→auto pass-through are not exercised. Consider adding:
it("also rejects gateway override when configured host is auto", () => {
expect(() =>
resolveExecTarget({
configuredTarget: "auto",
requestedTarget: "gateway",
elevatedRequested: false,
sandboxAvailable: true,
}),
).toThrow("exec host not allowed");
});
it("allows explicit auto request when configured host is auto", () => {
expect(
resolveExecTarget({
configuredTarget: "auto",
requestedTarget: "auto",
elevatedRequested: false,
sandboxAvailable: true,
}),
).toMatchObject({ selectedTarget: "auto", effectiveHost: "sandbox" });
});Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/bash-tools.exec-runtime.test.ts
Line: 50-59
Comment:
**Narrow test coverage for the new restriction**
The single test only asserts that `requestedTarget: "node"` is rejected. The symmetrical `gateway` override (`requestedTarget: "gateway"`) and the still-valid `auto`→`auto` pass-through are not exercised. Consider adding:
```ts
it("also rejects gateway override when configured host is auto", () => {
expect(() =>
resolveExecTarget({
configuredTarget: "auto",
requestedTarget: "gateway",
elevatedRequested: false,
sandboxAvailable: true,
}),
).toThrow("exec host not allowed");
});
it("allows explicit auto request when configured host is auto", () => {
expect(
resolveExecTarget({
configuredTarget: "auto",
requestedTarget: "auto",
elevatedRequested: false,
sandboxAvailable: true,
}),
).toMatchObject({ selectedTarget: "auto", effectiveHost: "sandbox" });
});
```
How can I resolve this? If you propose a fix, please make it concise.|
Addressed the review in follow-up commit 8eb3fd1. What changed:
Verification:
|
|
Added the missing changelog entry in follow-up commit |
3aecad3 to
52a0723
Compare
615325e to
68c3945
Compare
|
Landed via temp rebase onto main. Thanks @vincentkoc! |
Motivation
configuredTarget = "auto"acted like a wildcard allowlist and model-suppliedhost=gateway|nodecould force execution on the gateway/node host, escaping sandbox isolation.Description
isRequestedExecTargetAllowedto only permit a requested target when it exactly matches the configured target (remove the previous special-case that allowedauto).elevatedRequested) behavior unchanged (still selectgateway).src/agents/bash-tools.exec-runtime.test.tsto assert that host overrides are rejected whenconfiguredTargetisauto.docs/internal/codex/2026-03-29-exec-target-override-fix.mddocumenting the issue and the remediation.Testing
pnpm test -- src/agents/bash-tools.exec-runtime.test.ts, which passed (1 test file, 12 tests).pnpm check), and the checks completed with no errors.Codex Task