Skip to content

fix(permissions): withhold webfetch allows that differ only by userinfo or query - #3902

Merged
dyoshikawa merged 3 commits into
mainfrom
resolve-issue-3822-userinfo-query
Nov 19, 2026
Merged

dyoshikawa merged 3 commits into
mainfrom
resolve-issue-3822-userinfo-query

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

Fixes the remaining part of #3822 item 4: a webfetch allow written with userinfo, a query or a fragment was not withheld by a * deny/ask on the same host or path.

{ "*": { "example.com": "deny" }, "webfetch": { "https://[email protected]/x": "allow" } }   // allow was kept
{ "*": { "example.com/x": "deny" }, "webfetch": { "https://example.com/x?y=1": "allow" } }  // allow was kept
{ "*": { "*.pdf": "deny" }, "webfetch": { "https://example.com/doc.pdf?dl=1": "allow" } } // allow was kept

urlPatternsOverlap (src/features/permissions/shadowed-allows.ts) now also reads the allow without its userinfo (everything up to the last @ before the first /), query and fragment, both in the part-by-part comparison and in the whole-string comparison. These readings are added next to the original one and ORed, so the change can only add overlaps. Withholding adapters therefore only withhold more. No allow is added and no deny/ask is loosened. The restriction side is unchanged, so a ? glob in a restriction is still read as a glob.

The trailing-dot part of item 4 was already fixed in #3851. This PR does not touch last-match-restate.ts or single-action-collapse.ts (#3897).

Safety check

  • Compared urlPatternsOverlap on this branch with origin/main over 60,000 random restriction/allow pairs built from schemes, userinfo, hosts, ports, paths, queries, fragments and globs. Result: 0 overlaps lost, 2,078 added.
  • The new tests fail on main and pass here.

Tests

  • shadowed-allows.test.ts: new overlap cases (userinfo, user:pass@host:port, query, fragment, pathless host with a query, *.pdf vs doc.pdf?dl=1, multiple @). New non-overlap cases (a different host behind userinfo, /a/ only inside the query). New honorAllToolsRestrictions test that keeps an unrelated host.
  • Docs: one sentence added to the webfetch overlap paragraph in docs/reference/file-formats.md (and regenerated src/generated/docs-content.ts).
  • pnpm cicheck passes.

Items of #3822 still open

  • 3: by design (whitespace never names a URL)
  • 5: needs a maintainer decision (restating into a read category the config does not have)
  • 6: second and third bullets (OpenCode/Kilo catch-all {"*":{"*":"deny"}} restate, integer-like key order)
  • 7, 8, 11 and 12

Refs #3822

🤖 Generated with Claude Code

https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4

dyoshikawa and others added 3 commits November 20, 2026 00:36
…fo or query

A webfetch allow written with userinfo, a query or a fragment
(`https://[email protected]/x`, `example.com/x?y=1`) was not withheld by
a `*` deny or ask on `example.com` or `example.com/x`, since the
userinfo was read as part of the host and the query as part of the path.

`urlPatternsOverlap` now also compares the allow without its userinfo,
query and fragment, in addition to its original reading, so the change
can only add overlaps (withhold more) and never lets through an allow
that was withheld before.

Refs #3822

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
A `?` is a single-character glob in rulesync patterns. The extra
userinfo/query-stripped reading of a webfetch allow cut everything from
the first `?`, so a host glob such as `git?ub.com` was also read as
`git`. Only a `?` or `#` in the path now starts a query or fragment for
that reading; the host keeps it.

Refs #3822

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…erinfo-query

# Conflicts:
#	docs/reference/file-formats.md
#	src/generated/docs-content.ts
@dyoshikawa
dyoshikawa merged commit c6ffab6 into main Nov 19, 2026
10 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-3822-userinfo-query branch November 19, 2026 18:36
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