Am I affected?

type your ex_aws version to check

Description

Relative path traversal in ex_aws allows an attacker who controls an S3 object key to escape the intended bucket or key prefix.

When ex_aws builds a path-style S3 request, ExAws.Operation.S3.add_bucket_to_path/2 in lib/ex_aws/operation/s3.ex joins the bucket name and the object key into a single path string and then normalizes it, collapsing . and .. segments the way a filesystem path would. Because the bucket is the first segment of the combined string, a leading ../ in the object key pops the bucket off the path. With bucket mybucket and a key of ../victim/secret.txt, the combined /mybucket/../victim/secret.txt normalizes to /victim/secret.txt, so the request (signed with the application's own credentials) is sent to bucket victim. The same mechanism collapses ../ within a key, defeating any isolation an application enforces by prepending a trusted prefix.

Only the default path-style configuration is affected; requests built with virtual_host: true do not run this normalization. Because S3 treats object keys as opaque and does not resolve .. itself, the client-side normalization introduces a traversal that would not otherwise exist. Any application that derives an S3 object key from untrusted input and relies on the bucket, or a key prefix, as a tenant or trust boundary is exposed to cross-bucket or cross-prefix read and write, depending on the operation and the credentials' permissions.

This issue affects ex_aws: from 2.1.7 before 2.8.0.

Technical analysis

1. Path assembly. In the default path-style clause of ExAws.Operation.S3.add_bucket_to_path/2 (taken whenever virtual_host: true is not set), the bucket and the operation path are concatenated and then normalized: "/#{operation.bucket}#{ensure_absolute(operation.path)}" |> expand_dot().

2. Normalization across the bucket boundary. expand_dot/1 and do_expand_dot/2 resolve . and .. segments the way a filesystem path would. The bucket is just the first segment of the combined string, so a .. in the object key pops it: /mybucket/../victim/secret.txt becomes /victim/secret.txt. The only guard, the root clamp do_expand_dot([".." | t], []), stops .. from climbing above / but does not protect the bucket segment. The same collapse lets ../ escape a trusted key prefix within a bucket.

3. Signed request. The normalized path is signed with the application's credentials and sent, so the request is authorized against the bucket or prefix the attacker chose. S3 treats object keys as opaque and does not resolve .. itself; the traversal exists only because the client normalizes the path. The virtual_host clauses do not normalize, so behavior differs between configurations.

Proof of concept

  1. An application isolates data in its own bucket mybucket and builds the object key from user input, using the default path-style S3 configuration.
  2. It issues the request through the public API: ExAws.S3.get_object("mybucket", key) |> ExAws.request(config).
  3. The attacker supplies the key ../victim/secret.txt.
  4. ex_aws joins and normalizes the path, so /mybucket/../victim/secret.txt becomes /victim/secret.txt.
  5. The request is signed with the application's credentials and sent to /victim/secret.txt, addressing bucket victim instead of mybucket.

Weaknesses & attack patterns

Weakness

CWE-23 · Relative Path Traversal in catalog → MITRE ↗

Attack patterns

CAPEC-139 · Relative Path Traversal MITRE ↗

Affected — Hex / ex_aws Hex.pm ↗ Repository ↗

≥ 2.1.7 < 2.8.0 affected
every other version: unaffected
cpe cpe:2.3:a:ex-aws:ex_aws:*:*:*:*:*:*:*:*
version type semver
modules · source files · routines
modules 'Elixir.ExAws.Operation.S3'
source files lib/ex_aws/operation/s3.ex
routines 'Elixir.ExAws.Operation.S3':add_bucket_to_path/2

Affected — GitHub / ex-aws/ex_aws Repository ↗

≥ 557d343 < b1116f9 affected
every other version: unaffected
cpe cpe:2.3:a:ex-aws:ex_aws:*:*:*:*:*:*:*:*
version type git
modules · source files · routines
modules 'Elixir.ExAws.Operation.S3'
source files lib/ex_aws/operation/s3.ex
routines 'Elixir.ExAws.Operation.S3':add_bucket_to_path/2

Workarounds

Configure the ex_aws S3 client with virtual_host: true, which builds the request without the client-side path normalization. Alternatively, reject or sanitize object keys that contain .. segments before passing them to ex_aws.

Configurations

The vulnerability is only exposed in the default path-style S3 configuration, where ex_aws normalizes the combined bucket and key path. Applications that configure the S3 client with virtual_host: true build the request without this client-side normalization and are not affected.

References

Credits

Peter Ullrich Finder Reporter Coordinator
Jonatan Männchen / EEF Analyst
Bernard Duggan Remediation developer

CVSS breakdown

CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N

Exploitability

Attack Vector
Local
Attack Complexity
Low
Attack Requirements
Present
Privileges Required
None
User Interaction
None

Vulnerable System

Confidentiality
High
Integrity
High
Availability
None

Subsequent Systems

Confidentiality
None
Integrity
None
Availability
None
« All CVEs