Repository navigation
Description
- I have verified this feature I'm about to request hasn't been suggested before.
(Note: a related request was previously made in webfetch: always-allow scoped to domain instead of all URLs #37183 — host-scoping —
which was auto-closed by the compliance bot after 2h for missing the
template, without maintainer review. A companion issue for the general
"let the user choose the saved approval scope" feature (applicable to
webfetch as well as external_directory) is filed in parallel: [FEATURE] Let the user choose the saved approval scope in the "Always allow" prompt (e.g. parent directories for external_directory) #64430.)
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:
- 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 savehttps://<host>/<full-path>/*— e.g. approving
https://opencode.ai/this/is/a/test/pathsaves
https://opencode.ai/this/is/a/test/path/*, which (whole-value wildcard
semantics) covers that path and everything below it, nothing else. - 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)
- host-scoped:
- 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:
- a) Save two rules (
.../a/band.../a/b/*) — no matcher change, but
saved approvals become pairs of rows. - b) Extend matching so
<pattern>/*also matches<pattern>(analogous
to the existing shell behavior where a*suffix also matches the command
without arguments) — one row, small matcher change, new semantics for all
resource types to consider. - c) Normalize both side and pattern to a canonical form (always keep or
always drop the trailing slash on paths) — cleanest if the normalization
work from shell/webfetch policy resources match raw strings — argv tokenization and URL host normalization needed (evasion classes un-enumerable) #55232 lands first, but changes existing rule behavior.
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 savedwebfetch: *rules are exactly the
unintentionally broad ones; path-scoped saves would be safe to keep.
Related
- [FEATURE] Let the user choose the saved approval scope in the "Always allow" prompt (e.g. parent directories for external_directory) #64430 — companion: let the user choose the saved approval scope (the
UI-side of this feature; filed in parallel) - webfetch: always-allow scoped to domain instead of all URLs #37183 — predecessor request for host-scoping (auto-closed, never reviewed)
- shell/webfetch policy resources match raw strings — argv tokenization and URL host normalization needed (evasion classes un-enumerable) #55232 — raw-string URL matching; host normalization for webfetch rules
- fix(core): apply webfetch permissions to Code Mode fetch #59954 — evidence that
save: ["*"]is hardcoded (Code Mode fetch) - fix(core): check webfetch permission on every redirect hop #59352 — redirect hops are permission-checked individually
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
opencodejr commentedon Nov 17, 2026
Thanks for the detailed write-up, @mezen!
To restate the request: when you pick Allow always on a
webfetchprompt, OpenCode would save a pattern scoped to the approved URL's path (for examplehttps://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: