/

CVE-2026-40072

Severity:

HIGH RISK

(7.2)

Server-Side Request Forgery (CWE-918) via CCIP Read in web3.py Ethereum Clients

CVE-2026-40072

Analyzed

Vulnerability type

Category:

Server-Side Request Forgery (SSRF)

CWE:

CWE-918

Impact:

Network pivoting and unauthorized access to internal HTTP services via SSRF

Severity:

HIGH RISK

(7.2)

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

web3.py's CCIP Read / OffchainLookup implementation can be abused to make the library perform HTTP requests to attacker-controlled URLs embedded in smart contracts.

When backend services use web3.py's .call() / eth_call against untrusted contracts, a malicious contract can trigger server-side requests to arbitrary internal or external endpoints, leading to Server-Side Request Forgery (SSRF).

Affected context

This vulnerability affects Python applications that:

  • Use web3.py versions from 6.0.0b3 to before 7.15.0 or 8.0.0b2
  • Have CCIP Read / OffchainLookup (EIP-3668) enabled, which is the default (global_ccip_read_enabled = True)
  • Perform .call() or eth_call operations against untrusted or user-supplied contract addresses
  • Run in environments where the web3.py process can reach internal network resources (e.g., VPC services, databases, cloud metadata endpoints)

The issue arises when the application relies on smart contracts that can supply arbitrary URLs in the offchain_lookup_payload["urls"] field, without validating or constraining the destination.

Exploit preconditions

  • Attack surface: Applications using web3.py to talk to Ethereum (or compatible) networks, particularly backend services, indexers, relayers, or APIs.
  • Required access: Ability to control or influence the smart contract address used in .call() / eth_call, or to deploy/mutate a contract that returns crafted OffchainLookup payloads.
  • Trigger point: Invocation of a contract function that triggers an EIP-3668 OffchainLookup, causing web3.py to process offchain_lookup_payload["urls"] and issue HTTP requests.
  • Why exploitation is possible: web3.py uses contract-supplied URLs directly after simple {sender} / {data} template substitution, with no verification of scheme, host, or path. Because CCIP Read is enabled by default, applications may unknowingly allow arbitrary outbound HTTP requests triggered by untrusted contracts.

Why this happens

The core flaw is the direct use of untrusted, on-chain data as HTTP request destinations without any validation or restriction.

Under EIP-3668, contracts can declare one or more URLs in the OffchainLookup payload to fetch additional data. In the affected versions of web3.py, these URLs are taken from offchain_lookup_payload["urls"] and used as-is (after inserting {sender} and {data} values) to perform HTTP requests. There is no filtering of protocols, no host allow/deny list, and no enforcement of network boundaries.

This behavior maps to CWE-918: Server-Side Request Forgery (SSRF), where a server-side component (here, web3.py acting as an HTTP client on behalf of the application) is tricked into initiating network requests to attacker-chosen destinations. The bug is conceptual rather than a low-level coding error: the library conflates "contract-provided endpoint hints" with "trusted HTTP targets," and enables the feature by default across all providers without requiring explicit opt-in or boundary configuration.

Potential impact

  • A malicious contract could cause the web3.py process to make HTTP requests to internal services that are not directly exposed to the internet (e.g., admin APIs, databases, internal dashboards).
  • Attackers may access cloud provider metadata services (such as instance metadata endpoints) to exfiltrate credentials or tokens, depending on network layout.
  • Internal network scanning and service discovery could be facilitated by varying URLs and observing timing or error behavior from the vulnerable service.
  • Sensitive configuration, debugging endpoints, or management interfaces reachable from the backend host could be probed or accessed.
  • Web3-integrated backend components might be chained in a broader attack path, enabling lateral movement or privilege escalation within a cloud or data center environment.

General mitigation guidance

Effective mitigation focuses on treating all contract-supplied URLs as untrusted input and constraining what the client is allowed to reach:

  • Restrict or disable automatic CCIP Read: Prefer explicit opt-in for EIP-3668 behavior. If CCIP Read is not essential to your use case, disable it for providers used in backend and infrastructure-sensitive contexts.
  • Constrain outbound HTTP destinations: Introduce allowlists for CCIP Read endpoints at the application level, or wrap HTTP clients used by web3.py in components that enforce approved domains, schemes, and paths.
  • Harden network boundaries: Use network policies, firewall rules, and VPC configuration to prevent backend services from reaching sensitive internal management networks and cloud metadata services wherever possible.
  • Apply least privilege to runtime environments: Run web3.py-based services with minimized network reach and without over-privileged role credentials so that even if SSRF occurs, the reachable attack surface is small.
  • Separate roles and environments: Isolate components that must perform CCIP Read in tightly controlled network segments, distinct from control planes or sensitive data stores, and avoid mixing them with high-privilege workloads.

How teams detect issues like this

Organizations can detect and monitor for this vulnerability using a combination of code and behavior-centric approaches:

  • Static analysis and code inspection:
  • Flag usage of web3.py versions known to implement CCIP Read without destination validation.
  • Identify call paths where .call() / eth_call is performed against user-selected or arbitrary contract addresses, especially in backend APIs and indexers.
  • Review configuration for implicit defaults (e.g., global CCIP Read enabled) and lack of explicit network restrictions.
  • Configuration and policy checks:
  • Enforce policies requiring domain allowlists for off-chain data fetching mechanisms.
  • Validate that runtime environments hosting web3.py services cannot reach known-sensitive endpoints (cloud metadata IPs, internal admin APIs).
  • Runtime monitoring and logging:
  • Instrument HTTP clients used by web3.py to log destination hosts, especially those derived from EIP-3668 flows.
  • Monitor for anomalous outbound connections to internal IP ranges, metadata endpoints, or unexpected domains originating from web3.py processes.
  • Automated tooling integration:
  • Integrate dependency scanning tools in CI to flag vulnerable web3.py releases and missing hardening settings around CCIP Read.
  • Use infrastructure security scanners to detect SSRF-prone network paths (e.g., open egress with access to metadata services) and correlate with services running Ethereum clients.

Sources

SourceLink
github.comgithub.com/ethereum/web3.py/commit/b1c57bb0a124359c9902daaefab4d8af7c3c4c1e
github.comgithub.com/ethereum/web3.py/security/advisories/GHSA-5hr4-253g-cpx2

Frequently asked

questions

Yes. If your service exposes functionality that takes untrusted contract addresses or interacts with untrusted contracts (directly or indirectly) and runs web3.py with CCIP Read enabled, a remote attacker can deploy or point you to a malicious contract that triggers SSRF via OffchainLookup.

The attacker only needs the ability to influence which contract your backend calls using web3.py, or to get you to interact with a contract they control. They do not need shell access or direct network access to your infrastructure; the SSRF requests originate from your own backend or indexer process.

The safest broad fix is to treat CCIP Read as an opt-in feature: disable it by default in sensitive backend contexts, and where you must use it, constrain destinations through explicit allowlists or proxy components that validate URLs before use. Combining this with hardened outbound network policies significantly reduces risk.

Design any off-chain data fetching features so that untrusted data (such as contract-provided URLs) cannot directly control network destinations. Require explicit configuration of trusted domains, enforce network egress restrictions, review default feature flags for security impact, and use dependency and configuration scanning in your CI pipeline to catch risky defaults early.

Find out what's already
exploitable in your codebase.