[Bug] WebFetch Wildcard Domain Matching Fails to Generalize

Status Fixed / completed
Maintainer reply None cached
Activity 13 comments · opened Oct 10, 2025 · closed Aug 19, 2026

Bug Description
"WebFetch(domain:*)", # doesnt work?
...
"WebFetch(domain:developers.google.com)" # still required, but * should have handled it

Environment Info

  • Platform: linux
  • Terminal: vte-based
  • Version: 2.0.13
  • Feedback ID: bd5d0ca1-e082-4cdd-9fd4-e1c07ba130e4

Errors

[]

View original on GitHub ↗

12 Comments

github-actions[bot] · 8 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

mwbidwell · 8 months ago

yes, still broken

longfellowone · 8 months ago

Any planned fix for this? super annoying to have to approve every domain

will-lynas · 7 months ago

I'm also running into this problem

temn · 7 months ago

Regarding the domain prompt: The bug is worse than expected. Even explicit domains like WebFetch(domain:github.com) in the settings.json are not being honored - I still had to manually select option 2. This confirms the bug affects:

  1. WebFetch(domain:*) wildcard - doesn't work
  2. WebFetch(domain:github.com) explicit - also doesn't work

The settings.json domain permissions for WebFetch are completely broken. The only workaround is:

  • Select option 2 ("Yes, and don't ask again for github.com") when prompted
  • This stores the domain permission somewhere else that actually works, where?
brookstalley · 7 months ago

It looks like "WebFetch(domain:*)" does not work, but just adding "WebFetch" on its own does give permission for all domains.

blimmer · 7 months ago

I haven't tested this, but I just saw this in Claude Code v2.1.20's release notes:

Changed permission rules like Bash(*) to be accepted and treated as equivalent to Bash
peteygao · 7 months ago

Ah, so that means there was never any need to use WebFetch(domain:*), WebFetch would have been enough. And now, you can use WebFetch(*). Good to know, thanks @blimmer!

four43 · 6 months ago

Clarification around subdomain matching would be nice too. Can I use just a top level domain? What about *.example.com?

bmarkowitz · 6 months ago

Think this is broken again, at least within a sandbox. When approving a permission request, it adds the explicit WebFetch(domain:xxxx.com) to the settings.json, even though I already have WebFetch in there. Also tried with WebFetch(*) and WebFetch(domain:*).

johnswarbrick · 6 months ago

Yes, seems it's not possible to allow all domains in WebFetch when using sandbox mode?

yurukusa · 5 months ago

Hook workaround: auto-approve WebFetch by domain
Until the native wildcard matching is fixed (especially in sandbox mode), you can use a PreToolUse hook to auto-approve WebFetch requests based on the URL's domain.
webfetch-domain-allow.sh:

INPUT=$(cat)
TOOL=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
[[ "$TOOL" != "WebFetch" ]] && exit 0
URL=$(echo "$INPUT" | jq -r '.tool_input.url // empty' 2>/dev/null)
[ -z "$URL" ] && exit 0
DOMAIN=$(echo "$URL" | sed -E 's|^https?://||' | sed 's|/.*||' | sed 's|:.*||')
[ -z "$DOMAIN" ] && exit 0
ALLOW_ALL=true
ALLOWED=("docs.anthropic.com" "github.com" "developer.mozilla.org")
if [ "$ALLOW_ALL" = "true" ]; then
    jq -n '{ hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "allow" } }'
    exit 0
fi
for d in "${ALLOWED[@]}"; do
    [ "$DOMAIN" = "$d" ] && jq -n '{ hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "allow" } }' && exit 0
done
exit 0  # Not matched — falls through to normal permission prompt

Install in .claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "WebFetch",
        "hooks": [
          {
            "type": "command",
            "command": "bash /path/to/webfetch-domain-allow.sh"
          }
        ]
      }
    ]
  }
}

This works in sandbox mode and supports both "allow all" and specific domain allowlists. You can also use the CC_WEBFETCH_ALLOW_DOMAINS environment variable (comma-separated) for domain configuration without editing the script.

Showing cached comments. Read the full discussion on GitHub ↗