Skip to content

fix(security): harden web_fetch SSRF checks and rustls TLS - #187

Merged
undivisible merged 1 commit into
mainfrom
fix/web-fetch-ssrf-tls
Sep 16, 2026
Merged

undivisible merged 1 commit into
mainfrom
fix/web-fetch-ssrf-tls

Conversation

@undivisible

@undivisible undivisible commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Why

web_fetch SSRF validation was host-string matching only: it missed file://, decimal/abbreviated IPv4 (2130706433, 127.1), IPv6-mapped loopback, CGNAT, unique-local IPv6, DNS rebinding, and open redirects. The providers feature also enabled reqwest with default-features = false and no TLS backend.

What

  • Scheme allowlist (http/https) and real IP classification before fetch.
  • DNS resolution check for named hosts; redirect policy rejects blocked URLs.
  • Dedicated web_fetch client (30s timeout, 5 redirects) instead of the provider global client.
  • providers now enables reqwest/json + reqwest/rustls-tls.
  • Marketplace index fetch: 30s timeout, 5 redirects.
  • rustls 0.23.45 (RUSTSEC-2026-0285).
  • deny.toml: CDLA-Permissive-2.0; ignore unmaintained bincode via fff-search.
  • CI: cargo deny check.

Tests

  • cargo test --no-default-features --features providers,builtin-tools,mcp --lib — 513 passed
  • cargo clippy --no-default-features --features providers,builtin-tools,mcp,ipc,marketplace --lib -- -D warnings
  • cargo deny check — advisories/bans/licenses/sources ok

Not 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_fetch against SSRF: http/https only, 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 providers feature now wires reqwest with rustls TLS (reqwest/json, reqwest/rustls-tls); Cargo.lock bumps rustls. Marketplace index fetch gets the same 30s timeout and 5-redirect cap. CI runs cargo deny check; deny.toml adds CDLA-Permissive-2.0, workspace-level unmaintained handling, and yanked = warn. Provider HTTP client build uses expect instead 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.

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-ai

capy-ai Bot commented Sep 15, 2026

Copy link
Copy Markdown

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.

Open in Capy

@cursor

cursor Bot commented Sep 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@undivisible
undivisible merged commit 2cfb154 into main Sep 16, 2026
3 checks passed
@undivisible
undivisible deleted the fix/web-fetch-ssrf-tls branch September 16, 2026 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants