Skip to content

fix(permissions): withhold allows shadowed by skipped ask and all-tools restrictions - #3802

Merged
dyoshikawa merged 9 commits into
mainfrom
sec2-perms
Nov 9, 2026
Merged

dyoshikawa merged 9 commits into
mainfrom
sec2-perms

Conversation

@dyoshikawa

@dyoshikawa dyoshikawa commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes four permission-translator findings from the 2026-11-07 security audit (run-2). In each one a generated config auto-approved an input that a stricter canonical rule restricts. The canonical order is deny > ask > allow.

  • Skipped ask beside a covering allow (rulesync:permissions:ask-skipped-covering-allow-kept): Cursor, Vibe, Codex CLI (webfetch), TRAE (webfetch) and Copilot CLI (webfetch) have no ask tier there, so they skip ask rules. They still wrote the broader allow, though, e.g. Shell(git *) beside a git push * ask. The new withholdAllowsShadowedByAsks (src/features/permissions/shadowed-allows.ts) withholds every allow an ask covers. A catch-all * allow falls back to the tool's prompt instead: Vibe gets permission = "ask" instead of "always". A warning names each withheld allow. Takt now derives readonly from any ask, as it already did from any deny.
  • Junie first-match order (rulesync:permissions:junie:first-match-wins-allow-emitted-before-restriction): each group now lists every ask (including denies downgraded to ask) ahead of every allow. The sort is stable.
  • All-tools * restrictions honored only on bash (rulesync:permissions:all-tools-restriction-honored-only-on-bash): the new shared honorAllToolsRestrictions step handles a tool that cannot write a pattern-specific * deny/ask. In every category it withholds each allow the restriction covers, and it never writes a literal *(<pattern>) entry (Cursor, Reasonix, Qwen Code, Devin, Antigravity). It also gives Reasonix, Qwen Code and Kimi Code the bash handling they were missing. The catch-all * keeps its existing native handling wherever the tool writes one (Continue, AugmentCode, Grok CLI, Qoder, Command Code, CodeBuddy). OpenCode is last-match-wins, so the restriction is restated after the allows that would otherwise override it. The documented {"*": {"*": "ask"}, ...} default idiom is left untouched.
  • Antigravity unrepresentable deny (rulesync:permissions:antigravity:unrepresentable-glob-deny-skipped-catchall-allow-kept): a deny/ask that Antigravity cannot express is skipped, and it now withholds the allows of the same action that cover it. Example: read_file beside a skipped **/.env deny.

docs/reference/file-formats.md is updated for each target, and docs-content.ts is regenerated.

Test plan

  • src/features/permissions/shadowed-allows.test.ts runs each audit payload through every affected adapter. 18 of its cases fail on origin/main without the translator changes.
  • Updated expectations: Junie order (unit + e2e), Cursor catch-all ask, Qoder * deny.
  • pnpm cicheck passes, and so does the full pnpm test:e2e suite (1518 tests).

Follow-up fixes (review round)

  • OpenCode restatement no longer loosens anything. A restated * rule never lands after an overlapping stricter one: the tail of a key is asks first, then denies, and an own or * deny that overlaps a restated ask is moved after it. A * deny is also restated over an overlapping ask, not only an allow. Under a key whose own catch-all denies, the ask is restated as a deny. So {"*": {".env": "ask"}, "read": {"*": "allow", ".env*": "deny"}} still denies .env, and {"*": {".env": "deny"}, "read": {"*": "ask"}} ends with read .env deny.

  • **/ zero-segment gap. The overlap test widens **/ and a trailing /** to * on both sides, so it can only report more overlaps, never fewer. {"*": {"**/.env": "deny"}, "read": {".env": "allow"}} and {"*": {".env": "deny"}, "read": {"**/*": "allow"}} no longer leave a read_file allow on Antigravity. webfetch patterns are also compared lowercased and without a scheme, in addition to the raw comparison.

  • More adapters migrated. Vibe, TRAE, Codex CLI (webfetch domains) and Crush now go through honorAllToolsRestrictions, so a * deny/ask withholds the allows it covers, with the same warning. Crush keeps those tools out of allowed_tools. Its safe_commands/blocked_commands logic from feat(permissions): map crush bash pattern rules to safe_commands and blocked_commands #3818 is unchanged and still owns bash.

  • AugmentCode. A tool whose allows were all withheld keeps getting the blanket all-tools deny/ask fallback rather than AugmentCode's own default. That default would run a read-only tool such as view on the very input the restriction names, so this is now the documented behaviour, with updated warning text and comments and a test. Nothing becomes an allow.

  • Visibility. When a * ask of the same spelling replaces a bash allow, the warning now names it. The stale "narrower * patterns are shell restrictions" comments in CodeBuddy, Command Code and Qoder are updated. docs/reference/file-formats.md lists every adapter. New adapter tests cover CodeBuddy, Command Code, Continue, Grok CLI, Letta Code, Kiro permissions.yaml and AugmentCode.

  • Round 2:

    • Vibe: a withheld catch-all allow is written as permission = "ask", and a * path deny is written into the denylist. A stale allowlist entry or permission = "always" left by a withheld allow is removed.
    • Kilo now shares OpenCode's last-match restatement (moved to last-match-restate.ts). OpenCode also moves an own deny of the same spelling that absorbs a restated ask to the tail.
    • Overlap test: a trailing * is read as optional and a {a,b} alternation as overlapping everything. A pathless webfetch allow is also compared as its whole host, which covers Codex CLI and TRAE.
    • Antigravity compares what the emitted target grants (path subtree, . as the whole workspace, command word prefix, domain) against both skipped and * restrictions.
    • Category rules: CodeBuddy, Qoder, Command Code, Letta Code and Qwen Code write * path/URL denies and asks as category rules (Read(.env)), so a withheld read no longer falls back to an auto-approving default.
    • Codex CLI copies * path denies into its filesystem table as "<pattern>" = "deny", and path asks as read-only access. This only happens when a filesystem category is stated and the pattern has no whitespace, so the sandbox only gains restrictions.
    • Copilot in VS Code writes * restrictions as false entries (terminal map, and the edits/URL maps when they read as a path/URL).
  • Round 3:

    • URL comparison: webfetch patterns are compared as URLs (lowercased, scheme stripped, host/port/path compared separately; a pathless pattern covers every URL on that host and its subdomains). Unrelated restrictions such as rm -rf * or example.org/private/* no longer withhold a github.com allow, while evil.example still covers https://evil.example/*. Antigravity uses the same comparison.
    • Codex CLI: * path asks land under read like a direct read ask, so they become deny and also deny a narrower write allow they cover. A catch-all * deny withholds every filesystem allow.
    • Copilot in VS Code: a catch-all * restriction is written as "*": false where it wins. URLs are restated lowercased and without a scheme. A restriction that cannot be written into the map withholds the true entries it overlaps.
    • Vibe: permission = "never" under a catch-all * deny. On-disk allowlist entries that a current deny/ask covers are removed from managed tables.
    • *(<pattern>) entries: Cursor, Reasonix, Qwen Code, Devin and Antigravity write *(<pattern>) deny/ask entries again, as main did. No primary source shows these tools read a * tool name literally, and an entry that never matches is harmless.
  • Round 3 follow-up: URL patterns are also compared as whole strings, so *://evil.com/*, *.pdf and brace alternations still withhold what they cover; only whitespace patterns are exempt. Copilot in VS Code keeps the path case in restated URLs, and Vibe compares web_fetch allowlist entries as URLs.

User-visible behaviour change: the stricter rule wins whatever its width, so a narrow * restriction now also withholds catch-all allows. For example, {"*": {"git push *": "ask"}, "read": {"*": "allow"}} no longer writes a read allow on the adapters listed in the docs, because read's * names every input. To keep the other categories' allows, scope a command-only restriction under bash instead of *.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QUBBebviXSBQtiRAmDopZ7

dyoshikawa and others added 4 commits November 7, 2026 11:46
…ls restrictions

Several permission translators let a canonical allow auto-approve an input
that a stricter rule restricts (canonical order is deny > ask > allow):

- Cursor, Vibe, Codex CLI (webfetch), TRAE (webfetch) and Copilot CLI
  (webfetch) skip ask rules but kept the allows covering them. A new
  withholdAllowsShadowedByAsks step withholds those allows (a catch-all
  allow falls back to the tool's prompt, Vibe's permission = "ask") and
  names them in a warning. Takt derives readonly from any ask, as from
  any deny.
- Junie is first-match-wins, so every ask (including downgraded denies)
  is now written ahead of every allow in each group.
- A pattern-specific deny/ask under the all-tools '*' category was
  honored only on bash. A shared honorAllToolsRestrictions step now
  withholds the covered allows in every category for the tools that
  cannot write such a rule, never emits a literal '*(<pattern>)' entry,
  and brings Reasonix, Qwen Code and Kimi Code the bash handling they
  lacked. OpenCode restates the restriction after the allows that would
  override it under last-match-wins.
- Antigravity CLI/IDE withhold the allows of an action whose deny/ask
  they had to skip as unrepresentable.

Found by the 2026-11-07 security audit (run-2):
rulesync:permissions:ask-skipped-covering-allow-kept,
rulesync:permissions:junie:first-match-wins-allow-emitted-before-restriction,
rulesync:permissions:all-tools-restriction-honored-only-on-bash,
rulesync:permissions:antigravity:unrepresentable-glob-deny-skipped-catchall-allow-kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179ZomNiDQHCzgoxeRVmfth
…ir own

Cursor folds every per-tool MCP category into its Mcp surface and Antigravity into the mcp action, so an ask on one MCP tool withheld unrelated MCP tools' allows. Group MCP tool categories by category instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179ZomNiDQHCzgoxeRVmfth
@dyoshikawa

Copy link
Copy Markdown
Owner Author

Review notes (batch triage, 2026-11-09). CI is green, but this is held back for now: it conflicts with main, and one finding is a loosening the PR itself introduces.

Conflict. git merge-tree shows real conflicts only in src/features/permissions/reasonix-permissions.ts and src/generated/docs-content.ts. For Reasonix:

  • keep this PR's convertRulesyncToReasonixPermissions({ config, logger }) and the honorAllToolsRestrictions({ ..., dropAllToolsPatterns: true }) call;
  • take main's loop over toReasonixToolNames(category) (fix(permissions): write Reasonix agent rules under spawn_agents too #3814 writes both task and spawn_agents), applying the withhold once outside the loop so both names get the same result;
  • pass the withheld lists to main's warnOnLoosenedAgentEntries;
  • regenerate docs-content.ts rather than hand-merging it.

Devin (#3816), Codex (#3817) and AugmentCode merge cleanly with no semantic interaction.

Findings (from static review; the probes were not run locally):

  1. mid — OpenCode: a deny can become an ask. restateAllToolsRestrictionsLast (opencode-permissions.ts ~448-481) re-appends * asks at the end of each key, and strictest only compares the same spelling. {"*": {".env": "ask"}, "read": {"*": "allow", ".env*": "deny"}} → read: {"*":"allow", ".env*":"deny", ".env":"ask"}; with last-match, .env now prompts instead of being denied (main denied it). Related: {"*": {".env": "deny"}, "read": {"*": "ask"}} leaves read.*: ask last, so the deny is not restated for keys that only hold asks.
  2. mid — **/ never matches zero segments in the overlap test (shadowed-allows.ts createShadowingRestrictionsTest, flat glob in src/utils/glob.ts). {"*": {"**/.env": "deny"}, "read": {".env": "allow"}} keeps the allow; {"*": {".env": "deny"}, "read": {"**/*": "allow"}} likely does too, and on Antigravity the .env deny is also dropped by dropAllToolsPatterns, so the read is auto-approved. Widening **/ to * on both sides before comparing errs safe. (Incomplete fix, not a regression vs main.)
  3. mid — AugmentCode: a withheld catch-all allow turns into a whole-tool deny/ask. Once read: {"*": "allow"} is withheld, view drops out of categoriesWithOwnEntries and synthesizeManagedToolFallbackEntries writes the stricter * action for the whole tool ({"*": {".env": "deny"}, "read": {"*": "allow"}} → view deny). Stricter, but it contradicts the "falls back to the tool's own prompt" wording and the warning text at ~878/986.
  4. mid — same hole left in unmigrated adapters: Vibe (still honorAllToolsOnBash, drops the * category), TRAE and Codex webfetch (withhold only looks at asks), Crush (* is warned and skipped). {"*": {".env": "deny"}, "read": {"*": "allow"}} still emits read_file always (Vibe) / view in allowed_tools (Crush). Either migrate them or list them as out of scope in the docs.
  5. mid (visibility) — a narrow shell * restriction ({"*": {"git push *": "ask"}}) now withholds every category's {"*": "allow"} across 17 adapters (Cursor's documented example emits zero allows; Takt drops to readonly). Consistent with "stricter wins", but it should be called out in the release notes, and the "Narrower * patterns are shell restrictions" comments in codebuddy/commandcode/qoder are now stale.
  6. low — webfetch overlap is a plain string glob: no case folding, scheme stripping or domain/prefix containment (Codex, TRAE, Copilot CLI).
  7. low — Command Code: with writesAllToolsCatchAll, {"*": {"*": "deny"}, "bash": {"git *": "allow"}} now emits Shell(git *); the file's own comment says bare * is only honoured in aggressive mode, so check upstream.
  8. low — no warning when a bash allow is replaced by a same-pattern * ask (shadowed-allows.ts ~134-138); Vibe catch-all ask + pattern allow still differs from Cursor; no adapter tests for the new withholds in CodeBuddy, Command Code, Continue, Grok, Letta, Kiro capability and AugmentCode; path spellings (./.env, ~/ vs absolute, case) are not normalised.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@dyoshikawa The CI checks on this pull request are currently failing.

Please review the failing checks and push a fix. If you need help, leave a comment and a maintainer will follow up.

…lows

- OpenCode: restated '*' rules never land after an overlapping stricter rule. Asks come before denies, an own or '*' deny that overlaps a restated ask is moved after it, a '*' deny is restated over an overlapping ask too, and an ask under a key whose own catch-all denies is restated as a deny.

- The overlap test widens '**/' and a trailing '/**' to '*', so '**/.env' overlaps '.env' and '**/*' overlaps everything (Antigravity no longer auto-approves '.env' reads). webfetch patterns are also compared lowercased and without a scheme.

- Vibe, TRAE, Codex CLI webfetch and Crush now use honorAllToolsRestrictions, so a '*' deny/ask withholds the allows it covers (Crush keeps those tools out of allowed_tools; safe_commands/blocked_commands are unchanged).

- A bash allow replaced by a same-pattern '*' ask is now named in the warning.

- AugmentCode: document that a tool whose allows were all withheld gets the blanket all-tools fallback, and refresh stale comments in CodeBuddy, Command Code and Qoder about narrow '*' patterns. Docs list every adapter and state that a narrow '*' restriction also withholds catch-all allows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Claude-Session: https://claude.ai/code/session_01QUBBebviXSBQtiRAmDopZ7
- Vibe: a withheld catch-all allow becomes permission = "ask", a '*' path deny is written into the denylist, and the allowlist entry or permission = "always" an earlier generate wrote for a withheld allow is removed.

- Kilo shares OpenCode's last-match restatement (moved to last-match-restate.ts). OpenCode moves an own deny that absorbs a restated ask to the tail too.

- The overlap test reads a trailing ' *' as optional and a brace alternation as overlapping everything; a pathless webfetch allow is also compared as its whole host (Codex CLI, TRAE).

- Antigravity compares the scope the emitted target grants (path subtree, command word prefix, domain) against both skipped and '*' restrictions.

- CodeBuddy, Qoder, Command Code, Letta Code and Qwen Code write '*' path/URL denies and asks as category rules (Read(.env)); Codex CLI copies '*' path restrictions into its filesystem rules; Copilot in VS Code writes '*' restrictions as false entries and honors them on the terminal map.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Claude-Session: https://claude.ai/code/session_01QUBBebviXSBQtiRAmDopZ7
- webfetch patterns are compared as URLs, host/port/path separately, so a host allow is no longer withheld by unrelated command or path restrictions, while a pathless restriction still covers every URL on its host. Shared by createCategoryShadowTest and Antigravity.

- Codex CLI: '*' path asks land under read like a direct read ask (deny, and a narrower write allow they cover is denied); a catch-all '*' deny withholds every filesystem allow.

- Copilot in VS Code: a catch-all '*' restriction is written as "*": false where it wins, URLs are restated lowercased without a scheme, and restrictions it cannot write withhold the true entries they overlap.

- Vibe: a withheld catch-all under a catch-all '*' deny becomes permission = "never"; on-disk allowlist entries a current deny/ask covers are removed from managed tables.

- Cursor, Reasonix, Qwen Code, Devin and Antigravity write '*(<pattern>)' deny/ask entries again, as main did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Claude-Session: https://claude.ai/code/session_01QUBBebviXSBQtiRAmDopZ7
urlPatternsOverlap now also runs the whole-string glob comparison (widened as before, raw and lowercased without a scheme), so '*://evil.com/*', '*.pdf' or a brace alternation still withhold the webfetch allows they cover; only patterns with whitespace are exempt. A glob-spelled scheme is stripped before the part-wise comparison. Copilot in VS Code keeps the path case when restating into the urls map, and Vibe compares web_fetch allowlist entries as URLs when retiring them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Claude-Session: https://claude.ai/code/session_01QUBBebviXSBQtiRAmDopZ7
@dyoshikawa
dyoshikawa merged commit 54267ff into main Nov 9, 2026
10 checks passed
@dyoshikawa
dyoshikawa deleted the sec2-perms branch November 9, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant