EEF-CVE-2026-59697: IMDSv2 metadata token request follows HTTP redirects in ex_aws
Summary
Server-Side Request Forgery (SSRF) vulnerability in exaws (instance metadata token provider).
This vulnerability is associated with program files lib/exaws/instancemetatokenprovider.ex and program routines ExAws.InstanceMetaTokenProvider.requesttoken/1 and ExAws.InstanceMetaTokenProvider.get/1.
exaws requests its IMDSv2 session token from the link-local metadata endpoint (http://169.254.169.254/latest/api/token) with HTTP redirect following enabled. Because the token request follows 3xx redirects and does not restrict the redirect target to the link-local range, an attacker who can influence the response to the metadata request (for example an on-segment neighbor spoofing the link-local address) can answer with a redirect to an arbitrary host. The library follows the redirect and accepts the arbitrary host's response body as the IMDSv2 session token, caching it and sending it as the x-aws-ec2-metadata-token header on every subsequent metadata and credential request.
This issue affects exaws: from 2.3.0 before 2.8.0.
Details
1. Token request. ExAws.InstanceMetaTokenProvider.requesttoken/1 sends the IMDSv2 PUT to the hard-coded link-local endpoint http://169.254.169.254/latest/api/token with followredirect: true in its HTTP options. AWS advises against following redirects on metadata requests, and IMDSv2's "PUT plus required header" design is itself an SSRF mitigation.
2. Redirect following. Any 3xx reply to the token request is followed by the HTTP client to whatever host its Location header names. Nothing restricts the redirect target to the link-local range, so the request can leave 169.254.169.254.
3. Token acceptance. The body returned by the final URL is accepted verbatim as the session token, cached in ETS, and sent as the x-aws-ec2-metadata-token header on every later metadata and credential request the library makes. Whoever answers the redirect therefore chooses both where the token request ends up and which value is used as the token.
Proof of concept
1. The attacker is positioned to answer requests the instance sends to 169.254.169.254, for example as an on-segment neighbor spoofing the link-local address. 2. The application obtains a metadata token through ExAws.InstanceMetaTokenProvider.get/1, which calls requesttoken/1 and sends PUT /latest/api/token to the link-local endpoint. 3. The attacker answers the PUT with 302 and a Location header pointing at a host they control. 4. The HTTP client follows the redirect because exaws passed followredirect: true, and the attacker's host replies 200 with a chosen body such as ATTACKER-CONTROLLED-SESSION-TOKEN. 5. get/1 returns that body as the IMDSv2 session token, and exaws caches it and sends it as x-aws-ec2-metadata-token on later metadata and credential requests.
Configurations
The application must obtain its AWS credentials from the EC2 Instance Metadata Service (IMDSv2) through the exaws instance metadata token provider. Applications that source credentials by other means (for example environment variables or explicit configuration) do not reach the vulnerable code path.
Other sources
Server-Side Request Forgery (SSRF) vulnerability in exaws (instance metadata token provider).
This vulnerability is associated with program files lib/exaws/instancemetatokenprovider.ex and program routines ExAws.InstanceMetaTokenProvider.requesttoken/1 and ExAws.InstanceMetaTokenProvider.get/1.
exaws requests its IMDSv2 session token from the link-local metadata endpoint (http://169.254.169.254/latest/api/token) with HTTP redirect following enabled. Because the token request follows 3xx redirects and does not restrict the redirect target to the link-local range, an attacker who can influence the response to the metadata request (for example an on-segment neighbor spoofing the link-local address) can answer with a redirect to an arbitrary host. The library follows the redirect and accepts the arbitrary host's response body as the IMDSv2 session token, caching it and sending it as the x-aws-ec2-metadata-token header on every subsequent metadata and credential request.
This issue affects exaws: from 2.3.0 before 2.8.0.
— OSV
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
erlang/ex_awsto a version that resolves this vulnerability.Fixed in 2.8.0 - Upgrade
Upgrade
ex_awsto a version that resolves this vulnerability.Fixed in 2.8.0 - Configuration
Disable HTTP redirect following for the metadata token request.
ex_aws IMDSv2 token request follow_redirect = false
Event History
Frequently Asked Questions
Which versions are affected?
ex_aws versions from 2.3.0 up to, but not including, 2.8.0 are affected.
Does exploitation require an attacker to authenticate to the application?
No. The attacker does not need application privileges or user interaction, but must be able to influence the response to the link-local metadata token request, such as by spoofing the link-local address from an on-segment position.
Is the default metadata token request behavior affected?
Yes. The affected token request follows HTTP 3xx redirects and does not restrict redirect destinations to the link-local metadata address.
What is the impact after a malicious redirect succeeds?
The response body from an arbitrary redirect target is accepted and cached as the IMDSv2 token. It is then sent in the x-aws-ec2-metadata-token header on subsequent metadata and credential requests.
What version should be used to remediate the issue?
Upgrade to ex_aws 2.8.0 or later.