Skip to content

CRITICAL - DNS Rebinding (TOCTOU Race Condition) #187

@harshal-paltse

Description

@harshal-paltse

Title: TOCTOU Race Condition in SSRF Protection (DNS Rebinding Attack)
Severity: CRITICAL
Component: src/extension_shield/utils/http_safety.py (Lines 137-182)
Impact: Supply chain compromise in cloud deployments

Problem
The safe_get() function validates DNS resolution once, then requests.get() performs an independent second DNS resolution. An attacker can serve a public IP during validation and a private/cloud-metadata IP during the actual request.

Python

❌ VULNERABLE CODE:

def safe_get(url, allowed_hosts, ...):
# First DNS resolution + validation
validate_outbound_url(url, allowed_hosts) # ✓ Resolves to 1.2.3.4

# Second independent DNS resolution (VULNERABLE)
response = requests.get(url, ...)  # ❌ Can resolve to 169.254.169.254!

Attack Scenario
Code

  1. Attacker controls attacker.com DNS
  2. First check: attacker.com → 1.2.3.4 (public IP) ✓ passes
  3. Request sent: attacker.com → 169.254.169.254 (AWS metadata)
  4. ExtensionShield gets: EC2 instance credentials, IAM tokens, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature request or feature implementationgood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions