feat(security)!: add SSRF protection with safe-by-default DNS policy#17
Merged
feat(security)!: add SSRF protection with safe-by-default DNS policy#17
Conversation
Add threat model (specs/threat-model.md) with 37 identified threats across 6 categories (SSRF, Network, Input, DoS, Leakage, Conversion) using stable TM-XXX-NNN IDs. Implement resolve-then-check in fetchkit core: - DnsPolicy resolves hostnames to IPs before connecting - Validates against blocked ranges (private, loopback, link-local, metadata, multicast, etc.) - Pins validated IP via reqwest::resolve() to prevent DNS rebinding - Handles IPv6-mapped-IPv4 via to_canonical() - Opt-in via ToolBuilder::block_private_ips(true) Integrate into both DefaultFetcher and GitHubRepoFetcher. Add 20 SSRF security tests covering attack vectors from threat model. https://claude.ai/code/session_011H7YzDQ8VXbaNT7nXGQgmE
BREAKING: DnsPolicy::default() now blocks private/reserved IPs. Tool::default() and fetch() block loopback, private, link-local, metadata, multicast, and other reserved IP ranges out of the box. Callers that need to connect to private IPs (e.g., local dev servers) must explicitly opt out via: Tool::builder().block_private_ips(false).build() This is a security-first default — better to block by default and require explicit opt-out than to be permissive and hope callers remember to enable protection. https://claude.ai/code/session_011H7YzDQ8VXbaNT7nXGQgmE
- specs/initial.md: add SSRF prevention section, update error messages, add block_private_ips to tool builder, add SSRF test requirements - specs/fetchers.md: add dns_policy to FetchOptions, add SSRF section, add dns.rs to module structure - AGENTS.md: add threat-model.md to available specs list - README.md: add SSRF protection to features, add Security section with usage examples https://claude.ai/code/session_011H7YzDQ8VXbaNT7nXGQgmE
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
What
Add comprehensive SSRF protection to FetchKit with a resolve-then-check DNS policy that blocks private/reserved IP ranges by default.
Why
FetchKit is designed to be embedded in AI agent platforms (e.g., Everruns) where untrusted user prompts influence which URLs are fetched. Without SSRF protection, agents running in containers/clusters can be tricked into accessing internal resources (cloud metadata, Kubernetes API, internal services).
How
crates/fetchkit/src/dns.rs): Resolves hostnames to IPs before connecting, validates against 14 blocked IP ranges, pins validated IP viareqwest::resolve()to prevent DNS rebinding, handles IPv6-mapped-IPv4 viato_canonical()DnsPolicy::default()blocks private IPs.Tool::default(),Tool::builder().build(), andfetch()all block by default. Explicit opt-out viablock_private_ips(false)for local devspecs/threat-model.md): 37 threats across 6 categories with stable TM-XXX-NNN IDs, mitigation tracking, and vulnerability summaryBlocked IP ranges
Loopback, private (10/172/192), link-local (169.254 incl. cloud metadata), carrier-grade NAT, documentation, benchmarking, multicast, broadcast, unspecified, IPv6 unique-local/link-local
Risk
DnsPolicy::default()now blocks private IPs. Any consumer connecting to private IPs without explicit opt-out will getBlockedUrlerrors. This is intentional — safe-by-default.Checklist
-D warnings)cargo fmt)https://claude.ai/code/session_011H7YzDQ8VXbaNT7nXGQgmE