{"id":"EEF-CVE-2026-59697","summary":"IMDSv2 metadata token request follows HTTP redirects in ex_aws","details":"## Summary\n\nServer-Side Request Forgery (SSRF) vulnerability in ex_aws (instance metadata token provider).\n\nThis vulnerability is associated with program files `lib/ex_aws/instance_meta_token_provider.ex` and program routines `ExAws.InstanceMetaTokenProvider.request_token/1` and `ExAws.InstanceMetaTokenProvider.get/1`.\n\nex_aws 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.\n\nThis issue affects ex_aws: from 2.3.0 before 2.8.0.\n\n## Details\n\n**1. Token request.** `ExAws.InstanceMetaTokenProvider.request_token/1` sends the IMDSv2 `PUT` to the hard-coded link-local endpoint `http://169.254.169.254/latest/api/token` with `follow_redirect: 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.\n\n**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`.\n\n**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.\n\n## Proof of concept\n\n1. 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.\n2. The application obtains a metadata token through `ExAws.InstanceMetaTokenProvider.get/1`, which calls `request_token/1` and sends `PUT /latest/api/token` to the link-local endpoint.\n3. The attacker answers the `PUT` with `302` and a `Location` header pointing at a host they control.\n4. The HTTP client follows the redirect because ex_aws passed `follow_redirect: true`, and the attacker's host replies `200` with a chosen body such as `ATTACKER-CONTROLLED-SESSION-TOKEN`.\n5. `get/1` returns that body as the IMDSv2 session token, and ex_aws caches it and sends it as `x-aws-ec2-metadata-token` on later metadata and credential requests.\n\n## Configurations\n\nThe application must obtain its AWS credentials from the EC2 Instance Metadata Service (IMDSv2) through the ex_aws 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.","aliases":["CVE-2026-59697","GHSA-mww9-g5mj-j664"],"modified":"2026-11-24T11:56:08.588748599Z","published":"2026-11-24T11:43:17.078Z","database_specific":{"cpe_ids":["cpe:2.3:a:ex-aws:ex_aws:*:*:*:*:*:*:*:*"],"cwe_ids":["CWE-918"],"capec_ids":["CAPEC-664"]},"references":[{"type":"ADVISORY","url":"https://github.com/ex-aws/ex_aws/security/advisories/GHSA-mww9-g5mj-j664"},{"type":"WEB","url":"https://cna.erlef.org/cves/CVE-2026-59697.html"},{"type":"WEB","url":"https://github.com/ex-aws/ex_aws/commit/4d7923c16f613cc2bade2ed325d444bba0bc7234"},{"type":"FIX","url":"https://github.com/ex-aws/ex_aws/commit/9fcc3605c7a0ecf8e205a72c50de3ced72befed0"},{"type":"PACKAGE","url":"https://hex.pm/packages/ex_aws"}],"affected":[{"package":{"name":"ex_aws","ecosystem":"Hex","purl":"pkg:hex/ex_aws"},"ranges":[{"type":"SEMVER","events":[{"introduced":"2.3.0"},{"fixed":"2.8.0"}]}],"versions":["2.3.0","2.3.1","2.3.2","2.3.3","2.3.4","2.4.0","2.4.1","2.4.2","2.4.3","2.4.4","2.5.0","2.5.1","2.5.10","2.5.11","2.5.2","2.5.3","2.5.4","2.5.5","2.5.6","2.5.7","2.5.8","2.5.9","2.6.0","2.6.1","2.7.0"],"database_specific":{"source":"https://cna.erlef.org/osv/EEF-CVE-2026-59697.json"}},{"ranges":[{"type":"GIT","repo":"https://github.com/ex-aws/ex_aws","events":[{"introduced":"4d7923c16f613cc2bade2ed325d444bba0bc7234"},{"fixed":"9fcc3605c7a0ecf8e205a72c50de3ced72befed0"}]}],"database_specific":{"source":"https://cna.erlef.org/osv/EEF-CVE-2026-59697.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:A/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N","source":"CNA"}],"credits":[{"name":"Peter Ullrich","type":"FINDER"},{"name":"Peter Ullrich","type":"REPORTER"},{"name":"Jonatan Männchen / EEF","type":"ANALYST"},{"name":"Peter Ullrich","type":"COORDINATOR"},{"name":"Bernard Duggan","type":"REMEDIATION_DEVELOPER"}]}