Skip to content

[FEATURE]: Scope the webfetch "Allow always" approval to the requested URL path instead of saving * #64429

Done

Description

@mezen

Current behavior

When a permission prompt for webfetch resolves to ask and the user picks
Allow always, the saved approval pattern is * — the assertion passes
save: ["*"] regardless of the URL (same for Code Mode fetch, see #59954).
This persists a project-scoped webfetch: * → allow rule (SQLite permission
table), so after a single misclick every future URL on any host and path
is fetched without a prompt in that project.

Problem

The user has no way to express the intent "trust this location, but keep
asking for everything else". A real-world example: approving
https://opencode.ai/docs/permissions for OpenCode documentation lookups
should not imply trust for https://opencode.ai/config.json, other paths,
or https://malicious.example/whatever. Host-scoping alone (#37183) is still
too coarse — documentation sites, API references, and wikis expose large
untrusted content trees under one host. The approval a user grants is about
the specific resource location, and the saved pattern should reflect the
full path, not just the domain.

Requested change

Derive the saved pattern from the URL the user approved, preserving its full
path:

  1. Primary (default) pattern — path-scoped: parse the approved URL,
    normalize scheme+host (same normalization applied to rules at load time —
    cf. shell/webfetch policy resources match raw strings — argv tokenization and URL host normalization needed (evasion classes un-enumerable) #55232 / rule-normalization work), strip query string and fragment,
    and save https://<host>/<full-path>/* — e.g. approving
    https://opencode.ai/this/is/a/test/path saves
    https://opencode.ai/this/is/a/test/path/*, which (whole-value wildcard
    semantics) covers that path and everything below it, nothing else.
  2. Broader options as explicit secondary choices in the approval UI
    (per the companion scope-picker issue [FEATURE] Let the user choose the saved approval scope in the "Always allow" prompt (e.g. parent directories for external_directory) #64430):
    • host-scoped: https://<host>/*
    • everything: *
      (and optionally the exact URL without wildcard, for single-resource trust)
  3. Redirects: since each hop is permission-checked individually (fix(core): check webfetch permission on every redirect hop #59352),
    a redirect that leaves the approved path/host must still prompt — which
    falls out of this design for free.

Open question

Does a path-scoped approval https://<host>/<path>/* also cover the path
itself, or only everything below it?

With whole-value wildcard semantics, https://opencode.ai/a/b/* requires the
literal prefix https://opencode.ai/a/b/ — so it matches .../a/b/c and
.../a/b/, but not the bare .../a/b (no trailing slash). Depending on how
the normalized requested URL is compared (e.g. URL.href drops or keeps
trailing slashes depending on the path), the exact same page could prompt
again after being approved. Options:

Which of these (or another approach) fits the permission engine best? And
should the same question apply to external_directory patterns, which have
the same /* suffix convention?

Why it matters

  • Makes the safe default actually selectable: users can stop the prompt churn
    for the exact location they trust (a doc section, an API subtree) without
    opening the host — let alone the project — to arbitrary URLs.
  • Shrinks the blast radius of a misclick and of prompt-injected fetch targets
    to the approved path tree.
  • Aligns with the documented guidance to "review broad approvals and remove
    those no longer needed" — most saved webfetch: * rules are exactly the
    unintentionally broad ones; path-scoped saves would be safe to keep.

Related

Security considerations

  • Standing over-grant from a single misclick. webfetch: * is a durable,
    project-scoped allow for any URL. Once saved, every later fetch in that
    project — including fetches induced by prompt-injected content — proceeds
    without user review. One moment of inattention becomes a standing, silent
    exfiltration/recon channel for the life of the project (revocable only by
    editing the database, see permissions: allow-always is durable and project-scoped with no opt-out or TUI reset #50600).
  • Prompt injection in fetched content. webfetch content enters the model's
    context verbatim. A malicious page — or a URL suggested by a poisoned
    document/dataset — can instruct the model to fetch an attacker endpoint next;
    under a * approval, that hop is invisible to the user. A path-scoped
    approval limits the trust a single approval implies to the approved location.
  • Exfiltration via URL parameters. Even read-only GETs are an exfiltration
    primitive: a compromised model can encode data in query strings or path
    segments of a fetch to an attacker-controlled host. The approval prompt is
    currently the only human-in-the-loop control over the destination.
  • Malicious URLs are hard to detect automatically. Lookalike domains,
    drive-by infrastructure and poisoned mirrors produce syntactically clean
    URLs; whole-value string matching on raw URLs (shell/webfetch policy resources match raw strings — argv tokenization and URL host normalization needed (evasion classes un-enumerable) #55232) makes rule-based
    defense brittle. Human review at approval time is therefore the primary
    control — and the current pattern removes it for everything, forever.

Note on framing: this is not a vulnerability report. Per SECURITY.md the
permission system is a UX control rather than an isolation boundary, and this
request improves the granularity of that control for users who rely on it
(who need true isolation should run OpenCode in a container/VM). Related
security context: #55232 (raw-string matching / re-spelling evasion),
#59352 (per-hop redirect checks).

Environment

  • opencode version: 2.3.0
  • OS: Windows 11 (Windows 10.0.26300, win32 x64)
  • Terminal: Unavailable (terminal environment variables not set)
  • Shell: C:\WINDOWS\system32\cmd.exe (PowerShell used for tooling)
  • Install/channel: release (latest)
  • Active plugins: none found in config

Activity

  1. opencodejr commented on Nov 17, 2026

    @opencodejr
    Contributor

    Thanks for the detailed write-up, @mezen!

    To restate the request: when you pick Allow always on a webfetch prompt, OpenCode would save a pattern scoped to the approved URL's path (for example https://opencode.ai/docs/permissions/*), not *. Host-wide and * would remain available as explicit, broader choices. The permissions docs describe Allow always as saving the tool's proposed patterns for the project, so this asks to change what webfetch proposes rather than reporting a bug. Maintainers will consider it, along with your open question about how a bare path should match its /* pattern.

    Related issues:

  2. added
    area/core
    type/feature
    version/v2
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/coreplatform/windowstype/featureversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions