/

CVE-2026-32146

Severity:

HIGH RISK

(7.8)

Path Traversal / Directory Traversal in Gleam Compiler

CVE-2026-32146

Modified

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File System Modification (with possible Code Execution)

Severity:

HIGH RISK

(7.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

An improper path validation issue in the Gleam compiler's git dependency handling allows dependency names from configuration files to influence filesystem paths outside the intended dependency directory.

A malicious direct or transitive git dependency can craft names that traverse directories or use absolute paths, enabling deletion and overwriting of arbitrary paths during dependency download and resolution, which can cause data loss and, in some environments, lead to code execution.

Affected context

This vulnerability appears when Gleam projects use git-based dependencies whose names are derived from gleam.toml and manifest.toml.

During gleam deps download and similar dependency resolution stages, the compiler computes filesystem paths for these dependencies without sufficiently constraining them to the dedicated dependency directory.

Installations where build tooling runs with access to sensitive directories (such as user home directories, shared workspaces, or CI build agents) are particularly exposed, as crafted dependency names can affect files and directories outside the normal dependency tree.

Exploit preconditions

  • Attack surface: The Gleam dependency resolution and download phase, typically executed via commands like gleam deps download.
  • Required access: Ability to introduce or influence a git dependency entry in gleam.toml or manifest.toml, either as a direct dependency in the project or as a transitive dependency in a referenced repository.
  • Trigger point: Running Gleam tooling that resolves and downloads git dependencies, which computes and uses the derived paths for filesystem operations such as directory deletion and creation.
  • Why exploitation is possible: Dependency names are incorporated into filesystem paths without robust normalization, confinement, or rejection of traversal sequences (e.g. ../) and absolute paths, allowing attacker-controlled values to escape the intended dependency directory.

Why this happens

The core issue is insufficient validation and confinement of filesystem paths constructed from partially untrusted configuration data.

In this case, dependency names from gleam.toml and manifest.toml are treated as safe components for building local directories used during git dependency resolution.

Without rigorous normalization, rejection of traversal and absolute paths, or enforcement that the resulting path remains within a designated root, these derived paths can point outside the expected dependency tree.

This aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where user-controlled or configuration-controlled path elements are allowed to escape a presumed sandbox and affect arbitrary locations on the filesystem.

Potential impact

  • Deletion of arbitrary directories and their contents outside the intended dependency directory.
  • Overwriting of arbitrary directories or files reachable by the Gleam process.
  • Disruption of build environments and potential corruption of project repositories.
  • In some environments, execution of attacker-controlled code by overwriting:
  • Git hooks in repositories
  • Shell startup or profile configuration files
  • Other scripts that are later executed by users or automation.
  • Persistence of malicious changes across builds or developer sessions.

General mitigation guidance

Effective mitigation focuses on constraining how filesystem paths are derived and ensuring that dependency-related operations cannot escape a dedicated directory.

Common defensive patterns include:

  • Strictly normalizing and validating all paths derived from configuration, rejecting any input that resolves outside the intended dependency root.
  • Disallowing path elements that include traversal sequences (..), leading separators, or constructs that create absolute paths, rather than attempting to silently sanitize them.
  • Constructing dependency paths using safe path-joining utilities and post-join checks that enforce containment within a known base directory.
  • Treating dependency metadata (names, URLs, identifiers) as untrusted and subjecting them to the same trust-reduction and validation rules as external input.
  • Running build and dependency tooling under least-privilege accounts with restricted write access, so even if path handling fails, the process cannot modify sensitive system locations.

Applying these patterns helps ensure that dependency resolution is effectively sandboxed to a controlled directory structure.

How teams detect issues like this

Organizations can identify and monitor for this class of issue using multiple complementary strategies:

  • Static analysis and code scanning:
  • Rules that flag manual string concatenation for filesystem paths involving configuration or dependency metadata.
  • Checks that detect filesystem operations (such as delete, create, move) using paths that are not validated or normalized against a fixed base directory.
  • Code review practices:
  • Reviewing dependency management and build tooling code for assumptions that configuration-derived identifiers are inherently safe.
  • Verifying that any path derived from configuration is subject to a "stay within this root" policy with explicit failure on violation.
  • Policy enforcement:
  • CI pipeline checks that prevent merging changes introducing unsafe path handling in build or dependency-related modules.
  • Optional use of security-focused linters or SAST tools configured with rules specific to path traversal in build tools.
  • Runtime/operational monitoring:
  • In sensitive environments, using file integrity monitoring or audit logs to observe unexpected directory deletions or modifications during dependency resolution phases.

Sources

SourceLink
cna.erlef.orgcna.erlef.org/cves/CVE-2026-32146.html
github.comgithub.com/gleam-lang/gleam/commit/1aa5d8e594b0aa240bb213fce6ee19c65e6d5bcf
github.comgithub.com/gleam-lang/gleam/commit/2dc0467f822c75de94697a912755d172928ee40a
github.comgithub.com/gleam-lang/gleam/security/advisories/GHSA-vq5j-55vx-wq8j
osv.devosv.dev/vulnerability/EEF-CVE-2026-32146
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-32146
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2457578
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-32146.json

Frequently asked

questions

It can be, depending on how dependencies are managed. If an attacker can publish or modify a git repository that your project depends on—directly or transitively—and you then run Gleam's dependency resolution, the vulnerability can be triggered without local shell access. In more controlled environments where all dependencies are internal and tightly curated, the practical exploitability is reduced.

The attacker needs the ability to influence which git dependencies are resolved and what names or metadata they provide. This often means control over a dependency repository that is referenced in gleam.toml or appears transitively through another dependency. No additional privileges on the local machine are required beyond what the Gleam process itself already has.

The safest pattern is to ensure all dependency paths are derived through a strict, centralized path-handling routine that:

  • Joins inputs to a predefined base directory using safe utilities,
  • Normalizes the resulting path, and
  • Verifies that the final path remains within the allowed root, failing fast if not.

Additionally, treat all configuration or dependency metadata as untrusted input that must never directly control absolute paths or traversal.

Adopt secure coding standards for filesystem access that require:

  • Path normalization and containment checks whenever user or configuration data contributes to a path.
  • Security review of build tools and dependency managers, which frequently manipulate the filesystem.
  • Automated checks in CI for known-dangerous patterns, such as direct string concatenation into paths used for deletion or creation.

Combining these with least-privilege execution for build tooling significantly reduces the risk of similar path traversal issues.

Find out what's already
exploitable in your codebase.