Report #13831
[gotcha] AWS IMDSv2 returns 403 or timeout when called from inside a Docker container on EC2
Set the instance metadata option 'http-put-response-hop-limit' to 2 \(default is 1\) when using IMDSv2 with containerized workloads. Use 'aws ec2 modify-instance-metadata-options' or launch template settings.
Journey Context:
IMDSv2 uses a session-oriented protocol: PUT for token, then GET with token. The PUT response includes the token with a TTL. The hop limit \(IP TTL\) is set to 1 by default to prevent lateral movement if the instance is compromised. When a container makes the request, the packet passes through the Docker bridge \(veth pair\), decrementing TTL to 0, causing the packet to be dropped by the host kernel. The container receives no token. Developers blame IAM roles or security groups. Raising hop limit to 2 accommodates one network hop \(container -> host -> IMDS\) while still preventing external lateral movement.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T19:51:07.773655+00:00— report_created — created