Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Is IMDSv2?

IMDSv2 is the session-oriented version of the AWS instance metadata service. It requires a PUT request for a token, which ordinary request forgery cannot produce.

Illustration for the cybersecurity term IMDSv2
Home / Blog / Cybersecurity Terms / What Is IMDSv2?
17 November 2026

What Is IMDSv2?

What Is IMDSv2?

IMDSv2 is the second version of the AWS instance metadata service, introduced in November 2019 as a direct answer to credential theft through server-side request forgery. Where the original version answered any GET request arriving at 169.254.169.254, version 2 requires the caller to obtain a session token first and present it on every subsequent request. That one change removes the most common exploitation path, because the techniques that trick an application into fetching a URL generally cannot shape the request the way the token exchange demands.

What the Session Flow Requires

A caller sends a PUT request to the token endpoint with a header specifying the desired token lifetime, receives a token in the body, and includes that token in a header on each metadata request. Three properties of that exchange matter:

The service also refuses token requests carrying X-Forwarded-For, which blocks a class of attack routed through a misconfigured reverse proxy.

The Hop Limit

The second control is a TTL on the response packet. The default hop limit of 1 means the metadata response cannot traverse a network hop, so a container on a bridged network, or a workload one hop away from the host, does not receive it. This is genuinely useful, with one caveat that catches people out: some container networking configurations put pods one hop from the host, so a hop limit of 1 breaks legitimate access while a limit of 2 restores it and simultaneously widens exposure. The better answer for containers is not to raise the limit but to give each workload its own identity and block metadata access entirely, as set out in our entry on the IMDS attack.

Enforcing It Across an Estate

Supporting IMDSv2 is not the same as requiring it. An instance configured in optional mode still answers version 1 requests, so the protection does nothing. The setting you need is HttpTokens: required.

  1. Audit current state. The MetadataOptions field on every instance tells you which mode it is in, and AWS Config and Security Hub both have controls for this.
  2. Check the software. Current AWS SDKs and the CLI handle the token exchange transparently, but older versions, hand-rolled scripts that curl the endpoint, and some third-party agents do not. Those are the things that break.
  3. Set the default. AWS has made IMDSv2 the default for newly launched instances on most instance types, and you can set an account-level default per region so new launches require tokens regardless of the launch template.
  4. Fix launch templates, Auto Scaling groups, and AMI build pipelines, because instances are usually replaced rather than modified.
  5. Enforce with policy. A service control policy denying ec2:RunInstances unless ec2:MetadataHttpTokens equals required stops regression permanently—see service control policies.

You can disable the metadata service outright on instances that do not need it, which is the strongest option where a workload carries no instance role.

The Other Providers

Azure’s instance metadata service requires a Metadata: true header and refuses requests containing X-Forwarded-For. Google Cloud requires Metadata-Flavor: Google on its v1 endpoint. Both defeat the simplest forgery attempts but not an attacker who can set headers, so neither is as strong as the session exchange. Google additionally offers metadata concealment for GKE, and both platforms support giving workloads their own identities so that node credentials are not the fallback.

What It Does Not Fix

IMDSv2 raises the cost of one exploitation path. It does nothing against an attacker with command execution on the instance, who simply runs the token exchange themselves. It does not reduce the permissions on the role, so a stolen credential is as damaging as it ever was. And it does not address the application flaw that enabled the forgery in the first place.

Treat it as one of three layers: enforce the session requirement, scope the instance role to the minimum the workload uses, and alert when instance credentials are used from outside the provider’s address ranges. Together those make the path uneconomic; individually, none of them closes it.

At Privia Security, we verify metadata configuration and credential exposure across AWS estates through our cloud security services.

FAQ – Frequently Asked Questions

Does Enabling IMDSv2 Break Existing Applications?

Current AWS SDKs and the CLI handle the token exchange automatically, so most applications are unaffected. Breakage comes from old SDK versions, hand-written scripts that fetch the endpoint directly, and some third-party agents. Audit for those before enforcing, test in a non-production account, and roll the change out through launch templates and image pipelines rather than editing live instances.

What Is the Hop Limit and What Should I Set It To?

It is the TTL on metadata responses, controlling how many network hops they may traverse. The default of 1 prevents containers on a bridged network from reaching the endpoint, which is usually what you want. Some container network configurations require 2 for legitimate access; rather than raising it, give workloads their own identities and block metadata access from pods entirely.

Is Optional Mode Good Enough?

No. In optional mode the instance still answers version 1 requests, so an attacker exploiting a request forgery flaw simply uses the old path and the protection contributes nothing. Optional mode exists only as a migration state. Audit for it, set HttpTokens to required, and prevent regression with an account-level default and an organisation policy on instance launches.

Do Azure and Google Cloud Have an Equivalent?

Both require a custom request header—Metadata: true on Azure, Metadata-Flavor: Google on Google Cloud—which blocks the simplest forgery attempts but not an attacker able to set headers. Neither uses a session token exchange, so the protection is weaker than IMDSv2. Both offer workload-level identities, and Google provides metadata concealment for GKE, which are the stronger controls on those platforms.

Related Terms

You May Be Interested In These

What Is LDAP?

Cybersecurity Terms

17 November 2026

What Is LDAP?

Read More