chore(hardening): stop auto-approving Bash in auto mode and FetchURL by default - #5
Merged
Merged
Conversation
…by default Auto mode exists to take friction out of ordinary work, and headless runs turn it on for the whole session. Blanket-approving Bash there converts a shell command the model chose, possibly on the strength of text it read from a repo file or a fetched page, into unreviewed execution. Bash now falls through the rest of the chain, so a user allow rule still authorizes it, explicitly. KIMI_CODE_AUTO_APPROVE_BASH=1 restores the old behaviour. Drop FetchURL from the default auto-approve set. It is the one auto-approved tool that sends caller-chosen bytes to a caller-chosen host, so it is the sink half of an exfiltration pair; the SSRF guard blocks internal targets but not public ones, so the gate has to be approval. The two Bash hook-flow tests set auto mode purely to let Bash run while they assert hook ordering; they now opt in through the env var instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4 tasks
# Conflicts: # packages/agent-core-v2/test/agent/permissionPolicy/permissionPolicyService.test.ts
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two privileges were granted implicitly rather than asked for.
Bash. Headless runs (kimi -p) switch the whole session into auto mode, so every shell command the model chose ran with no review — including one chosen on the strength of text that arrived in a repo file, an issue, or a fetched page. The mode is a convenience setting; it was also acting as a grant of arbitrary code execution.FetchURLwas in the default auto-approve set. It is the only auto-approved tool that sends caller-chosen bytes to a caller-chosen host. Whatever the agent can read (andRead/Grep/Globare auto-approved), it could put in a URL and ship out with no prompt. TheLocalFetchURLProviderSSRF guard is solid but blocks internal targets — it does nothing about exfiltration to a public host, so the gate has to be approval.What changed
auto-mode-approveskips an excluded-tool set, currently{ Bash }. This does not deny Bash: the call falls through to the rest of the chain, so a user[permission] allowrule authorizes it — explicit and auditable instead of implied by the mode.KIMI_CODE_AUTO_APPROVE_BASH=1restores the old behaviour for an operator who accepts the risk.FetchURLremoved fromDEFAULT_APPROVE_TOOLS.[permission] allow = ["FetchURL"]restores it.Both escape hatches route through the
[permission]rules that PR #2 makes functional, so the config path is real rather than theoretical.Behaviour change worth reviewing
This is the most user-visible PR of the set:
kimi -ppipelines that rely on Bash will now stop unless they set the env var or add an allow rule. That is the intended outcome — the previous behaviour was the finding — but it is a breaking change for any existing automation, so it deserves a deliberate decision rather than a silent merge.Testing
auto-mode-approvein auto mode; ordinary tools still are; the env opt-in restores approval;FetchURLis not in the default approve set.tool.test.tsset auto mode purely so Bash would run while they assert hook ordering. They timed out under the new behaviour (correctly — they were waiting for approval), so they now opt in via the env var. Their subject is hooks, not permissions, so this keeps them testing what they were written to test.agent-core-v2suite green: 310 files / 4874 tests.oxlintandtsc --noEmitclean.Checklist
minor).