AWS IMDSv2
AWS IMDSv2 是什么?
AWS IMDSv2The session-token-based replacement for the AWS EC2 Instance Metadata Service, designed to defeat SSRF-based credential theft of EC2 instance role tokens by requiring a PUT-issued, short-lived token on every request.
IMDSv2 is the second version of the EC2 Instance Metadata Service, introduced in 2019 in direct response to the Capital One breach and other SSRF-driven cloud credential theft attacks. Unlike IMDSv1, where any code on the instance — including a webserver tricked into making a GET to `http://169.254.169.254/latest/meta-data/iam/security-credentials/`— could read the instance role credentials, IMDSv2 requires the client to first issue a PUT to `/latest/api/token` with a TTL header, then include the returned session token on every metadata read. A reflected or server-side request forgery cannot easily issue both calls because the PUT requires a non-default HTTP method and a custom header, and the response is a short-lived token. IMDSv2 also lets administrators set the `HttpPutResponseHopLimit` to 1, blocking containers on the host from reaching the metadata service. As of 2023, new AWS resources and most launch templates default to `HttpTokens: required`; legacy AMIs and infra still permitting IMDSv1 remain a common Wiz/CSPM finding and an active path for cloud token theft.
● 示例
- 01
An EC2 launch template sets `HttpTokens: required` and `HttpPutResponseHopLimit: 1`, blocking both IMDSv1 access and container-side metadata theft.
- 02
A CSPM finding flags every EC2 instance still allowing IMDSv1 because the legacy CentOS AMI was launched before the org-wide policy.
● 常见问题
AWS IMDSv2 是什么?
The session-token-based replacement for the AWS EC2 Instance Metadata Service, designed to defeat SSRF-based credential theft of EC2 instance role tokens by requiring a PUT-issued, short-lived token on every request. 它属于网络安全的 云安全 分类。
AWS IMDSv2 是什么意思?
The session-token-based replacement for the AWS EC2 Instance Metadata Service, designed to defeat SSRF-based credential theft of EC2 instance role tokens by requiring a PUT-issued, short-lived token on every request.
AWS IMDSv2 是如何工作的?
IMDSv2 is the second version of the EC2 Instance Metadata Service, introduced in 2019 in direct response to the Capital One breach and other SSRF-driven cloud credential theft attacks. Unlike IMDSv1, where any code on the instance — including a webserver tricked into making a GET to `http://169.254.169.254/latest/meta-data/iam/security-credentials/`— could read the instance role credentials, IMDSv2 requires the client to first issue a PUT to `/latest/api/token` with a TTL header, then include the returned session token on every metadata read. A reflected or server-side request forgery cannot easily issue both calls because the PUT requires a non-default HTTP method and a custom header, and the response is a short-lived token. IMDSv2 also lets administrators set the `HttpPutResponseHopLimit` to 1, blocking containers on the host from reaching the metadata service. As of 2023, new AWS resources and most launch templates default to `HttpTokens: required`; legacy AMIs and infra still permitting IMDSv1 remain a common Wiz/CSPM finding and an active path for cloud token theft.
如何防御 AWS IMDSv2?
针对 AWS IMDSv2 的防御通常结合技术控制与运营实践,详见上方完整定义。
AWS IMDSv2 还有哪些其他名称?
常见的别称包括: EC2 Instance Metadata Service v2, IMDSv2。
● 相关术语
- cloud-security№ 092
AWS IMDSv1 攻击
通过向旧版 IMDSv1 端点发送未认证的 GET 请求(通常借助 SSRF)窃取 EC2 实例角色凭据。
- cloud-security№ 208
云元数据 SSRF
一种服务端请求伪造攻击,通过有漏洞的应用让虚拟机查询云厂商的实例元数据服务,窃取临时凭据。
- attacks№ 1120
服务器端请求伪造(SSRF)
一种 Web 漏洞,使攻击者能够诱使服务器代为发起 HTTP 或其他网络请求,通常指向内部系统。
- cloud-security№ 212
云端令牌窃取
从云身份服务窃取 OAuth、SAML 或签名令牌,并重放以冒充用户或服务,无需密码。
- cloud-security№ 561
IAM 配置错误(云)
云端身份与访问管理的不安全或过度授权设置,使用户、角色或服务获得超出实际需要的权限。
- cloud-security№ 209
云配置错误
由云服务的不当或不安全设置造成的安全漏洞,例如对象存储暴露、IAM 策略薄弱或管理端口对外开放等。