/

CVE-2026-24052

Severity:

HIGH RISK

(7.4)

Improper URL/Domain Validation in Claude Code WebFetch

CVE-2026-24052

Analyzed

Vulnerability type

Category:

Improper URL/Domain Validation

CWE:

CWE-601

Impact:

Data Exfiltration via Misvalidated Trusted Domains

Severity:

HIGH RISK

(7.4)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Claude Code used a naive prefix-based string check to validate "trusted" domains for WebFetch requests, allowing lookalike domains such as modelcontextprotocol.io.example.com to be treated as trusted.

If an attacker can lure the tool or user into fetching from such a crafted domain, the tool may automatically send requests to attacker-controlled servers without explicit user consent, which can expose sensitive data.

Affected context

This vulnerability affects workflows in Claude Code that rely on WebFetch requests to a fixed set of "trusted" domains (for example documentation or protocol endpoints).

The issue arises when trust is inferred solely from a URL string starting with a known domain substring, rather than from strict hostname and scheme validation.

In environments where the tool holds or can access sensitive project data, automatically following such misvalidated URLs increases the risk that private information is sent to attacker-controlled infrastructure.

Exploit preconditions

  • Attack surface: Outbound WebFetch requests performed by Claude Code.
  • Required access: Ability to influence or control the URLs that the tool is asked to fetch (e.g., through prompts, shared snippets, project configuration, or embedded links).
  • Trigger point: WebFetch is invoked for a URL whose hostname is crafted to start with a trusted domain string, such as docs.python.org.evil.com or modelcontextprotocol.io.attacker.org.
  • Why exploitation is possible: The validation logic uses startsWith() on the URL string to decide whether a destination is "trusted," which does not enforce boundaries between hostnames. This allows attacker-controlled domains that merely share a prefix with a trusted domain to be incorrectly accepted.

Why this happens

The underlying bug is an improper validation of URLs against a trusted-domain allowlist, aligned with CWE-601: URL Redirection to Untrusted Site ('Open Redirect') patterns.

Instead of parsing the URL and comparing the normalized hostname and scheme against an exact or well-scoped set of allowed origins, the implementation relied on startsWith() string comparison.

This ignores domain boundaries, subdomain relationships, and potential URL encoding edge cases.

As a result, attacker-registered domains that simply begin with the trusted domain text are treated as if they belong to the trusted set, causing the tool to send requests to untrusted endpoints while believing they are safe.

Potential impact

  • Claude Code may send HTTP requests to attacker-controlled domains that masquerade as trusted hosts.
  • Sensitive project content, snippets, or contextual data associated with a WebFetch operation could be exfiltrated.
  • Attackers could collect metadata about usage patterns, project structure, or connected services.
  • Downstream attacks such as phishing, targeted social engineering, or dependency confusion may be facilitated through harvested information.

General mitigation guidance

Effective mitigation focuses on robust URL and origin validation rather than string-prefix checks:

  • Parse URLs using a dedicated, well-tested URL parsing library and validate based on structured components (scheme, hostname, port).
  • Compare hostnames against an explicit allowlist using exact matches or carefully scoped subdomain rules (e.g., checking registrable domains via public suffix lists when subdomains are allowed).
  • Normalize and canonicalize URLs before validation to avoid bypasses due to encoding, casing, or trailing-dot tricks.
  • Restrict the amount and sensitivity of data automatically attached to outbound WebFetch requests, following least-privilege and data minimization principles.
  • Introduce user confirmation or explicit consent when WebFetch is directed to domains that are not clearly in a conservative trusted set.

How teams detect issues like this

Organizations can look for this class of issue by:

  • Performing static analysis or code search for domain validation that relies on startsWith(), contains(), or similar substring checks instead of parsed host comparisons.
  • Reviewing code paths around outbound HTTP requests for simplistic allowlist logic or direct string comparison with trusted domains.
  • Implementing security review checklists that flag any trust decision based purely on URL string prefixes or suffixes.
  • Using automated security scanning tools that understand URL/host validation anti-patterns and highlight potential improper redirects or domain checks.
  • Logging and periodically reviewing outbound request destinations to detect unexpected domains that visually resemble trusted services.

Sources

SourceLink
github.comgithub.com/anthropics/claude-code/security/advisories/GHSA-vhw5-3g5m-8ggf

Frequently asked

questions

Exploitability depends on how easily an attacker can influence the URLs the tool fetches. In collaborative environments or where users paste untrusted links into the tool, it can be relatively straightforward for an attacker to introduce malicious but deceptively named domains.

Typically, the attacker does not need privileged access to the system running Claude Code; they primarily need a way to cause the tool to fetch from a crafted domain they control. This might occur through user interaction with shared code, prompts, or configuration that references such URLs.

The safest pattern is to parse each URL and apply strict origin-based validation, comparing normalized hostnames and schemes against a minimal, clearly defined allowlist. Avoid using substring or prefix checks to determine trust, and treat any unrecognized origin as untrusted by default.

Build URL handling around robust parsing and normalization libraries, apply principle-of-least-privilege to outbound requests, and institutionalize security reviews for any feature that relies on trusted-domain lists or redirects. Integrating automated checks for weak domain validation patterns into CI can also catch regressions early.

Find out what's already
exploitable in your codebase.