Repository navigation
fix(permissions): withhold webfetch allows that differ only by userinfo or query - #3902
Merged
Merged
Conversation
…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
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the remaining part of #3822 item 4: a
webfetchallow 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 kepturlPatternsOverlap(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.tsorsingle-action-collapse.ts(#3897).Safety check
urlPatternsOverlapon this branch withorigin/mainover 60,000 random restriction/allow pairs built from schemes, userinfo, hosts, ports, paths, queries, fragments and globs. Result: 0 overlaps lost, 2,078 added.mainand pass here.Tests
shadowed-allows.test.ts: new overlap cases (userinfo,user:pass@host:port, query, fragment, pathless host with a query,*.pdfvsdoc.pdf?dl=1, multiple@). New non-overlap cases (a different host behind userinfo,/a/only inside the query). NewhonorAllToolsRestrictionstest that keeps an unrelated host.docs/reference/file-formats.md(and regeneratedsrc/generated/docs-content.ts).pnpm cicheckpasses.Items of #3822 still open
readcategory the config does not have){"*":{"*":"deny"}}restate, integer-like key order)Refs #3822
🤖 Generated with Claude Code
https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4