Am I affected?

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

≥ v0.18.0-rc1-elixir < v1.17.0-elixir affected
≥ v0.18.0-rc1-erlang < v1.17.0-erlang affected
≥ v0.18.0-rc1-node < v1.17.0-node affected
≥ v0.18.0-rc1-node-slim < v1.17.0-node-slim affected
≥ v0.18.0-rc1-elixir-slim < v1.17.0-elixir-slim affected
≥ v0.18.0-rc1-erlang-slim < v1.17.0-erlang-slim affected
≥ v0.18.0-rc1-erlang-alpine < v1.17.0-erlang-alpine affected
≥ v0.18.0-rc1-elixir-alpine < v1.17.0-elixir-alpine affected
≥ v0.18.0-rc1-node-alpine < v1.17.0-node-alpine affected
≥ v0.18.0-rc1-scratch < v1.17.0-scratch affected
every other version: unaffected

Description

Path traversal vulnerability in Gleam's dependency management allows arbitrary directory deletion via malicious build/packages/packages.toml content.

Package keys read from build/packages/packages.toml by LocalPackages::read_from_disc are passed without validation to paths.build_packages_package(), which constructs a filesystem path by joining the project build directory with the attacker-controlled key. The resulting path is then passed to fs::delete_directory (which calls remove_dir_all). No check is performed to ensure the path remains within the intended build/packages/ directory. Both absolute paths and relative traversal sequences (e.g. ../) are accepted as package keys, allowing deletion of arbitrary directories.

An attacker who can cause a victim to run gleam deps download on a project containing a malicious build/packages/packages.toml (e.g. by committing the normally-gitignored file to a repository) can cause arbitrary directories on the victim's system to be recursively deleted.

This issue affects gleam: from 0.18.0-rc1 before 1.17.0.

Weaknesses & attack patterns

Weakness

CWE-22 · Improper Limitation of a Pathname to a Restricted Directory in catalog → MITRE ↗

Attack patterns

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

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

≥ v0.18.0-rc1-elixir < v1.17.0-elixir affected
≥ v0.18.0-rc1-erlang < v1.17.0-erlang affected
≥ v0.18.0-rc1-node < v1.17.0-node affected
≥ v0.18.0-rc1-node-slim < v1.17.0-node-slim affected
≥ v0.18.0-rc1-elixir-slim < v1.17.0-elixir-slim affected
≥ v0.18.0-rc1-erlang-slim < v1.17.0-erlang-slim affected
≥ v0.18.0-rc1-erlang-alpine < v1.17.0-erlang-alpine affected
≥ v0.18.0-rc1-elixir-alpine < v1.17.0-elixir-alpine affected
≥ v0.18.0-rc1-node-alpine < v1.17.0-node-alpine affected
≥ v0.18.0-rc1-scratch < v1.17.0-scratch affected
every other version: unaffected
cpe cpe:2.3:a:gleam-lang:gleam:*:*:*:*:*:*:*:*
version type other
modules · source files · routines
modules compiler-cli
source files compiler-cli/src/dependencies.rs
routines compiler_cli::dependencies::remove_extra_packages · compiler_cli::dependencies::LocalPackages::read_from_disc · compiler_cli::dependencies::LocalPackages::extra_local_packages

Affected — Gleam

≥ 0.18.0-rc1 < 1.17.0 affected
every other version: unaffected
cpe cpe:2.3:a:gleam-lang:gleam:*:*:*:*:*:*:*:*
version type semver
modules · source files · routines
modules compiler-cli
source files compiler-cli/src/dependencies.rs
routines compiler_cli::dependencies::remove_extra_packages · compiler_cli::dependencies::LocalPackages::read_from_disc · compiler_cli::dependencies::LocalPackages::extra_local_packages

Affected — GitHub / gleam-lang/gleam Repository ↗

≥ ed7aec0 < 690ca06 affected
every other version: unaffected
cpe cpe:2.3:a:gleam-lang:gleam:*:*:*:*:*:*:*:*
version type git
modules · source files · routines
modules compiler-cli
source files compiler-cli/src/dependencies.rs
routines compiler_cli::dependencies::remove_extra_packages · compiler_cli::dependencies::LocalPackages::read_from_disc · compiler_cli::dependencies::LocalPackages::extra_local_packages

References

Credits

Abdelrahman Ahmed Aboelkasem (0x2face) Finder
Aly (spect3r1) Finder
Jonatan Männchen / EEF Analyst
Louis Pilfold Remediation developer

CVSS breakdown

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

Exploitability

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

Vulnerable System

Confidentiality
None
Integrity
None
Availability
High

Subsequent Systems

Confidentiality
None
Integrity
None
Availability
None
« All CVEs