GeezerVison is showing github.com — fix(core): apply webfetch URL rules to redirect targets by rekram1-node · Pull Request #59748 · anomalyco/opencode
Conversation
rekram1-node
commented
Oct 27, 2026
•
edited by opencodejr
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Problem
webfetch checked the URL rules for the URL the model asked for, then let fetch follow redirects on its own. So a webfetch deny rule (or a policy that only allows certain hosts) didn't apply to wherever the page redirected.
Change
webfetch now follows redirects itself and checks each new URL against the rules first. It never prompts for a redirect, it only stops when a rule denies the target.
fetch url (asks as before)
302 → next url
rules deny next? → stop, "Permission denied: webfetch"
otherwise → follow it
... up to 10 redirects
- Adds
Permission.assertNotDenied: same evaluation as assert (config, session rules, saved approvals, plugin hooks) but it never asks, it only fails on deny.
- Redirects to non http(s) URLs are rejected, and chains stop after 10 redirects.
- No redirect means no change in behavior. Default setups see no new prompts.
Out of scope
A redirect to a URL that would normally ask is still followed without asking.
Verification
bun test test/permission.test.ts test/tool-webfetch.test.ts test/plugin/permission-assert.test.ts in packages/core: 200 pass
bun run check from the repo root: passes
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. A redirect to a URL the rules deny is followed on the base and blocked with this change.
I couldn't run it through the TUI because the simulation backend blocks all outbound HTTP. Instead I ran a temporary test with the real fetch client and a local server where /redirect returns 302 to a denied /secret. On the base, webfetch returned the secret body. With this PR, it failed with "Permission denied: webfetch". Managed tool.use deny policies also apply to redirects, since they run through the same evaluate hook. The three test files pass (200 tests). The source type-checks cleanly with tsc; the package typecheck script can't run here because bun check isn't available.
Public API unchanged: Permission.Interface.assertNotDenied is internal to core, and the plugin, SDK, HTTP API and config are untouched.
No blocking concerns.
Related: #55232
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.
This was referenced Oct 29, 2026
This was referenced Nov 3, 2026
brentyates-swx
pushed a commit
to swxtchio/swx-opencode-archive
that referenced
this pull request
Nov 3, 2026
)
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)
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
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.
|