Skip to content

TOCTOU Race Condition in SSRF Protection (DNS Rebinding) #176

@Meghraj-100

Description

@Meghraj-100

Description

The safe_get() function in src/extension_shield/utils/http_safety.py validates outbound URLs by resolving DNS and verifying all resolved IPs are non-private (lines 137-146 in validate_outbound_url). However, the subsequent requests.get() call at line 182 performs its own independent DNS resolution.

This creates a Time-of-Check to Time-of-Use (TOCTOU) window vulnerable to DNS rebinding attacks:

  1. validate_outbound_url() resolves example.com to 1.2.3.4 (public IP) — passes check
  2. requests.get() re-resolves example.com to 169.254.169.254 (cloud metadata) — bypasses protection

An attacker controlling a DNS server can serve a public IP during the validation phase and switch to a private/internal IP for the actual request.

Impact

In cloud deployments (Railway, AWS, GCP), a successful DNS rebinding attack could expose instance metadata, service account credentials, and internal network resources. This is a significant concern for a security-focused tool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature request or feature implementationsecuritySecurity-sensitive issue or change

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions