chore(deps): update dependency web3 to v7.15.0 [security]#1580
Open
renovate[bot] wants to merge 1 commit intomainfrom
Open
chore(deps): update dependency web3 to v7.15.0 [security]#1580renovate[bot] wants to merge 1 commit intomainfrom
renovate[bot] wants to merge 1 commit intomainfrom
Conversation
27d4f3b to
1884e08
Compare
f71a350 to
d57f438
Compare
cff0983 to
9d05fcb
Compare
9d05fcb to
17c5621
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
==7.14.1→==7.15.0web3.py: SSRF via CCIP Read (EIP-3668) OffchainLookup URL handling
CVE-2026-40072 / GHSA-5hr4-253g-cpx2
More information
Details
Summary
web3.py implements CCIP Read /
OffchainLookup(EIP-3668) by performing HTTP requests to URLs supplied by smart contracts inoffchain_lookup_payload["urls"]. The implementation uses these contract-supplied URLs directly (after{sender}/{data}template substitution) without any destination validation:https://(and no opt-in gate forhttp://)requestsandaiohttpfollow redirects by default)CCIP Read is enabled by default (
global_ccip_read_enabled = Trueon 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.Affected Code
Sync CCIP handler
File:
web3/utils/exception_handling.py(lines 42-58)Contract-controlled URLs are requested via
requestswith no destination validation:(The request is issued before response validation; subsequent logic parses JSON and enforces a
"data"field.)Key observations:
requestsfollows redirects by default (allow_redirects=True).allow_redirects=Falseis set.formatted_urlbefore the request.if "{data}" in url) operates on the rawurlvalue from the payload (beforestr()conversion), not on the already-formattedformatted_url. Ifurlis not a plainstr(e.g., aURItype), theincheck may behave differently than intended.Async CCIP handler
File:
web3/utils/async_exception_handling.py(lines 45-63)Same pattern with
aiohttp:Key observations:
aiohttpfollows redirects by default.urlplaceholder check issue as the sync handler.Default-on invocation path
File:
web3/providers/base.py(line 66) andweb3/providers/async_base.py(line 79):File:
web3/eth/eth.py(lines 222-266) andweb3/eth/async_eth.py(lines 243-287):The
.call()method automatically invokeshandle_offchain_lookup()/async_handle_offchain_lookup()when a contract reverts withOffchainLookup, up toccip_read_max_redirectstimes (default: 4). No user interaction or explicit opt-in is required beyond the default configuration.Security Impact
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:
http://127.0.0.1:<port>/...,http://localhost/...http://169.254.169.254/latest/meta-data/iam/security-credentials/10.x.x.x,172.16-31.x.x,192.168.x.x)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 raisesWeb3ValidationErroror continues to the next URL. This means: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
requestsandaiohttpfollow HTTP redirects by default. The CCIP handlers use the final response without validating the final resolved URL.web3/utils/exception_handling.py--session.get()with defaultallow_redirects=Trueweb3/utils/async_exception_handling.py--session.get()with default redirect followingA contract-supplied URL can point to an attacker-controlled server that issues a
302redirect tohttp://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
OffchainLookuprevert payload, an attacker can:4. POST-Based SSRF
When the contract-supplied URL does not contain both
{sender}and{data}placeholders, the handler switches tosession.post()with a JSON body. This means the attacker can cause the victim to issue POST requests with a controlled JSON body ({"data": ..., "sender": ...}) to arbitrary destinations, increasing the potential for triggering state-changing operations on internal services.Proof of Concept
Prerequisites
web3installedStep 1: Start a local HTTP listener
Step 2: Run the reproduction script
Step 3: Observe
The HTTP server logs will show an inbound request to a path like
/SSRF_DETECTION_SUCCESS?sender=...&data=..., confirming thathandle_offchain_lookup()issued an outbound HTTP request to the contract-supplied URL without any destination validation.The script will then print an error (the local HTTP server does not return the expected JSON), but the request has already been sent -- the SSRF occurs before any response validation.
Reproduction script (
repro_ssrf.py)Real-world attack scenario
In a production setting, the attacker would:
OffchainLookup, supplying URLs pointing to internal services (e.g.,http://169.254.169.254/latest/meta-data/iam/security-credentials/).eth_call/.call().No special permissions or contract interactions beyond a standard
eth_callare required.Suggested Remediation
1. Restrict URL schemes (safe default)
Allow only
https://by default. Provide an explicit opt-in flag (e.g.,ccip_read_allow_http=True) forhttp://.2. Block private/reserved IP destinations by default
Before issuing the request, resolve the hostname and reject connections to:
127.0.0.0/8(loopback)169.254.0.0/16(link-local / cloud metadata)10.0.0.0/8,172.16.0.0/12,192.168.0.0/16(RFC1918)::1,fe80::/10(IPv6 loopback / link-local)0.0.0.0/83. Disable or validate redirects
Either:
allow_redirects=Falseon the HTTP requests, or4. Provide a URL validator hook
Allow users to supply a custom URL validation callback for CCIP Read URLs (e.g., a hostname allowlist, gateway pinning, or custom policy). This enables advanced users to configure CCIP Read for their specific trust model.
5. Consider stronger default safety signaling (or default-off in server-side contexts)
EIP-3668 encourages keeping CCIP Read enabled for calls, so this may not be desirable as a universal default change. However, for server-side deployments, consider either:
ccip_read_enabled=Falseorglobal_ccip_read_enabled=False) when calling untrusted contracts.At minimum, document the SSRF risk prominently in the CCIP Read docs.
Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
Release Notes
ethereum/web3.py (web3)
v7.15.0Compare Source
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.