Skip to content

feat(core): one SSRF-vetted GET hop for host-side web clients (#625 part 1a) - #671

Closed
ajianaz wants to merge 1 commit into
developfrom
feat/web-vetted-hop
Closed

ajianaz wants to merge 1 commit into
developfrom
feat/web-vetted-hop

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Part 1a of #625: tole_core::web::vetted_get, a single GET hop through the existing SSRF vet-and-pin resolver, plus vet_public_url and allow_private_from_env. Part 1b (#672, stacked on this PR) builds nginjen-lite's HttpClient on it in tole-cli, so the built-in web tools keep tole's one HTTP client, one TLS stack and its SSRF guard on every redirect hop.

Depends on: nothing unmerged; based on develop.

Why

nginjen-lite brings no HTTP stack: callers implement its blocking HttpClient, ideally with lite's get_following_redirects around a transport that fetches exactly one hop. tole's SSRF guard lives in a private ureq resolver in tole-core, so tole-core exposes that one hop. tole-core stays platform-agnostic, with no new dependency (58 crates with --no-default-features, unchanged).

Changes

  • web::Hop / HopResponse / HopError, and web::vetted_get(&Hop):
    • The address is checked up front: a private or loopback host is refused before any connection, as HopError::Private. It is checked again in the connection's own resolver (SsrfResolver), which pins what it vetted, so a DNS rebinding between the two checks fails closed.
    • No redirect is followed: a 301, 302, 303, 307 or 308 with a location comes back with an unread, empty body. A non-2xx status is a response, not an error.
    • The body is capped at max_bytes. Over the cap is TooLarge, or a truncated body with truncated: true.
    • The timeout covers the hop (at most 30 s). The environment proxy is off, as for web_fetch.
    • Header names come back lower-case.
  • web::vet_public_url(url, allow_private): the http(s) and public-address check on its own.
  • web::allow_private_from_env(): TOLE_WEB_ALLOW_PRIVATE=1.
  • The existing web_fetch, web_search and backend tools are unchanged. The CHANGELOG entry and the threat-model update ship with feat(cli): built-in web_search and web_fetch on nginjen-lite (#625 part 1b) #672, which makes this reachable.
  • Memory: none resident; one ureq agent per hop, dropped after it.

Testing

  • TDD: tests/web_hop.rs went red against a stub (5 of 5 failed), then green.
  • The 5 tests use local servers on 127.0.0.1, with the opt-out passed explicitly and never through the environment. They cover:
    • status, headers and body, with request headers sent;
    • a non-2xx answer as a response;
    • a redirect returned unfollowed, with its body unread;
    • the cap as an error or as truncation;
    • private addresses refused with nothing reaching the server, and file: URLs refused;
    • the timeout.
  • Gates on the combined tree (this PR plus feat(cli): built-in web_search and web_fetch on nginjen-lite (#625 part 1b) #672):
    • cargo fmt --all
    • cargo clippy --workspace --all-targets --all-features -- -D warnings
    • cargo test --workspace
    • cargo test -p tole-core --no-default-features
    • the no-mcp commands (cargo check, clippy --features shell-tools and test for tole-cli with --no-default-features)
  • cora review --no-llm --staged: no issues.
  • Mutation breaks, each restored afterwards; the tests caught all 7:
    • no up-front SSRF check;
    • redirects followed;
    • redirect bodies read;
    • the cap ignored;
    • truncation hidden;
    • non-2xx as an error;
    • a timeout reported as a transport error.

…art 1a)

web::vetted_get performs a single GET through the existing vet-and-pin
resolver: the host is checked up front (a private address is refused
before any connection) and again in the connection's own resolver. No
redirect is followed (a 3xx comes back with an unread body), a non-2xx
status is a response rather than an error, the body is capped (error or
truncate and flag) and the timeout covers the hop. vet_public_url and
allow_private_from_env expose the check and the opt-out.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

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