Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Enforce IMDSv2
Cyber Security

Enforce IMDSv2

← Back to Glossary
By NHI Mgmt Group Updated November 26, 2026 Domain: Cyber Security

Enforce IMDSv2 means configuring EC2 instances so the instance metadata service accepts only session-token requests, not IMDSv1 requests. Attackers use server-side request forgery to read role credentials from the metadata endpoint; the token requirement blocks many such attacks. Defenders set the HttpTokens option to required and audit instances still permitting IMDSv1.

What IMDSv2 enforcement changes in EC2

Enforcing IMDSv2 changes the instance metadata service from a permissive metadata endpoint into a token-based one. That matters because many SSRF payloads succeed by making the workload fetch role credentials from metadata without proving it is an authorised in-instance caller. Requiring a session token closes off that easy read path.

For practitioners, the key distinction is not whether metadata still exists, but whether the workload can obtain it without first completing the IMDSv2 token exchange. In an EC2 environment, that turns metadata access from a simple unauthenticated network request into a controlled, stateful interaction.

Why metadata-service hardening is an access-control issue

IMDSv2 is often described as a cloud hardening setting, but the security effect is really about constraining access to short-lived role credentials. Those credentials can authorize actions far beyond the instance itself, so the metadata service becomes part of the access-control boundary for the workload.

That is why IMDSv1 exposure is risky even when the instance itself seems otherwise well configured. If an attacker can trick software on the box into making an outbound request, they may use that request to pivot back to the local metadata endpoint and retrieve credentials intended for the instance role.

Enforcing the token requirement reduces that blast radius because the attacker must also satisfy the IMDSv2 session-token flow. It does not remove the need for least privilege on the instance role, but it removes one of the most common credential-exposure shortcuts.

See also the broader cloud workload identity context in Cloud Workload Identity Guide, which explains why temporary cloud credentials should be treated as first-class identity material.

How teams check whether they still allow IMDSv1

The first exposure check is configuration inventory: find which EC2 instances still permit metadata requests without tokens, then separate intentional exceptions from drift. In large estates, account-level defaults help, but they do not replace instance-level verification because older launches and inherited templates can preserve weak settings.

Teams also need to look for indirect exposure paths. An instance may be technically configured for IMDSv2 yet still be reachable from untrusted code running nearby, especially in containerized or shared compute patterns where local request paths are easier to abuse.

Use vendor guidance for the exact settings and audit commands, then confirm the current state in the cloud control plane rather than assuming a template change has propagated everywhere. EC2 Instance Metadata Service Hardening Guide covers enforcement patterns, hop limits, and account defaults for that review.

For teams mapping exposure to attack patterns, OWASP Top 10 API7 Server-Side Request Forgery Guide is useful because it ties SSRF prevention to concrete controls and testing.

Why enforcement works best with layered cloud controls

IMDSv2 should be treated as one control in a broader set of guardrails, not as a standalone fix. If the role behind the instance is overly broad, stolen role credentials can still do damage even though metadata access is harder to abuse.

That is why the surrounding control set matters: least-privilege role design, network restrictions on where requests can go, secure platform defaults, and monitoring for credential-exposure patterns all reinforce the same boundary. The hardening goal is to make both exploitation and post-exploitation use less rewarding.

A useful mental model is to pair metadata hardening with broader cloud misconfiguration review. Cloud Misconfiguration Guide places IMDSv2 alongside other drift and hardening failures that create avoidable exposure.

For organisations that prefer a general AWS control baseline, AWS Security Guide gives the wider account, logging and guardrail context in which IMDSv2 sits.

Detection and post-exploitation review for metadata abuse

Detection starts with knowing whether any workload should have needed IMDSv1 at all. If not, repeated metadata access without tokens is a sign of either stale configuration or attempted abuse. If compromise is suspected, review role usage, unusual instance-to-metadata access patterns, and any downstream API calls made with temporary credentials.

Post-exploitation review should assume the attacker may have used those credentials quickly and quietly. The important question is not only whether the instance was vulnerable, but whether any temporary credentials were issued, copied, or used before the setting was fixed.

That review aligns well with ATT&CK-style credential discovery and metadata abuse techniques, including the local metadata endpoint. MITRE ATT&CK T1552 Unsecured Credentials Guide is useful where metadata access is part of a broader credential-exposure investigation.

For attack-path context, the Capital One breach 2019 page remains a concrete illustration of why metadata endpoints and role credentials are such valuable targets.

Defenders often also pair the setting with broader mitigation patterns such as M1035 Limit Access to Resource Over Network when they want to reduce the reach of the systems that can initiate the abuse path.

Risk and Threat Considerations

Enforcing IMDSv2 matters because the metadata endpoint is a common bridge from application-layer SSRF to cloud role credential theft. If IMDSv1 remains allowed, an attacker who can influence a server-side request may be able to retrieve temporary credentials and then use those credentials for privilege-bearing cloud actions.

Failure mechanism: A vulnerable application or service makes a local request to the metadata IP on behalf of the attacker, and the instance returns credentials because token enforcement is not required.

Impact: Temporary cloud credentials can be exposed, abused for unauthorized API calls, and used to expand access beyond the original workload, especially when the attached role is broader than necessary.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK and OWASP API Security Top 10 address the attack and risk surface, while NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5IA-5 — Authenticator ManagementIMDSv2 relies on short-lived session tokens and credential lifecycle control.
IA-9 — Service Identification and AuthenticationEC2 metadata access authenticates a workload service path rather than a human user.
AC-6 — Least PrivilegeInstance role credentials exposed through metadata should have minimal permissions.
Recommendation — Require token-based metadata access and manage related credentials with strict rotation and expiry controls. Treat metadata-token exchange as service authentication and restrict it to the intended workload path. Limit instance role permissions so any leaked metadata credentials have minimal operational reach.
CIS Controls v8CIS-6 — Access Control ManagementIMDSv2 enforcement reduces unnecessary credential exposure on cloud instances.
Recommendation — Remove or constrain weak metadata access paths and validate cloud instance access settings.
MITRE ATT&CKT1552.005 — Cloud Instance Metadata APIThe term directly addresses attacker abuse of the cloud metadata API for credential access.
Recommendation — Map metadata abuse detections to T1552.005 and hunt for temporary credential theft or reuse.
OWASP API Security Top 10API7 — Server Side Request ForgeryIMDSv2 is a direct mitigation for SSRF-driven metadata credential theft.
Recommendation — Harden URL-consuming features and test SSRF paths that could reach instance metadata.

Practitioner Guidance

Why practitioners should care: Treat IMDSv2 enforcement as a baseline control for any EC2 workload that can reach metadata, especially internet-facing services, proxy-heavy applications, and shared compute patterns. It is one of the simplest ways to remove a high-value credential-exposure path without changing application logic.

Practitioner takeaway: Verify that token enforcement is required everywhere by default, then review the attached instance role as if any metadata leak would be immediately usable.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 26, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org