Why is IMDSv1 a vulnerability?
Because it answers a plain GET with no session. Anything that can make the instance send an HTTP request to 169.254.169.254, such as a server-side request forgery (SSRF) bug or a misconfigured open proxy, can read the metadata, including the instance role's temporary credentials, under iam/security-credentials/ and the role's name.
IMDSv2 exists to stop those relayed requests: the opening PUT, the token on every call, and the refusal of a token PUT that carries X-Forwarded-For. AWS wrote in 2019 that its analysis of real-world vulnerabilities found this combination protects against the vast majority of SSRF vulnerabilities. Security Hub rates the matching control, EC2.8, High severity.
Which instances still allow IMDSv1?
Every instance whose HttpTokens is optional. The AWS CLI lists them for one Region per call:
aws ec2 describe-instances \
--filters "Name=metadata-options.http-tokens,Values=optional" \
--query "Reservations[*].Instances[*].[InstanceId]" \
--output text
Add --region and repeat for each Region you use. In the EC2 console, the Instances list takes the filter IMDSv2 = optional.
For a count over time, use the ImdsV1Enabled CloudWatch metric: 1 when an instance allows IMDSv1, 0 when it doesn't. This Metrics Insights query averages it across instances, so 0.25 means a quarter of them still allow it:
SELECT AVG(ImdsV1Enabled) FROM SCHEMA("AWS/EC2", InstanceId)
Is anything still calling IMDSv1?
Look at the MetadataNoToken metric for the instance: it counts the times the metadata service was reached without a token. Zero over a normal working period means requiring tokens won't break anything on that instance; any other number means a process still makes IMDSv1 calls.
To find the process, AWS points to IMDS Packet Analyzer, an open-source tool that logs IMDSv1 calls during the instance's boot and while it runs. Then update that software. AWS lists the first version of each SDK that uses IMDSv2:
| Tool | First version that uses IMDSv2 |
|---|---|
| AWS CLI | 1.16.289 |
| Boto3 (Python) | 1.12.6 (botocore 1.13.25) |
| SDK for JavaScript v2 | 2.722.0 |
| SDK for Java | 1.11.678 (v1), 2.10.21 (v2) |
| SDK for Go | 1.25.38 (v1), 0.19.0 (v2) |
| SDK for .NET | 3.3.634.1 |
| SDK for Ruby | 3.79.0 |
| SDK for PHP | 3.147.7 |
From AWS's “Use a supported AWS SDK” list, read December 1, 2026. The list has more SDKs.
How do you switch IMDSv1 off on a running instance?
Set HttpTokens to required on it, with the one-instance command in step 3 of the IMDSv2 guide. The change takes effect immediately, with no stop or reboot, and touches only that instance. Once MetadataNoToken reads zero on every instance the filter above found, this loop joins AWS's two commands to switch them all in one Region:
for id in $(aws ec2 describe-instances \
--filters "Name=metadata-options.http-tokens,Values=optional" \
--query "Reservations[].Instances[].InstanceId" \
--output text); do
aws ec2 modify-instance-metadata-options \
--instance-id "$id" --http-tokens required
done
If containers on the instance read metadata, add --http-put-response-hop-limit 2: the default of 1 keeps the token from reaching them (hop limits for containers). Afterwards, watch MetadataNoTokenRejected, which counts IMDSv1 calls attempted after IMDSv1 was turned off. A value there is software you missed; setting --http-tokens optional again brings IMDSv1 back while you fix it, unless enforcement is on.
How do you stop new instances allowing IMDSv1?
Change the account default for each Region, then enforce it: the IMDSv2 guide has the loop for every Region. The default makes new launches require tokens; enforcement makes any launch that allows IMDSv1 fail, and a call that tries to turn IMDSv1 back on gets an UnsupportedOperation error.
Neither touches instances already running, so finish the switch above first. Across many accounts, an IAM policy or service control policy can deny launches unless ec2:MetadataHttpTokens is required. AMIs registered with ImdsSupport set to v2.0, Amazon Linux 2023 among them, launch with IMDSv1 off.
Which popular Terraform modules leave IMDSv1 on?
15 of the 35 most-downloaded Terraform modules that launch EC2 instances don't require tokens by default. 2 allow IMDSv1 until you flip a variable, 2 depend on the submodule, and 11 set nothing, so the Region's default or the AMI decides. The other 20, including terraform-aws-modules' eks, ec2-instance and autoscaling, require tokens.
| Module, latest version | What it sets for tokens | Checkov CKV_AWS_79 |
|---|---|---|
| Guimove/ | IMDSv1 allowed: use_imds_v2 defaults to false | Fails |
| boldlink/ | IMDSv1 allowed: http_tokens defaults to "optional" | No failure |
| PaloAltoNetworks/ | Firewall and Panorama instances need enable_imdsv2; its autoscaling group requires tokens | No failure |
| PaloAltoNetworks/ | The same as vmseries-modules | No failure |
| squareops/ | Nothing | Fails |
| infrablocks/ | Nothing (null) | No failure |
| hashicorp/ | Nothing | Fails |
| boldlink/ | Nothing (an empty map) | No failure |
| ccs-terraform/ | Nothing | Fails |
| Young-ook/ | Nothing | Fails |
| dwp/ | Nothing | Fails |
| hashicorp/ | Nothing (launch configuration) | Fails |
| hashicorp/ | Nothing (launch configuration) | Fails |
| dcos-terraform/ | Nothing | Fails |
| fpco/ | Nothing | Fails |
Each module's latest version, read in its source on December 1, 2026, from the Terraform Registry's 500 most-downloaded AWS modules.
Checkov, a free Apache-2.0 scanner, fails Terraform whose http_tokens isn't required with check CKV_AWS_79. Run on each module's source on December 2, 2026, version 3.4.14 failed 10 of the 15. It reported no failure for the other 5, boldlink/ecs-cluster among them, though that module's default is optional. A clean run is not proof. In your own repo, have it read the modules you call:
checkov -d . --check CKV_AWS_79 \
--download-external-modules True
If you use one of these, pass required yourself, or set the Region's default as above so a template that sets nothing still gets tokens. All 35 modules, with downloads and the source line for each default, are in the Terraform IMDS defaults dataset, terraform-modules-imds-defaults.csv (CC BY 4.0). The IMDSv2 guide sums up module and tool defaults, next to eksctl, Karpenter, kops and AWS CDK.
Which check fits which job?
Use the CLI filter to find instances, the metrics to see who still calls IMDSv1, Checkov for Terraform before it ships, and AWS Config when you need a record. None of them changes a setting; the ways to enforce IMDSv2 do.
| Check | What it tells you | Scope | Cost |
|---|---|---|---|
| describe-instances filter | Which instances allow IMDSv1 now | One Region a call | Free |
| Console filter IMDSv2 = optional | The same, in the Instances list | One Region | Free |
| ImdsV1Enabled metric | How many allow it, over time | Each instance, or all via a query | CloudWatch rates |
| MetadataNoToken metric | Whether software still calls IMDSv1 | Each instance | CloudWatch rates |
| MetadataNoTokenRejected metric | IMDSv1 calls refused after the switch | Each instance | CloudWatch rates |
| IMDS Packet Analyzer | Which process makes the calls | On the instance | Free, open source |
| Checkov CKV_AWS_79 | Terraform that leaves tokens optional | Each resource, before apply | Free, Apache-2.0 |
| AWS Config ec2-imdsv2-check | NON_COMPLIANT instances, with history | Each account and Region | $0.003 a recorded change + $0.001 an evaluation |
Costs read December 1, 2026; Checkov December 2, 2026. CloudWatch charges weren't read for this page; check AWS's CloudWatch pricing before alarming on these metrics.
How was this page checked?
Commands, metric definitions and SDK versions were read from AWS's documentation on December 1, 2026, and module defaults from each module's source that day; the commands are AWS's examples, and the loop joins two of them. On December 2, 2026 we ran Checkov 3.4.14 with only CKV_AWS_79 on each of the 15 modules at the commit the CSV links; a failure counts only in the module's own code, not its examples. Errors: support@winding.ai.
- Transition to using Instance Metadata Service Version 2 and Use a supported AWS SDK (AWS)
- Terraform Registry, AWS modules, and each module's source on GitHub at its latest tag (links in the CSV)
- Modify instance metadata options for existing instances and Configure instance metadata options for new instances (AWS)
- CloudWatch metrics that are available for your instances (AWS)
- Retrieve security credentials from instance metadata (AWS)
- Example policies to control access to the Amazon EC2 API (AWS)
- Add defense in depth against open firewalls, reverse proxies, and SSRF vulnerabilities, AWS Security Blog, November 19, 2019
- Checkov CKV_AWS_79 and its Apache-2.0 license, read and run December 2, 2026
- Security Hub controls for Amazon EC2, AWS Config rule ec2-imdsv2-check and AWS Config pricing