SSRF-004
security
network_error
ai_generated
true
SSRF: AWS metadata endpoint accessed via DNS rebinding bypassing IP-based blocklists
ID: security/ssrf-aws-metadata-timing
78%Fix Rate
82%Confidence
1Evidence
2023-11-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| AWS EC2 | active | — | — | — |
| Kubernetes 1.28 | active | — | — | — |
| Python requests 2.31.0 | active | — | — | — |
Root Cause
An SSRF filter blocks requests to 169.254.169.254 by IP, but an attacker uses a domain that initially resolves to a benign IP and later rebinds to the metadata endpoint during the request.
generic中文
SSRF 过滤器通过 IP 阻止对 169.254.169.254 的请求,但攻击者使用一个最初解析为良性 IP 的域名,在请求过程中重新绑定到元数据端点。
Official Documentation
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.htmlWorkarounds
-
78% success Implement a DNS pinning mechanism: resolve the domain once and reject if the IP is in the blocklist, then use the resolved IP for the connection. Example in Python: `socket.getaddrinfo(url)` then check IP before making request.
Implement a DNS pinning mechanism: resolve the domain once and reject if the IP is in the blocklist, then use the resolved IP for the connection. Example in Python: `socket.getaddrinfo(url)` then check IP before making request.
-
82% success Use a proxy that enforces DNS resolution and IP validation before forwarding requests, such as Squid with strict ACLs.
Use a proxy that enforces DNS resolution and IP validation before forwarding requests, such as Squid with strict ACLs.
-
75% success Disable HTTP redirects and follow redirects manually with IP validation at each step
Disable HTTP redirects and follow redirects manually with IP validation at each step
中文步骤
Implement a DNS pinning mechanism: resolve the domain once and reject if the IP is in the blocklist, then use the resolved IP for the connection. Example in Python: `socket.getaddrinfo(url)` then check IP before making request.
Use a proxy that enforces DNS resolution and IP validation before forwarding requests, such as Squid with strict ACLs.
Disable HTTP redirects and follow redirects manually with IP validation at each step
Dead Ends
Common approaches that don't work:
-
85% fail
DNS rebinding bypasses IP blocklists because the IP changes after the initial DNS resolution
-
90% fail
The IP can change mid-request; a single check is insufficient
-
75% fail
This breaks legitimate functionality and is not a practical fix