fix(permissions): native path deny/ask rules apply to the file the tool opens
Edit/Read/Grep rules matched only the raw argument string, so a workspace symlink (or a quoted, `~`, `./`, `..`, or absolute spelling) reached a denied file. The policy now resolves the path exactly as the tools do (sanitize, expand `~`, display-cwd remap, join to the requesting session's cwd), follows symlinks parent-first, and re-checks deny/ask rules on the opened path and its target as absolute, `./`-relative and relative spellings. Escalation only: no allow is granted through a link. A link that cannot be followed forces a prompt that survives YOLO, auto mode and the session edit grant, with event reason `unresolved_link`. Permission requests now carry the requesting tool's cwd and display cwd so a child worktree session sharing its parent's handle is checked where it runs. Ported from upstream 1.0.14 (grok-build permission/policy.rs symlink re-check), reshaped for Kigi's lexical rule matcher. Claude-Session: https://claude.ai/code/session_01RUqV8HVGXcAETyYbZ2tPQ4
This commit is contained in:
1 parent
fb3fe89d33
commit
5f7416f3ef
8 files changed
+995
-34
No files matched your search
@@ -270,10 +270,10 @@ Path patterns are globs matched against the path string the tool was called with
|
||||
- `*` and `?` do not cross `/`; `**` does. `Read(src/*)` matches `src/main.rs` but not `src/nested/mod.rs`; use `Read(src/**)` for the whole tree.
|
||||
- A bare filename matches only that exact string. Use `**/.env` to match `.env` at any depth.
|
||||
- There are no anchor prefixes: a leading `//` or `~/` in a pattern is treated as literal glob text. Write absolute-path patterns or `**/` patterns instead.
|
||||
- Paths are matched as given, without canonicalization. Whether a path is absolute or relative depends on how the tool was invoked, so patterns intended as boundaries should cover both forms (for example both `/repo/secrets/**` and `secrets/**`).
|
||||
- Allow rules match the path as the tool was called with it. Deny and ask rules are also checked against the file the tool will open: the path is resolved against the session directory, symlinks are followed, and the absolute and the workspace-relative spelling (with or without a leading `./`) are matched. `secrets/**` therefore catches a read of `/repo/secrets/key` and a read through a symlink that points into `secrets/`. A symlink that cannot be resolved (a loop) prompts when any deny or ask rule covers the tool.
|
||||
- `Read` rules also govern `grep` searches; `Grep(...)` rules match only grep.
|
||||
|
||||
`Read` and `Edit` deny rules additionally apply to file paths that shell commands touch (for example `cat` or `sed` on a denied path), and that shell-level check resolves symlinks. The direct `read_file`/`search_replace` tool checks do not resolve symlinks. For OS-level enforcement that covers every process, combine deny rules with the sandbox ([18-sandbox.md](18-sandbox.md)).
|
||||
`Read` and `Edit` deny rules additionally apply to file paths that shell commands touch (for example `cat` or `sed` on a denied path), and that shell-level check resolves symlinks too. For OS-level enforcement that covers every process, combine deny rules with the sandbox ([18-sandbox.md](18-sandbox.md)).
|
||||
|
||||
### MCP Rules
|
||||
|
||||
|
||||
Reference in new issue
Block a user