GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): check each Code Mode fetch redirect against webfetch rules by rekram1-node · Pull Request #60502 · anomalyco/opencode

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Oct 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Problem

Code Mode fetch checked only the first URL against the webfetch rules, then let the runtime follow redirects on its own. Any allowed URL that redirects could reach a denied one:

deny rule: https://evil.com/*

webfetch:  safe.com/r → 302 → evil.com → checked, blocked
fetch:     safe.com/r → 302 → evil.com → not checked, fetched

Change

fetch now follows redirects itself (redirect: "manual") and checks each new URL with permission.assertNotDenied, the same hop check the webfetch tool uses. A denied hop is never requested, and the promise rejects.

fetch(url)
  assert webfetch(url)                  (unchanged: may ask)
  loop: request → 3xx + location?
          check deny rules for next URL  ← NEW (never asks)
          follow, like a browser would

Following by hand keeps the standard fetch behavior programs expect:

  • 303, and 301/302 after a POST, become a GET without a body.
  • authorization, cookie and proxy-authorization are dropped when the redirect changes origin.
  • Up to 20 redirects, same as fetch. Only http(s) targets.
  • response.url is the final URL and response.redirected is set.
  • One 30s timeout covers the whole chain.

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>
    .dot { animation: hop 3s ease-in-out infinite; }
    .x { opacity: .25; animation: deny 3s ease-in-out infinite; }
    @keyframes hop { 0% { transform: translate(0,0); opacity: 1 } 35% { transform: translate(70px,0) } 55% { transform: translate(70px,0) } 75% { transform: translate(118px,0); opacity: 1 } 85%, 100% { transform: translate(118px,0); opacity: 0 } }
    @keyframes deny { 0%, 70% { opacity: .25 } 78%, 95% { opacity: 1 } 100% { opacity: .25 } }
    @media (prefers-reduced-motion: reduce) { .dot, .x { animation: none } .x { opacity: 1 } }
  </style>
  <rect x="8" y="24" width="52" height="24" rx="6" opacity=".6"/>
  <text x="34" y="40" font-family="ui-monospace, monospace" font-size="10" text-anchor="middle" fill="currentColor" stroke="none">fetch</text>
  <path d="M62 36 H96" opacity=".35" stroke-dasharray="3 4"/>
  <rect x="98" y="24" width="40" height="24" rx="6" opacity=".4"/>
  <text x="118" y="40" font-family="ui-monospace, monospace" font-size="10" text-anchor="middle" fill="currentColor" stroke="none">302</text>
  <path d="M140 36 H168" opacity=".35" stroke-dasharray="3 4"/>
  <circle class="dot" cx="64" cy="36" r="4" fill="currentColor" stroke="none"/>
  <path d="M186 18 L202 24 V36 C202 46 194 52 186 55 C178 52 170 46 170 36 V24 Z" opacity=".8"/>
  <path class="x" d="M180 31 L192 43 M192 31 L180 43"/>
  <circle cx="224" cy="36" r="9" opacity=".25"/>
</svg>

Out of scope

  • The check and the request can still disagree on the URL's spelling (case, default port). That's a separate small PR covering both fetch and webfetch.

Verification

  • New test in packages/core/test/tool-execute.test.ts: a redirect to a URL denied for webfetch is never requested. It fails on dev.
  • bun test ./test/tool-execute.test.ts in packages/core: 13 pass. bun typecheck is clean.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
fix(core): check each Code Mode fetch redirect against webfetch rules
c6e3ce1
@github-actions github-actions Bot added the contributor label Oct 30, 2026
opencodejr[bot]
opencodejr Bot reviewed Oct 30, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

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 change looks sound. On the base, the PR's new deny-on-redirect test fails (the redirect to the denied URL is followed unchecked). With the PR it passes, along with the tool-execute, codemode and tool-webfetch tests (127 pass), and typecheck:tsc is clean. I also checked that a redirect with an invalid Location and a redirect loop reject in a way the program can catch.

Public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
test(core): keep one redirect test
17c6a05
opencodejr[bot]
opencodejr Bot reviewed Oct 30, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

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 simplifies the tests, and the single redirect test is small and clear. It fails on the base (the redirect to the denied URL is followed) and passes with the PR, along with the rest of tool-execute.test.ts (13 pass). typecheck:tsc is clean. The fetch.ts fix is unchanged since my last review.

Public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
rekram1-node merged commit b5b9bdd into dev Nov 2, 2026
15 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node
rekram1-node deleted the fetch-redirects branch November 2, 2026 02:09
@opencodejr opencodejr Bot mentioned this pull request Nov 2, 2026
fix(core): match web permissions against the URL that is requested #60505
Merged
@rekram1-node rekram1-node mentioned this pull request Nov 6, 2026
fix(core): match webfetch rules against the URL as written #62373
Merged
3 of 6 tasks
@amrkmn amrkmn mentioned this pull request Nov 7, 2026
opencode 2.2.6 amrkmn/homebrew-tap#1217
Closed
1 task
This was referenced Nov 7, 2026
feat: opencode release v2.2.6 sprisa/opencode-server#84
Merged
Tool release: OpenCode 2 v2.2.6 (was v2.2.5) agent-sh/agnix#1808
Closed
AbizardShafwan pushed a commit to AbizardShafwan/opencode that referenced this pull request Nov 9, 2026
@rekram1-node Abizard Sulaiman
fix(core): check each Code Mode fetch redirect against webfetch rules (…
4576a8c
…anomalyco#60502)
This was referenced Nov 9, 2026
Check xor against OpenCode v2.2.0 (breaking plugin changes) QuaanNguyen/xor#87
Open
Dataset tool coverage: cover every built-in tool in OpenCode V2, Claude Code and Codex QuaanNguyen/xor#72
Open
Checker judges the right input: retries, very long calls, rewritten arguments, direct MCP calls, and parallel sub-agent calls QuaanNguyen/xor#84
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

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.

1 participant

@rekram1-node
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.