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): match webfetch rules against the URL as written by rekram1-node · Pull Request #62373 · anomalyco/opencode

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 6, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Issue for this PR

Follow-up to #60505 and #61701.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Webfetch permission rules are matched against the URL the model requested, as written, the same as in v2.2.5.

#60505 and #61701 started matching against the parsed URL (new URL(...).href, fragment removed). Parsing adds a / path, lowercases the host and drops default ports, but rules from config are still compared as written. So rules users already have stopped matching:

Rule Request v2.2.5 Before this PR
*: allow, deny https://example.com https://example.com deny allow
*: ask, allow https://Example.org/* https://Example.org/x allow ask
*: ask, allow https://example.net:443/* https://example.net:443/x allow ask

This matches webfetch and Code Mode fetch rules against the URL as written again. It keeps rejecting URLs with credentials, drops the fragment from the URL as written before matching, and keeps the per-redirect checks from #60502. None of those change how an existing rule matches. Rule normalization (#62260) is no longer needed.

How did you verify your code works?

  • bun test test/tool-webfetch.test.ts test/tool-execute.test.ts test/permission.test.ts test/codemode test/tool-image-generate.test.ts test/config/agent.test.ts (packages/core): 302 pass
  • bun typecheck (packages/core): clean
  • The table above was checked end to end against the v2.2.5 binary and a build of dev.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" stroke="currentColor" font-family="ui-monospace,monospace" font-size="9">
  <style>
    .u{animation:u 3s ease-in-out infinite}
    .c{animation:c 3s ease-in-out infinite}
    @keyframes u{0%,20%{transform:translateY(0)}50%,100%{transform:translateY(-20px)}}
    @keyframes c{0%,45%{opacity:.15}60%,100%{opacity:1}}
    @media (prefers-reduced-motion:reduce){.u,.c{animation:none}.u{transform:translateY(-20px)}}
  </style>
  <rect x="8" y="8" width="150" height="20" rx="4" opacity=".4"/>
  <text x="16" y="21" fill="currentColor" stroke="none" opacity=".8">rule  https://example.com</text>
  <g class="u">
    <rect x="8" y="42" width="150" height="20" rx="4"/>
    <text x="16" y="55" fill="currentColor" stroke="none">url   https://example.com</text>
  </g>
  <path class="c" d="M190 40l8 8 16-18" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #55232, #62260

Sorry, something went wrong.

Uh oh!

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

All reactions
exe.dev user
fix(core): match webfetch rules against the URL as written
e8a239a
Existing rules such as https://example.com, uppercase hosts and explicit
ports are compared to the URL the model requested again, as in v2.2.5.
Undoes the URL parsing from #60505 and #61701; keeps the Code Mode redirect
checks from #60502.
@github-actions github-actions Bot added the contributor label Nov 6, 2026
opencodejr[bot]
opencodejr Bot reviewed Nov 6, 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.

This fixes the rule-compatibility regression, but by reopening the deny-rule bypasses that #60505 and #61701 closed. I'd rather not trade one for the other.

I ran the permission matcher (Permission.evaluate) on the URL as written and on the parsed URL. Every row of your table now matches as in v2.2.5. But with *: allow and a deny rule for https://evil.com/*, these are allowed again and the request goes to evil.com:

  • HTTPS://EVIL.COM/x
  • https://evil.com:443/x
  • https://[email protected]/x

The same goes for https://evil.com/x#a against a deny rule for exactly https://evil.com/x. Normalizing the rules as well (the open #62260) fixes the same table and keeps these protections. Could you say why that approach is no longer wanted? The description just calls it unneeded.

Also, rejecting credentials and dropping the fragment don't cause the regression, so they can stay whichever way the URL question goes (inline comments).

The tests you listed pass (300), and typecheck:tsc is clean in packages/core.

Public API is unchanged: same config keys, only how webfetch rules match changes.

Related: #55232, #62260

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/core/src/tool/plugin/webfetch.ts Outdated
yield* permission.assert({
action: name,
resources: [url],
resources: [input.url],

@opencodejr opencodejr Bot Nov 6, 2026

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.

Checking input.url as written lets a different spelling of a denied URL through. With deny https://evil.com/*, HTTPS://EVIL.COM/x and https://evil.com:443/x no longer match but are still fetched from evil.com; this is what #60505 fixed. Normalizing the scheme and host of the rules when they are loaded (#62260) fixes the rules in your table without reopening this.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/core/src/tool/plugin/webfetch.ts
const request = (url: string, format: Format, userAgent = openCodeUserAgent) =>
HttpClientRequest.get(url).pipe(HttpClientRequest.setHeaders(headers(format, userAgent)))

const assertHttpUrl = (url: URL) => {

@opencodejr opencodejr Bot Nov 6, 2026

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.

Dropping the credentials check isn't needed for compatibility: no existing rule matches a URL with credentials in it differently because of this check. Without it, https://[email protected]/x gets past a deny rule for https://evil.com/* again. The same goes for removing hash = "" (it only matters for rules that contain #). Could both stay?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/core/src/codemode/fetch.ts Outdated
// The fragment is never sent, and would keep a rule for the exact URL from matching.
parsed.hash = ""
const url = parsed.href
const url = String(input)

@opencodejr opencodejr Bot Nov 6, 2026

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.

Same problem in Code Mode fetch: the program can now write HTTPS://EVIL.COM/, https://evil.com:443/ or https://[email protected]/ to get past a deny rule for https://evil.com/*. Rejecting credentials and dropping the fragment can stay here as well, since they don't cause the regression.

Sorry, something went wrong.

Uh oh!

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

All reactions
@rekram1-node rekram1-node mentioned this pull request Nov 6, 2026
fix(core): normalize webfetch permission rules like requested URLs #62260
Closed
exe.dev user
fix(core): keep rejecting URL credentials and ignoring fragments in w…
5ccf043
…ebfetch
@rekram1-node

rekram1-node commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Kept the credential rejection and the fragment handling (applied to the URL as written) in both webfetch and Code Mode fetch, with tests.

On matching the URL as written: this is deliberate for now.

  • Existing rules have to keep working. v2.2.5 already matched raw strings, so spellings like HTTPS://EVIL.COM/x aren't a new gap.
  • Rewriting rules (fix(core): normalize webfetch permission rules like requested URLs #62260) only covered scheme and host. Rules with paths, queries or # stayed broken, and rewriting globs can't be lossless.
  • Webfetch rules aren't a network boundary while shell can run curl.

The proper fix is rules that match the parsed host, plus "always allow" saving the domain. I'll do that separately under #55232.

All reactions

Sorry, something went wrong.

Uh oh!

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

opencodejr[bot]
opencodejr Bot reviewed Nov 6, 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.

Rejecting credentials and dropping the fragment are back in both tools, thanks. The case and default-port bypass (HTTPS://EVIL.COM/x, https://evil.com:443/x against deny https://evil.com/*) is still open in both webfetch and Code Mode fetch.

One new gap: the credential check misses an empty userinfo. https://@evil.com/x and https://:@evil.com/x parse with an empty username and password, so the check passes them, and as written they don't match a deny rule for https://evil.com/* (inline).

The suggested tests pass (302) and typecheck:tsc is clean in packages/core. Public API is unchanged.

  • packages/core/src/tool/plugin/webfetch.ts:74: An empty userinfo gets past this check. new URL("https://@evil.com/x") (or https://:@evil.com/x) has username === "" and password === "", so it isn't rejected. The rule is then matched against the string as written, so a deny rule for https://evil.com/* doesn't match, and the request goes to evil.com. Since rules now match the written URL, rejecting any @ in the written URL's authority would close this. The same applies to Code Mode fetch (codemode/fetch.ts line 25).

Sorry, something went wrong.

Uh oh!

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

All reactions
@rekram1-node
rekram1-node merged commit e803323 into dev Nov 6, 2026
17 checks passed

Uh oh!

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

@rekram1-node
rekram1-node deleted the revert-web-perms branch November 6, 2026 16:25
@adamdotdevin adamdotdevin mentioned this pull request Nov 6, 2026
release: site colour fixes (dev → production) #62379
Merged
@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
autonull pushed a commit to autonull/opencode_spacegraph that referenced this pull request Nov 7, 2026
@rekram1-node exe.dev user me
fix(core): match webfetch rules against the URL as written (anomalyco…
10a7e79
…#62373)

Co-authored-by: exe.dev user <[email protected]>
@ichinya ichinya mentioned this pull request Nov 9, 2026
Артефакты: сохранение, upload/download, preview metadata и checksums ichinya/ariel#33
Open
3 tasks
AbizardShafwan pushed a commit to AbizardShafwan/opencode that referenced this pull request Nov 9, 2026
@rekram1-node exe.dev user Abizard Sulaiman
fix(core): match webfetch rules against the URL as written (anomalyco…
dc64400
…#62373)

Co-authored-by: exe.dev user <[email protected]>
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
hunterchristian added a commit to chipp-ai/opencode that referenced this pull request Nov 13, 2026
@hunterchristian
fix(core): check webfetch redirect permissions before requests
eda5035
Adapt anomalyco/opencode 17837a2 (anomalyco#59748), 125655e (anomalyco#61701), and e803323 (anomalyco#62373). Use this fork's existing permission assertions per redirect; reject URL credentials, ignore fragments, and bound redirects. Prove denied destinations receive no HTTP request.
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.