pypi package report

Is web3 safe?

1 known vulnerability, worst severity MODERATE.

// reach

18 direct dependencies

7 carry known advisories, worst HIGH

31 packages depend on it

an advisory here reaches each of them

Create a free accountfor every dependency path, dependent and what to upgrade
// ai model usage

No published models are known to use this package.


cvss
7.2
high

CVSS v3.1 base score out of 10; GitHub rates it MODERATE

epss
0.24%
low

chance of exploitation in 30 days, 15th percentile of all CVEs

xyz score
not scored

CyberXYZ composite out of 10

fig. 01 — GHSA-5hr4-253g-cpx2, the advisory selected below

// 1 advisories

GHSA-5hr4-253g-cpx2

MODERATEGitHub ratingCVE-2026-40072
// summary

web3.py implements CCIP Read / OffchainLookup (EIP-3668) by performing HTTP requests to URLs supplied by smart contracts in offchain_lookup_payload["urls"]. The implementation uses these contract-supplied URLs directly (after {sender} / {data} template substitution) without any destination validation:

  • No restriction to https:// (and no opt-in gate for http://)
  • No hostname or IP allowlist
  • No blocking of private/reserved IP ranges (loopback, link-local, RFC1918)
  • No redirect target validation (both requests and aiohttp follow redirects by default)

CCIP Read is enabled by default (global_ccip_read_enabled = True on all providers), meaning any application using web3.py's .call() method is exposed without explicit opt-in.

This results in Server-Side Request Forgery (SSRF) when web3.py is used in backend services, indexers, APIs, or any environment that performs eth_call / .call() against untrusted or user-supplied contract addresses. A malicious contract can force the web3.py process to issue HTTP requests to arbitrary destinations, including internal network services and cloud metadata endpoints.

---

// why this is a vulnerability

The argument is not that CCIP Read itself is invalid or that web3.py should stop supporting EIP-3668. The issue is that, in server-side deployments (backends, indexers, bots, APIs), the current implementation doesn't provide destination policy controls, such as a validation/override hook, private-range blocking, or redirect target checks, which means contract controlled CCIP URLs can be used as an SSRF primitive.

This is consistent with EIP-3668's own security considerations, which recommends that client libraries "provide clients with a hook to override CCIP read calls, either by rewriting them to use a proxy service, or by denying them entirely" and that "this mechanism or another should be written so as to easily facilitate adding domains to allowlists or blocklists." The mitigations I'm suggesting are meant to align with that guidance without breaking CCIP Read support.

  • Default-on exposure. CCIP Read is enabled by default on all web3.py providers (global_ccip_read_enabled = True). Users who never intend to use CCIP Read, and who may not even know the feature exists, are silently exposed. A feature that makes unsanitized outbound requests to attacker-controlled URLs should not be enabled by default without safety guardrails.
  • Library vs. application responsibility. web3.py is a widely-used library. Expecting every downstream application to independently implement SSRF protections around .call() is unreasonable, especially for a feature that fires automatically and invisibly on a specific revert pattern. Safe defaults at the library level are the standard expectation for any library that issues outbound HTTP requests to externally-controlled URLs.

---

// sync ccip handler

File: web3/utils/exception_handling.py (lines 42-58)

Contract-controlled URLs are requested via requests with no destination validation:

session = requests.Session()
for url in offchain_lookup_payload["urls"]:
    formatted_url = URI(
        str(url)
        .replace("{sender}", str(formatted_sender))
        .replace("{data}", str(formatted_data))
    )

    try:
        if "{data}" in url and "{sender}" in url:
            response = session.get(formatted_url, timeout=DEFAULT_HTTP_TIMEOUT)
        else:
            response = session.post(
                formatted_url,
                json={"data": formatted_data, "sender": formatted_sender},
                timeout=DEFAULT_HTTP_TIMEOUT,
            )

(The request is issued before response validation; subsequent logic parses JSON and enforces a "data" field.)

Key observations:

  • requests follows redirects by default (allow_redirects=True).
  • No allow_redirects=False is set.
  • No validation of formatted_url before the request.
  • The placeholder check (if "{data}" in url) operates on the raw url value from the payload (before str() conversion), not on the already-formatted formatted_url. If url is not a plain str (e.g., a URI type), the in check may behave differently than intended.
// async ccip handler

File: web3/utils/async_exception_handling.py (lines 45-63)

Same pattern with aiohttp:

session = ClientSession()
for url in offchain_lookup_payload["urls"]:
    formatted_url = URI(
        str(url)
        .replace("{sender}", str(formatted_sender))
        .replace("{data}", str(formatted_data))
    )

    try:
        if "{data}" in url and "{sender}" in url:
            response = await session.get(
                formatted_url, timeout=ClientTimeout(DEFAULT_HTTP_TIMEOUT)
            )
        else:
            response = await session.post(
                formatted_url,
                json={"data": formatted_data, "sender": formatted_sender},
                timeout=ClientTimeout(DEFAULT_HTTP_TIMEOUT),
            )

Key observations:

  • aiohttp follows redirects by default.
  • No redirect or destination validation.
  • Same raw-url placeholder check issue as the sync handler.
// default-on invocation path

File: web3/providers/base.py (line 66) and web3/providers/async_base.py (line 79):

global_ccip_read_enabled: bool = True

File: web3/eth/eth.py (lines 222-266) and web3/eth/async_eth.py (lines 243-287):

The .call() method automatically invokes handle_offchain_lookup() / async_handle_offchain_lookup() when a contract reverts with OffchainLookup, up to ccip_read_max_redirects times (default: 4). No user interaction or explicit opt-in is required beyond the default configuration.

---

// 1. blind ssrf (primary impact)

A malicious contract can supply URLs that cause the web3.py process to issue HTTP GET or POST requests to:

The request is made from the web3.py process. This alone constitutes SSRF -- the attacker controls the destination of an outbound request from the victim's infrastructure.

Note on response handling: The CCIP handler expects a JSON response containing a "data" field. If the target endpoint does not return valid JSON with this key, the handler raises Web3ValidationError or continues to the next URL. This means:

  • The raw response body is not directly returned to the attacker in most cases (blind SSRF).
  • However, the request itself is the primary threat: it can reach internal services, trigger side effects on internal APIs, and serve as a network probe.
  • On AWS with IMDSv1, a GET to http://169.254.169.254/... returns credentials in plaintext. While the CCIP handler would fail to parse this as JSON, the request itself reaches the metadata service. If an internal endpoint returns JSON containing a "data" field (or can be coerced to), the handler may accept it and use it in the on-chain callback, creating a potential exfiltration path.
// 2. redirect-based ssrf amplification

Both requests and aiohttp follow HTTP redirects by default. The CCIP handlers use the final response without validating the final resolved URL.

  • Sync: web3/utils/exception_handling.py -- session.get() with default allow_redirects=True
  • Async: web3/utils/async_exception_handling.py -- session.get() with default redirect following

A contract-supplied URL can point to an attacker-controlled server that issues a 302 redirect to http://169.254.169.254/... or any internal endpoint. This defeats naive URL-prefix checks that an application might add, expanding the SSRF surface.

// 3. internal network probing

By varying the URLs supplied in the OffchainLookup revert payload, an attacker can:

  • Probe internal network topology (open ports, reachable hosts) based on response timing and error behavior
// cvss v3.1 vector

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
None

Checked 2026-11-07 at 07:53 UTC. The most recent advisory here was published 2026-04-04. Updated continuously from NVD, GHSA, OSV and CNA feeds.

Think a verdict here is wrong? Tell us — we respond within 2 business days.