fix(security): harden web_fetch SSRF checks and rustls TLS - #187
Merged
Merged
Conversation
Reject non-http(s) schemes, abbreviated/decimal IPv4 loopback, IPv6-mapped addresses, CGNAT, unique-local IPv6, and DNS-resolved private targets. Bound marketplace fetch timeouts/redirects. Enable rustls on the providers feature, bump rustls past RUSTSEC-2026-0285, allow CDLA-Permissive-2.0 for webpki-roots, and run cargo-deny in CI. Amp-Thread-ID: https://ampcode.com/threads/T-01a0a5f1-67fb-76fe-ac75-eae1b8f3a08a Co-authored-by: Max Carter <undivisible@vk.com>
|
Capy couldn't review this pull request because Max's workspace is out of credits, add credits or enable auto-reload to resume automatic reviews. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_95fe2e66-fbfc-40aa-aaf5-0fed6080fb68) |
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.
Why
web_fetchSSRF validation was host-string matching only: it missedfile://, decimal/abbreviated IPv4 (2130706433,127.1), IPv6-mapped loopback, CGNAT, unique-local IPv6, DNS rebinding, and open redirects. Theprovidersfeature also enabled reqwest withdefault-features = falseand no TLS backend.What
http/https) and real IP classification before fetch.providersnow enablesreqwest/json+reqwest/rustls-tls.deny.toml: CDLA-Permissive-2.0; ignore unmaintained bincode viafff-search.cargo deny check.Tests
cargo test --no-default-features --features providers,builtin-tools,mcp --lib— 513 passedcargo clippy --no-default-features --features providers,builtin-tools,mcp,ipc,marketplace --lib -- -D warningscargo deny check— advisories/bans/licenses/sources okNot merged: security-sensitive; needs review.
Note
High Risk
Security-critical changes to agent network fetch paths, TLS for providers, and redirect/DNS behavior; misclassification could block legitimate URLs or leave SSRF gaps.
Overview
Hardens
web_fetchagainst SSRF:http/httpsonly, stricter host/IP blocking (decimal/abbreviated IPv4, IPv6-mapped loopback, CGNAT, unique-local), DNS resolution checks for hostnames, and a dedicated reqwest client (30s timeout, max 5 redirects) that rejects redirects to blocked targets instead of using the provider global client.The
providersfeature now wiresreqwestwith rustls TLS (reqwest/json,reqwest/rustls-tls);Cargo.lockbumps rustls. Marketplace index fetch gets the same 30s timeout and 5-redirect cap. CI runscargo deny check;deny.tomladds CDLA-Permissive-2.0, workspace-level unmaintained handling, and yanked = warn. Provider HTTP client build usesexpectinstead of falling back to a default client on failure. Unit tests cover URL validation and destination checks.Reviewed by Cursor Bugbot for commit 783f531. Configure here.