Skip to content

🔒 Fix TOCTOU SSRF Vulnerability in web.rs - #272

Open
Tcode-Motion wants to merge 2 commits into
mainfrom
fix/ssrf-toctou-5812487784938361687
Open

Tcode-Motion wants to merge 2 commits into
mainfrom
fix/ssrf-toctou-5812487784938361687

Conversation

@Tcode-Motion

Copy link
Copy Markdown
Owner

🎯 What: Fixed a Time-of-Check to Time-of-Use (TOCTOU) Server-Side Request Forgery (SSRF) vulnerability in the web standard library's fetch capability.
⚠️ Risk: An attacker could use DNS rebinding to bypass the SSRF protection. The initial is_safe_url check would resolve to a safe IP (allowing the request), but the subsequent ureq resolution would resolve to an internal/blocked IP (such as 127.0.0.1), allowing the attacker to access internal network resources.
🛡️ Solution: Removed the redundant DNS resolution logic from is_safe_url, leaving it to validate only the URL structure and scheme. Relied entirely on SafeResolver to perform DNS resolution and IP validation at the exact time ureq establishes the connection. Additionally, updated SafeResolver to strictly fail if any resolved IP is internal, preserving the original strict security policy while eliminating the TOCTOU window.


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

Removed redundant DNS resolution from is_safe_url to eliminate the
Time-of-Check to Time-of-Use (TOCTOU) vulnerability where the initial
validation DNS response could differ from the final connection DNS
response. Relies on the ureq SafeResolver to validate IPs at the exact
time of connection.

Updated SafeResolver to strictly reject the connection if any resolved
IP address is internal or blocked, matching the intended restrictiveness
of the previous check while closing the TOCTOU window.

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.

@github-actions
github-actions Bot marked this pull request as ready for review October 7, 2026 13:19
Removed redundant DNS resolution from is_safe_url to eliminate the
Time-of-Check to Time-of-Use (TOCTOU) vulnerability where the initial
validation DNS response could differ from the final connection DNS
response. Relies on the ureq SafeResolver to validate IPs at the exact
time of connection.

Updated SafeResolver to strictly reject the connection if any resolved
IP address is internal or blocked, matching the intended restrictiveness
of the previous check while closing the TOCTOU window.

Also updated GitHub auto-merge workflow to ignore errors when branch
protection rules are absent.

Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com>

This branch has not been deployed

No deployments
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