[Bug] Dangerous-command guard misses find -delete, find -exec, xargs, git clean and shred (YOLO runs them without confirmation)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 66/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- shell, typescript
調査の方向性
Start with packages/agent-core-v2/src/agent/permissionPolicy/policies/dangerous-command-ask.ts and read the existing policy tests to see how analyzeInvocation classifies commands. Add coverage for the five destructive forms and the stated negative cases, then run those tests. Done means destructive commands prompt for confirmation in YOLO mode while the dry run and ordinary find case do not.
索引モデルが issue の本文から書いたものです。
説明
What version of Kimi Code is running?
2.6.3 (source main snapshot, 2026-11-18). Confirmed by reading the policy and by running a unit-level reproduction.
Which open platform/subscription were you using?
None involved (code-level audit).
Which model were you using?
None involved (code-level audit).
What platform are your computer?
Windows 11 x64. The guard bypass is platform-independent (the analyzer is shell-syntax based).
What issue are you seeing?
In Ask When Needed (YOLO) mode, the dangerous-command guard does not recognize several common destructive shell idioms, so the Bash call falls through to yolo-mode-approve and runs without confirmation.
The guard is packages/agent-core-v2/src/agent/permissionPolicy/policies/dangerous-command-ask.ts. It covers rm -rf, dd of=/dev/..., systemctl poweroff/reboot, init 0/6, sudo/doas, env/command/exec/nohup, nested sh -c/bash -c, eval, busybox, and mkfs.*. It does not handle these common destructive forms:
find <path> -deletefind <path> -exec rm -rf {} +/-execdir... | xargs rm -rfgit clean -fdx(deletes untracked files, including ignored files with-x)shred -u <file>
analyzeInvocation has no branch for find, xargs, git, or shred, so it returns undefined at the end, meaning "not dangerous". The policy ordering in packages/agent-core-v2/src/agent/permissionPolicy/permissionPolicyService.ts:39-53 puts dangerous-command-ask before yolo-mode-approve, which is correct, but with an undefined result the YOLO policy then approves the call.
What steps can reproduce the bug?
In the TUI, switch to Ask When Needed mode (/yolo), then ask the agent to run any of the commands above against a disposable directory. No confirmation appears; the command executes.
Unit-level (temporary test, reverted afterwards), instantiating the real parser and policy in YOLO mode:
const policy = new DangerousCommandAskPermissionPolicyService(
new BashParserService() as any,
{ mode: 'yolo' } as any,
{ get: () => ({ dangerousCommandGuard: true }) } as any,
);
const evaluate = (command: string) =>
policy.evaluate({ toolCall: { name: 'Bash' }, args: { command } } as any);
evaluate('rm -rf /'); // { kind: 'ask', reason: { dangerous_command: 'rm -rf' } }
evaluate("bash -c 'rm -rf /'"); // { kind: 'ask', reason: { dangerous_command: 'rm -rf' } }
evaluate('sudo rm -rf /'); // { kind: 'ask', reason: { dangerous_command: 'rm -rf' } }
evaluate('find / -delete'); // undefined
evaluate('find / -exec rm -rf {} +'); // undefined
evaluate('printf / | xargs rm -rf'); // undefined
evaluate('git clean -fdx'); // undefined
evaluate('shred -u /etc/passwd'); // undefined
Observed:
find -delete => undefined
find -exec => undefined
xargs rm => undefined
git clean => undefined
shred => undefined
The three control cases correctly return ask.
What is the expected behavior?
The guard should treat these forms as dangerous and return { kind: 'ask', reason: { dangerous_command: ... } }, so Ask When Needed / YOLO mode still prompts before a destructive operation. The guard does not need to be a complete shell sandbox, but these are common, statically analyzable destructive idioms.
Additional information
Suggested implementation:
find: if any operand is-delete, mark dangerous; for-exec/-execdir, collect the command tokens until;or+, substitute{}with a placeholder, and recursively callanalyzeInvocationon the wrapped command.xargs: analyze the command after xargs options (reusedropLeadingOptions);-0/-r/-netc. are safe to skip.git:cleanwith-f(and a destructive scope such as-d/-x) is dangerous;git clean -n(dry run) is not.shred: destructive on any operand.
Add regression tests next to the existing policy tests for the five commands above, plus negative cases (git clean -n, find . -name '*.log').
Scope note: this issue is only about the dangerous-command guard. It is not a claim that the guard covers every shell construct. I checked the tracker for dangerous command / find -delete / xargs and did not find an existing report.
Contribution
- I am willing to submit a PR for this bug fix myself (please wait for maintainer approval in this issue first)
- 主要言語
- TypeScript
- スター
- 8.3k
- フォーク
- 1.4k
- 平均マージ
- 12時間 6分
- マージ済み PR(30日)
- 596
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
MoonshotAI/kimi-code のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
MoonshotAI/kimi-code#5539 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] Kimi RC workspace folder picker does not display symbolic link directories対応中かも @markankamaransheogarat-sys が 2 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
MoonshotAI/kimi-code#5296 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
MoonshotAI/kimi-code#5256 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
MoonshotAI/kimi-code#5062 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
MoonshotAI/kimi-code#5057 ·
メンテナーはふだん 1 日以内に返信
MoonshotAI/kimi-code の issue をすべて見る
似ている issue
-
Add Alice&Botオープン
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
slavakurilyak/awesome-ai-agents#1048 ·
-
bot:ai-assisted component:faucet github_actions security status:untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
midnightntwrk/midnight-faucet-api#215 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
NanmiCoder/cc-haha#2034 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
mobile prio:low
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
digitalfabrik/entitlementcard#3324 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信