CVE-2026-59697 in ex_aws
Summary
by MITRE • 11/24/2026
Server-Side Request Forgery (SSRF) vulnerability in ex_aws (instance metadata token provider).
This 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.
ex_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.
This issue affects ex_aws: from 2.3.0 before 2.8.0.
If you want to get best quality of vulnerability data, you may have to visit VulDB.
Analysis
by VulDB Data Team • 11/24/2026
The vulnerability identified in the ex_aws library, specifically within the instance metadata token provider module, represents a critical Server-Side Request Forgery (SSRF) flaw that compromises the integrity of cloud credential retrieval mechanisms on Amazon EC2 instances. This issue stems from an improper implementation of HTTP redirect handling during the acquisition of IMDSv2 session tokens. When applications utilizing ex_aws attempt to authenticate with AWS services while running on EC2, they must first obtain a temporary security token by querying the local instance metadata service at the link-local address 169.254.169.254. The vulnerable code path in lib/ex_aws/instance_meta_token_provider.ex employs an HTTP client that automatically follows redirect responses without validating whether the new target URL remains within the trusted, non-routable link-local range. This design oversight allows a malicious actor positioned on the same network segment to intercept or spoof traffic destined for the metadata service and respond with a 3xx status code directing the request to an arbitrary external host controlled by the attacker.
From a technical perspective, the exploitation of this vulnerability relies on the ability to manipulate DNS resolution or ARP tables to redirect requests intended for 169.254.169.254 toward a malicious server. Once the ex_aws library receives the redirect response, it follows the instruction and fetches content from the attacker-controlled endpoint. The application then caches this fetched content as if it were a valid IMDSv2 session token. Subsequently, every request made to AWS services using this compromised instance will include the x-aws-ec2-metadata-token header populated with the malicious value. This effectively breaks the authentication handshake because AWS rejects tokens that do not originate from the legitimate metadata service or are malformed in structure and length, but more critically, it indicates a severe breach of trust where internal network assumptions were violated. The vulnerability is present in ex_aws versions ranging from 2.3.0 up to, but not including, version 2.8.0, affecting any Elixir-based application relying on this library for AWS authentication within EC2 environments.
The operational impact of this flaw extends beyond simple credential theft due to the specific mechanics of IMDSv2 token validation. While an attacker might hope to steal valid credentials by tricking the instance into sending requests with a fake token, AWS typically rejects invalid tokens, which may limit immediate exploitation for direct data exfiltration via standard API calls. However, the SSRF nature of this vulnerability can still be leveraged in broader attack chains. For instance, if the application performs additional internal network operations or logs sensitive information during error handling related to these failed authentication attempts, an attacker could potentially gain insights into internal infrastructure topology. Furthermore, if there are other services running on the same host that rely on similar metadata retrieval patterns without such protections, they too may be susceptible. The core risk lies in the violation of the principle of least privilege and network segmentation; by allowing outbound redirects to arbitrary hosts during an authentication handshake, the application exposes itself to man-in-the-middle attacks and potential data leakage if error messages or stack traces are returned to the attacker-controlled endpoint.
This vulnerability aligns with CWE-918, which classifies Server-Side Request Forgery (SSRF) flaws where a server makes requests based on user-supplied input without proper validation of the destination address. In this specific context, while the initial request target is hardcoded, the redirect following mechanism effectively allows an attacker to supply the final destination through network-level manipulation. From a threat intelligence perspective, such behavior maps to ATT&CK technique T1557, Adversary-in-the-Middle, specifically involving ARP or DNS spoofing on local networks to intercept and modify traffic between the victim host and its metadata service. The failure to restrict HTTP redirects to link-local addresses represents a common misconfiguration in cloud-native libraries that prioritize convenience over strict security boundaries during internal communication phases.
To mitigate this vulnerability, organizations must immediately upgrade ex_aws to version 2.8.0 or later, where the redirect handling logic has been hardened to ensure that any redirected requests remain strictly within the link-local address range defined by RFC 3927 and AWS documentation. For environments unable to patch immediately due to legacy constraints, defensive measures should include implementing strict egress firewall rules that block outbound HTTP traffic from application hosts unless explicitly whitelisted for known external endpoints, although this may interfere with legitimate cloud API calls if not configured carefully. Additionally, deploying network intrusion detection systems capable of identifying ARP spoofing or unusual redirect patterns targeting 169.254.169.254 can provide an additional layer of defense. It is also recommended to review application code for any other instances where HTTP clients are used with automatic redirect following enabled without corresponding URL validation, as this pattern poses a systemic risk across the software ecosystem. Ensuring that all dependencies in Elixir projects are kept up-to-date and regularly audited against known vulnerability databases remains essential for maintaining robust cloud security postures.