kimi-code icon indicating copy to clipboard operation
kimi-code copied to clipboard

User-defined `[[permission.rules]]` (incl. `deny`) are not enforced in print/auto mode (2.3.1, still present in 2.3.2)

Open artemmonakhov opened this issue 1 month ago • 1 comments

Summary

In kimi -p (print mode, which forces auto permission) user-defined [[permission.rules]] from ~/.kimi-code/config.toml — including decision = "deny" — are not applied at all. The CLI command reference states: "In -p mode … static deny rules remain in effect". Empirically they don't — on 2.3.1 and still on 2.3.2.

Environment

  • kimi 2.3.1 → 2.3.2 (/opt/homebrew/bin/kimi, macOS, Apple Silicon)
  • default_permission_mode unset (defaults apply); no KIMI_CODE_* permission env overrides

Repro

  1. ~/.kimi-code/config.toml:
[[permission.rules]]
decision = "deny"
pattern = "Read(/Users/you/.credentials/**)"
reason = "test rule"

[[permission.rules]]
decision = "deny"
pattern = "Bash(echo V60PROBE*)"
reason = "test rule"
  1. echo "dummy" > ~/.credentials/probe.txt

  2. Run:

kimi -p "Perform an actual Read tool call on /Users/you/.credentials/probe.txt and show the result"

Expected (per docs): the Read call is denied by the static deny rule. Actual: the file is read; wire.jsonl shows a successful tool.result with the file contents. Session records permission.set_mode = "auto".

  1. Bash control:
kimi -p "Run the Bash command: echo V60PROBE-test and show the output"

Expected: denied. Actual: V60PROBE-test executes and returns.

Still present in 2.3.2 (reproduced 2026-10-26)

Fresh probe on 2.3.2 with a neutral path:

[[permission.rules]]
decision = "deny"
pattern = "Read(/tmp/v62probe/**)"
reason = "temp probe"
echo "V62-SECRET-CONTENT-778899" > /tmp/v62probe/secret.txt
kimi -p "Perform an actual Read tool call on /tmp/v62probe/secret.txt and show the file content"

Actual: the read succeeds; the model reports the content and notes the read "went through normally". The deny rule did not fire.

Verified

  • Config is valid: kimi doctor → All checked config files are valid; tomllib parses the rules.
  • Pattern form is not the cause: tested Read(/abs/path/**), Read(/abs/path/*), Read(/abs/path*), Read(*.credentials*), plus Bash(echo V60PROBE*) — none fire (2.3.1).
  • Built-in guards DO work in the same mode: a dummy /tmp/.env is hard-blocked with "/tmp/.env" matches a sensitive-file pattern … Access is blocked.
  • User-defined [[hooks]] (PreToolUse) DO fire in the same mode (exit 2 blocks the tool call).
  • Interactive modes (manual/yolo) were not tested; issue may be print/auto-specific.

Impact

Headless runs (kimi -p used by automations/CI) and --auto sessions silently lose the user-configured permission layer, while documentation promises static deny enforcement. Workaround: replicate deny logic in PreToolUse hooks.

Source: Context OS v6.0 phase verification, 2026-10-25 (probe sessions 93873acb, 90d11ffa, 0dc855f3, 780bad69); 2.3.2 reproduction 2026-10-26 (session 6d21b95f).

artemmonakhov avatar Oct 26 '26 12:10 artemmonakhov

因為這個bug一直存在

xuruizhe891 avatar Oct 27 '26 19:10 xuruizhe891