Am I affected?

This record states its affected versions in a form that can't be compared automatically.

1.9.0-rc1 and up affected
1.15.4 not affected
every other version: unaffected

Description

Improper path validation vulnerability in the Gleam compiler's handling of git dependencies allows arbitrary file system modification during dependency download.

Dependency names from gleam.toml and manifest.toml are incorporated into filesystem paths without sufficient validation or confinement to the intended dependency directory, allowing attacker-controlled paths (via relative traversal such as ../ or absolute paths) to target filesystem locations outside that directory. When resolving git dependencies (e.g. via gleam deps download), the computed path is used for filesystem operations including directory deletion and creation.

This vulnerability occurs during the dependency resolution and download phase, which is generally expected to be limited to fetching and preparing dependencies within a confined directory. A malicious direct or transitive git dependency can exploit this issue to delete and overwrite arbitrary directories outside the intended dependency directory, including attacker-chosen absolute paths, potentially causing data loss. In some environments, this may be further leveraged to achieve code execution, for example by overwriting git hooks or shell configuration files.

This issue affects Gleam from 1.9.0-rc1 until 1.15.4.

Weaknesses & attack patterns

Weakness

CWE-22 · Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') in catalog → MITRE ↗

Attack patterns

CAPEC-139 · Relative Path Traversal MITRE ↗
CAPEC-597 · Absolute Path Traversal MITRE ↗

Affected — Gleam

1.9.0-rc1 and up affected
1.15.4 not affected
every other version: unaffected
default status unaffected
cpe cpe:2.3:a:gleam-lang:gleam:*:*:*:*:*:*:*:*
modules · source files · routines
modules compiler-core
source files compiler-core/src/config.rs · compiler-core/src/manifest.rs
routines compiler_core::config::dependencies_map::deserialize · compiler_core::config::package_name::deserialize

Affected — GitHub / gleam-lang/gleam Repository ↗

1.9.0-rc1 and up affected
1.15.4 not affected
a4fde22 and up affected
92aae39 not affected
2dc0467 not affected
every other version: unaffected
default status unaffected
cpe cpe:2.3:a:gleam-lang:gleam:*:*:*:*:*:*:*:*
modules · source files · routines
modules compiler-core
source files compiler-core/src/config.rs · compiler-core/src/manifest.rs
routines compiler_core::config::dependencies_map::deserialize · compiler_core::config::package_name::deserialize

Affected — ghcr.io / gleam-lang/gleam Container registry ↗

v1.9.0-rc1-elixir < v1.15.4-elixir affected
v1.9.0-rc1-erlang < v1.15.4-erlang affected
v1.9.0-rc1-node < v1.15.4-node affected
v1.9.0-rc1-node-slim < v1.15.4-node-slim affected
v1.9.0-rc1-elixir-slim < v1.15.4-elixir-slim affected
v1.9.0-rc1-erlang-slim < v1.15.4-erlang-slim affected
v1.9.0-rc1-erlang-alpine < v1.15.4-erlang-alpine affected
v1.9.0-rc1-elixir-alpine < v1.15.4-elixir-alpine affected
v1.9.0-rc1-node-alpine < v1.15.4-node-alpine affected
v1.9.0-rc1-scratch < v1.15.4-scratch affected
every other version: unaffected
default status unaffected
cpe cpe:2.3:a:gleam-lang:gleam:*:*:*:*:*:*:*:*
modules · source files · routines
modules compiler-core
source files compiler-core/src/config.rs · compiler-core/src/manifest.rs
routines compiler_core::config::dependencies_map::deserialize · compiler_core::config::package_name::deserialize

Workarounds

  • Avoid using untrusted git dependencies, especially without pinning to a specific commit SHA
  • Review dependency trees carefully, including transitive git dependencies
  • Run dependency resolution commands in a restricted or isolated environment (e.g. containers)

Configurations

The project must use git-based dependencies (direct or transitive), or the victim must run gleam deps download on a repository with a malicious manifest.toml lockfile. Projects that exclusively use Hex dependencies and do not clone untrusted repositories are not affected.

Projects that exclusively use trusted or personally controlled git dependencies, or dependencies pinned to verified commit SHAs, are not exposed.

Solutions

Upgrade to Gleam 1.15.4 or later.

Both patches must be applied: the original incomplete fix (1aa5d8e594b0aa240bb213fce6ee19c65e6d5bcf, backported as 55bb36e6d7febfbbc48c4d001e0ae13eb0312d78 to 1.15) and the follow-up fix (2dc0467f822c75de94697a912755d172928ee40a, backported as 92aae3913570e8d8962f6399404777d313045bfa to 1.15). Gleam 1.15.4 includes both.

References

Credits

John Downey Remediation developer
Louis Pilfold Analyst
Jonatan Männchen / EEF Analyst

CVSS breakdown

CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:N/VI:H/VA:N/SC:H/SI:H/SA:H
« All CVEs