Skip to content

fix(permissions): treat pathless host allows as any path and keep the host of host//path - #3831

Merged
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-3822-url-overlap-gaps
Nov 12, 2026
Merged

dyoshikawa merged 2 commits into
mainfrom
resolve-issue-3822-url-overlap-gaps

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

What

Fixes items 1 and 2 of #3822 in src/features/permissions/shadowed-allows.ts, plus the matching change in the Copilot (VS Code) URL map.

  1. Pathless host allow vs. suffix-glob restriction. A pathless webfetch allow such as example.com names every path on that host. When urlPatternsOverlap compares the whole strings, it now also tries the allow as <host>/* against any restriction that has no / (*.pdf, *admin). With {"*":{"*.pdf":"deny"},"webfetch":{"example.com":"allow"}}, every adapter that withholds now withholds example.com. Only the allow side is widened, and only against restrictions without a /. Widening the restriction too would let .env overlap *.github.com, and *://evil.com/* overlap good.com, by matching through the *. Restrictions that contain a / are still compared host by host and path by path.
  2. host//path read as a scheme. stripUrlSchemeKeepingPathCase now strips a scheme only when a : comes before the //, or when the prefix is * or empty. So evil.com//x keeps its host evil.com. The overlap check still compares the old reading too (the new stripUrlSchemeLoosely). That means the change can only add overlaps: under the old reading evil.com//x overlapped x, and it still does.
    • Copilot in VS Code no longer turns such a restriction into a key like "admin": false (from Evil.com//Admin). It treats the restriction as one it cannot write, so it withholds every true URL entry the restriction overlaps under either reading (new helper hasDoubleSlashWithoutScheme).

The file-formats.md paragraph on webfetch overlap is updated to match, and docs-content.ts is regenerated.

Items 3-12 are out of scope.

Can this make any generated config looser?

No. I checked this with real generate runs, not only unit tests. For 16 probe inputs, I ran tsx src/cli/index.ts generate -f permissions -t '*' in fresh scratch project dirs, once on the base commit and once on this branch. That covers every target that writes a file: 27 files per probe, including Codex, Cursor, Copilot VS Code/CLI, Grok, Vibe, Reasonix, Devin, CodeBuddy, Qoder, Qwen, Command Code, Pool, Antigravity, OpenCode, Kilo, Claude Code and others. Then I ran diff -r on the two output trees.

Probes: the two inputs from the issue; ask variants; scheme and port allows (https://example.com, example.com:8080); in-category restrictions (webfetch: {"*.pdf": "ask", "*": "allow", ...}); evil.com//x against allows x, x/foo, https://x/, evil.com/z; Evil.com//Admin deny or ask against evil.com and against *; *//evil.com/*, http*//bad.com, //worse.com, *://evil.com/*, https://bad.com/admin; *evil.com/* and *://bad.com/* against good.com and *.github.com; .env and *admin together with *.github.com, example.com and example.com/docs/*.

Results:

  • Every changed output line is a removed allow, or a JSON/TOML line that changed only because a neighbouring entry was removed (a trailing comma, "allow": []). No allow entry appears in any output that was not there before. No deny or ask entry turned into an allow.
  • The only removed false entries are the Copilot VS Code keys written from the old misreading ("x": false, "admin": false). In each case, every true entry that the restriction overlaps under either reading is now withheld. So no remaining true entry covers those hosts, and VS Code still prompts for them.
  • Probes whose restriction has a / (*://evil.com/*, *evil.com/*, https://bad.com/admin) produce identical output. So good.com and *.github.com are not over-withheld.

Tests

  • urlPatternsOverlap cases: *.pdf/*admin vs. example.com; evil.com//x vs. evil.com and vs. x. Non-overlaps: .env vs. *.github.com, *://evil.com/* vs. good.com, *evil.com/* vs. good.com, evil.com//x vs. evil.com/z.
  • stripUrlSchemeKeepingPathCase table (scheme, http*://, *://, *//, //, Evil.com//Admin).
  • honorAllToolsRestrictions regression with both probe inputs from the issue.
  • Copilot VS Code: {"*":{"Evil.com//Admin":"deny"},"webfetch":{"evil.com":"allow","admin":"allow","good.com/z":"allow"}} writes only {"good.com/z": true}.

All new tests fail on the base commit. pnpm cicheck passes locally.

Refs #3822

🤖 Generated with Claude Code

https://claude.ai/code/session_01QUBBebviXSBQtiRAmDopZ7

dyoshikawa and others added 2 commits November 12, 2026 20:59
… host of host//path

A pathless webfetch allow such as `example.com` names every path on that
host, so it now overlaps a `*` restriction without a `/` such as `*.pdf`
and is withheld. `stripUrlSchemeKeepingPathCase` strips a scheme only when
a `:` precedes the `//` (or the prefix is `*` or empty), so `evil.com//x`
keeps its host `evil.com`. The earlier reading is still compared in the
overlap check, so the change only adds overlaps. Copilot in VS Code no
longer rewrites such a restriction into a key like `"admin": false`; it
withholds the `true` entries the restriction overlaps instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QUBBebviXSBQtiRAmDopZ7
# Conflicts:
#	src/generated/docs-content.ts
@dyoshikawa
dyoshikawa merged commit e18778a into main Nov 12, 2026
10 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-3822-url-overlap-gaps branch November 12, 2026 12:09
superbiche pushed a commit to superbiche/rulesync that referenced this pull request Nov 29, 2026
- Restate '*' path restrictions as Read rules even without a read
  category in CodeBuddy, Qoder, Command Code, Letta Code and Qwen Code,
  keeping existing entries of that category.
- Respell integer-like deny/ask keys a later looser rule overlaps as
  '<n>*' at the key's end for OpenCode-family last-match-wins tools.
- Skip Codex's default .git carve-out when a '*' deny covers .git.
- Write the '*' catch-all restriction into Vibe categories.
- Add the tests from the dyoshikawa#3831 review and compute the restriction
  actions and left-side glob tests once.

Closes dyoshikawa#3822

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
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