{
  "id": "security/ssrf-cloud-metadata-bypass",
  "signature": "SSRF bypasses cloud metadata endpoint block via redirect or alternative IP representation",
  "signature_zh": "SSRF通过重定向或替代IP表示绕过云元数据端点封锁",
  "regex": "SSRF.*metadata.*blocked|Request to 169.254.169.254|SSRF.*redirect.*bypass",
  "domain": "security",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "The application blocks direct requests to 169.254.169.254 but does not handle redirects to that IP or alternative representations such as decimal IP (2852039166), IPv6 mapped IPv4 (::ffff:169.254.169.254), or DNS rebinding, allowing SSRF to access cloud metadata.",
  "root_cause_type": "generic",
  "root_cause_zh": "应用程序阻止直接请求169.254.169.254，但未处理重定向到该IP或替代表示形式（如十进制IP 2852039166、IPv6映射IPv4 ::ffff:169.254.169.254或DNS重绑定），使SSRF可以访问云元数据。",
  "versions": [
    {
      "version": "AWS IMDSv1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "GCP Metadata Server 2023",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Azure IMDS 2024-02-01",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Attackers can use decimal IP (2852039166), hex (0xA9FEA9FE), or DNS names that resolve to that IP.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Does not block alternative ports (e.g., 443) or redirects that come from other IPs.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Attackers can use IPv6 mapped addresses or DNS rebinding to bypass the deny list.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use a DNS resolver that resolves all hostnames and validate that the resolved IP is not in the private or link-local range (169.254.0.0/16, 10.0.0.0/8, etc.) before making the request. Example in Python: import socket; ip = socket.gethostbyname(hostname); if ipaddress.ip_address(ip).is_private: raise Exception('Blocked SSRF')",
      "success_rate": 0.9,
      "how": "Use a DNS resolver that resolves all hostnames and validate that the resolved IP is not in the private or link-local range (169.254.0.0/16, 10.0.0.0/8, etc.) before making the request. Example in Python: import socket; ip = socket.gethostbyname(hostname); if ipaddress.ip_address(ip).is_private: raise Exception('Blocked SSRF')",
      "condition": "",
      "sources": []
    },
    {
      "action": "Disable redirect following in HTTP clients (e.g., requests.get(url, allow_redirects=False)) to prevent redirect-based SSRF",
      "success_rate": 0.85,
      "how": "Disable redirect following in HTTP clients (e.g., requests.get(url, allow_redirects=False)) to prevent redirect-based SSRF",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use IMDSv2 with a session token that requires a PUT request, making it harder for SSRF to access metadata even if the IP is reached",
      "success_rate": 0.8,
      "how": "Use IMDSv2 with a session token that requires a PUT request, making it harder for SSRF to access metadata even if the IP is reached",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use a DNS resolver that resolves all hostnames and validate that the resolved IP is not in the private or link-local range (169.254.0.0/16, 10.0.0.0/8, etc.) before making the request. Example in Python: import socket; ip = socket.gethostbyname(hostname); if ipaddress.ip_address(ip).is_private: raise Exception('Blocked SSRF')",
    "Disable redirect following in HTTP clients (e.g., requests.get(url, allow_redirects=False)) to prevent redirect-based SSRF",
    "Use IMDSv2 with a session token that requires a PUT request, making it harder for SSRF to access metadata even if the IP is reached"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html",
  "official_doc_section": null,
  "error_code": "SSRF_METADATA_BYPASS",
  "verification_tier": "ai_generated",
  "confidence": 0.89,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2025-02-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}