Skip to content

🛡️ Sentinel: [CRITICAL] Fix SSRF vulnerability in web_fetch tool#596

Open
mudcube wants to merge 1 commit into
mainfrom
sentinel/fix-ssrf-web-fetch-55156631330636357
Open

🛡️ Sentinel: [CRITICAL] Fix SSRF vulnerability in web_fetch tool#596
mudcube wants to merge 1 commit into
mainfrom
sentinel/fix-ssrf-web-fetch-55156631330636357

Conversation

@mudcube

@mudcube mudcube commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

🚨 Severity: CRITICAL

💡 Vulnerability: Server-Side Request Forgery (SSRF) in the web_fetch tool. The tool previously used reqwest::blocking::get directly with user-supplied URLs, allowing an attacker to request internal network services and bypass DNS-based validation due to TOCTOU DNS Rebinding.

🎯 Impact: An attacker could use the web_fetch tool to access and exfiltrate data from internal or restricted network services (e.g., localhost, AWS metadata service, private subnets) that the agent host has access to.

🔧 Fix:

  1. Replaced the direct reqwest::blocking::get call with a manual DNS resolution loop.
  2. Added an is_allowed_ip blocklist that correctly validates all returned IP addresses, explicitly blocking 0.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, IPv4-mapped IPv6 addresses, and IPv6 unique-local/link-local ranges.
  3. Prevented TOCTOU DNS Rebinding by explicitly pinning the validated IP address to the hostname using reqwest::blocking::ClientBuilder::resolve(). This preserves the original hostname, allowing SNI and HTTPS to continue functioning.
  4. Disabled automatic HTTP redirects in the client and implemented manual redirect tracking (up to 10 redirects) via Url::join, ensuring that any external redirect target also undergoes the same strict IP validation.

Verification:

  • Verified that the crate successfully compiles (cargo check -p mill-plugin-system).
  • Ensured all tests pass (cargo test -p mill-plugin-system).
  • Ensured code formatting and linting pass with no warnings (cargo fmt -p mill-plugin-system and cargo clippy -p mill-plugin-system).
  • Added a detailed entry to .jules/sentinel.md documenting the SSRF mitigation and DNS Rebinding prevention strategy.

PR created automatically by Jules for task 55156631330636357 started by @mudcube

Mitigate SSRF in `handle_web_fetch` by replacing `reqwest::blocking::get` with a manual IP resolution and validation loop.

* Implement `is_allowed_ip` to strictly filter loopback, private (10.x, 172.16..=31, 192.168), link-local, unspecified (0.0.0.0/8), multicast, and broadcast addresses across IPv4 and IPv6 (including IPv4-mapped IPv6).
* Prevent TOCTOU DNS Rebinding by explicitly pinning the validated IP address using `reqwest::blocking::ClientBuilder::resolve()`.
* Disable automatic redirects and handle `Location` headers manually to ensure redirect targets undergo the same IP validation loop, preventing SSRF bypasses via external redirects.
* Preserve original hostname for SNI and HTTPS compatibility.

Co-authored-by: mudcube <101564+mudcube@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying typemill with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1300429
Status: ✅  Deploy successful!
Preview URL: https://4fd8cb88.typemill.pages.dev
Branch Preview URL: https://sentinel-fix-ssrf-web-fetch-47fw.typemill.pages.dev

View logs

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.

1 participant