Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
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.

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.
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 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.
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.
MetadataOptions field on every instance tells you which mode it is in, and AWS Config and Security Hub both have controls for this.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.
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.
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.
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.
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.
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.
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.
You May Be Interested In These
Cybersecurity Terms
17 November 2026
What Are Preventive, Detective and Corrective Controls?
Read MoreWe use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.