Skip to content

🔒 Fix SSRF vulnerability in std.web.fetch - #52

Merged
Tcode-Motion merged 2 commits into
mainfrom
fix/web-ssrf-2495096785143464329
Aug 25, 2026
Merged

🔒 Fix SSRF vulnerability in std.web.fetch#52
Tcode-Motion merged 2 commits into
mainfrom
fix/web-ssrf-2495096785143464329

Conversation

@Tcode-Motion

Copy link
Copy Markdown
Owner

🎯 What: Fixed an SSRF (Server-Side Request Forgery) vulnerability in stdlib/src/web.rs where the fetch function blindly retrieved user-provided URLs.
⚠️Risk: Attackers could supply URLs pointing to internal infrastructure (127.0.0.1, AWS metadata 169.254.169.254, internal subnets), exposing sensitive internal data, configuration, or performing unauthorized actions on internal APIs.
🛡️ Solution: Implemented a robust validation mechanism:

  • Used the url crate to parse and validate incoming URLs.
  • Introduced a custom ureq::Resolver (SafeResolver) that filters out all private, loopback, link-local, broadcast, and unspecified IP addresses (IPv4 and IPv6). This resolves the IP at connection time, preventing DNS rebinding (TOCTOU) attacks.
  • Configured the ureq HTTP agent with .redirects(0) to prevent attackers from bypassing the check via 3xx redirects to internal IPs.

PR created automatically by Jules for task 2495096785143464329 started by @Tcode-Motion

This commit addresses a Server-Side Request Forgery (SSRF) vulnerability
in the `fetch` function of the standard `web` module. Previously, user-provided
URLs were passed directly to `ureq::get`, allowing attackers to probe
internal networks, access metadata services (like 169.254.169.254), or
hit loopback addresses.
The fix introduces a custom `SafeResolver` for the `ureq` client that blocks
resolution of private, loopback, link-local, broadcast, and unspecified
IP addresses (for both IPv4 and IPv6, including IPv4-mapped IPv6 addresses).
By doing this at the resolver level, we prevent DNS rebinding (TOCTOU) attacks.
Additionally, HTTP redirects are explicitly disabled (`.redirects(0)`) to prevent
bypasses where an external safe server redirects to an internal malicious IP.
Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@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.

@Tcode-Motion
Tcode-Motion marked this pull request as ready for review August 25, 2026 10:22
@Tcode-Motion
Tcode-Motion merged commit c5a3c25 into mainAug 25, 2026
0 of 6 checks passed
Sign up for freeto 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

@Tcode-Motion