GeezerVison is showing github.com — fix(core): match web permissions against the URL that is requested by rekram1-node · Pull Request #60505 · anomalyco/opencode
Conversation
rekram1-node
commented
Oct 30, 2026
•
edited by opencodejr
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Problem
webfetch rules were matched against the URL exactly as the model wrote it, but the request goes to the parsed, normalized URL. Rule matching is case-sensitive, so a different spelling of the same URL slipped past a deny rule:
deny rule: https://evil.com/*
webfetch({ url: "HTTPS://EVIL.COM/x" })
check: "HTTPS://EVIL.COM/x" → no match → allowed
request: https://evil.com/x → reaches evil.com
Default ports (https://evil.com:443/x) worked the same way. This affected both the webfetch tool and Code Mode fetch.
Change
Both parse the URL once and use the normalized form (URL.href) for the permission check and for the request, so the rule sees exactly what gets fetched.
- permission.assert({ resources: [input.url] }) // as written
- request(input.url)
+ const url = new URL(input.url).href // lowercase scheme and host, no default port
+ permission.assert({ resources: [url] })
+ request(url)
Paths keep their case, since they're case-sensitive. The webfetch tool's output and error messages still show the URL the model passed. An invalid URL in Code Mode fetch now rejects with a TypeError before the permission check, instead of after.
Visual
<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<style>
.a { animation: fadeA 3s ease-in-out infinite; }
.b { opacity: 0; animation: fadeB 3s ease-in-out infinite; }
@keyframes fadeA { 0%, 35% { opacity: 1 } 50%, 100% { opacity: 0 } }
@keyframes fadeB { 0%, 40% { opacity: 0 } 55%, 95% { opacity: 1 } 100% { opacity: 0 } }
@media (prefers-reduced-motion: reduce) { .a, .b { animation: none } .a { opacity: 0 } .b { opacity: 1 } }
</style>
<text class="a" x="12" y="40" font-family="ui-monospace, monospace" font-size="11" fill="currentColor" stroke="none">HTTPS://EVIL.COM/x</text>
<text class="b" x="12" y="40" font-family="ui-monospace, monospace" font-size="11" fill="currentColor" stroke="none">https://evil.com/x</text>
<path d="M150 36 H172" opacity=".35" stroke-dasharray="3 4"/>
<path d="M196 18 L212 24 V36 C212 46 204 52 196 55 C188 52 180 46 180 36 V24 Z" opacity=".8"/>
<path class="b" d="M190 31 L202 43 M202 31 L190 43"/>
</svg>
Verification
bun test for tool-execute, tool-webfetch and codemode in packages/core pass. bun typecheck and bun run typecheck:tsc are clean.
Added by the opencode bot (AI-generated).
Related: #55232
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I ran the new tool-webfetch / tool-execute tests on the base and with this change. On the base, both new tests fail: the rule is checked against HTTPS://Example.COM:443/Path and HTTP://LOCALHOST:<port>/Path, the spelling the model gave. With the change, all 104 pass, and typecheck:tsc in packages/core is clean.
The permission check now uses the same URL.href form that redirect targets were already checked in, so the first request and redirects behave the same way.
Public API is unchanged.
One heads-up, not blocking: a rule for an exact bare origin with no wildcard (e.g. https://docs.example.com) no longer matches, because the request is now checked as https://docs.example.com/. An allow rule like that will start prompting again. A deny rule like that was already easy to get around by adding the slash.
Related: #55232
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new commit only removes the two tests the pull request had added. The source change is the same one I reviewed before, and tool-webfetch / tool-execute in packages/core still pass (102 tests). Public API is unchanged. Nothing new to raise.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest commit is a rebase onto dev, which now includes #60502's redirect handling in Code Mode fetch. After the rebase, the permission check and the first request both use the normalised URL, the same form redirect targets were already checked in. tool-webfetch, tool-execute and the codemode tests in packages/core pass (126 tests) and typecheck:tsc is clean. The original mixed-case, default-port webfetch test from this pull request still passes against the new head. Public API is unchanged. Nothing new to raise.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
harishpixous-commits
pushed a commit
to harishpixous-commits/Harishcode
that referenced
this pull request
Nov 2, 2026
The webfetch tool validated the request URL with new URL() but matched
permission rules and fetched using the raw input string, so a
non-canonical URL (scheme/host case, default port, dot segments) evaded
rules written for its canonical form (HTTPS://EVIL.COM vs a deny on
https://evil.com/*). Normalize once via URL.href and use the canonical
form for the permission resources, the fetch target, and the
Cloudflare-challenge retry, so matching and egress always refer to the
same URL. Redirect-hop checks were already normalized and are unchanged.
Ports the webfetch half of anomalyco/opencode#60505 (upstream commit
805a4b820). The Code Mode half is already covered by the custom
mediated fetch guard (c4e4f16/c4a364c0), which normalizes before its
approval and per-hop checks; those stronger protections are untouched.
Tests (offline, synthetic HttpClient + recording permission layer):
negative controls fail before the fix (raw resources recorded; denied
canonical URL fetched via non-canonical form) and pass after. Covered:
scheme/host case, default port, dot segments, deny + allow controls,
zero egress on deny, credentials-in-URL and percent-encoding documented
as distinct resources (same semantics as upstream).
This was referenced Nov 3, 2026
brentyates-swx
pushed a commit
to swxtchio/swx-opencode-archive
that referenced
this pull request
Nov 3, 2026
…nomalyco#60505)
Port canonical URL identity into the fork's existing V2 and V1 webfetch owners, using the parsed HTTP(S) href for initial policy matching and transport. Redirect targets remain resolved and checked by their serialized URL. Preserve the V1 image attachment and V2 unsupported-attachment contracts.
This is a partial port of anomalyco#60505: exclude its packages/core/src/codemode/fetch.ts changes because that Code Mode API is not a drop-in to this fork's current path. Adapted owners: packages/core/src/tool/webfetch.ts and packages/opencode/src/tool/webfetch.ts.
(cherry picked from commit 805a4b8)
brentyates-swx
added a commit
to swxtchio/swx-opencode-archive
that referenced
this pull request
Nov 4, 2026
* chore(core): plan webfetch URL policy backport
1. Cherry-pick the redirect-denial donor first and adapt deny-only checks to the current V2 permission service and the V1 session-bound policy path.
2. Cherry-pick the canonicalization donor second; use parsed HTTP(S) serialization for policy and transport in both adapters, while leaving Code Mode out.
3. Add executor-driven regressions for canonical allow/deny, redirect targets and chains, ask-only destinations, unsupported URLs, and live transport request evidence; demonstrate focused red/green absence proofs.
4. Record donor provenance, compatibility adaptations, fork paths, and executed focused results in CHANGESET.md, then run the required crew gates.
* fix(core): apply webfetch URL rules to redirect targets (anomalyco#59748)
Port redirect denial into the current V2 built-in and separate V1 adapter. The V2 deny-only check uses the explicit invocation agent; V1 binds the merged agent/session rules through SessionTools. Resolve and deny-check each HTTP(S) redirect before transport; allow and ask-only destinations continue without a new prompt. Preserve both adapters' existing output contracts and Cloudflare retry behavior. Canonical URL identity remains the next donor's scope.
(cherry picked from commit 17837a2)
* fix(core): match web permissions against the URL that is requested (anomalyco#60505)
Port canonical URL identity into the fork's existing V2 and V1 webfetch owners, using the parsed HTTP(S) href for initial policy matching and transport. Redirect targets remain resolved and checked by their serialized URL. Preserve the V1 image attachment and V2 unsupported-attachment contracts.
This is a partial port of anomalyco#60505: exclude its packages/core/src/codemode/fetch.ts changes because that Code Mode API is not a drop-in to this fork's current path. Adapted owners: packages/core/src/tool/webfetch.ts and packages/opencode/src/tool/webfetch.ts.
(cherry picked from commit 805a4b8)
* docs(opencode): record webfetch URL policy backport
* fix(webfetch): cancel discarded response bodies
Cancel unread redirect and rejected-response bodies in the V1 and V2 executors, with live streaming regressions for release paths. Record the adoption split as partly upstream.
Claude-Session: ses_e5cdbcb11ffeK5x75lZZqBWCmy
* docs(opencode): record webfetch response release proofs
Claude-Session: ses_e5cdbcb11ffeK5x75lZZqBWCmy
---------
Co-authored-by: Aiden Cline <[email protected]>
This was referenced Nov 4, 2026
This was referenced Nov 6, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|