Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-103061 Overview
CVE-2026-103061 is a path traversal vulnerability [CWE-22] in the Gleam programming language toolchain. The flaw allows a malicious Hex package publisher to delete directories outside a project's build directory when a developer compiles the project. Gleam reads the app field from a Hex package release's metadata and uses it as a build directory name without validating it. When a dependency fails to compile, Gleam invokes remove_dir_all against the attacker-controlled path. The issue affects gleam from version 0.32.4 before 1.19.2 and is tracked under GitHub Security Advisory GHSA-jhcr-c7qm-8589.
Critical Impact
A malicious or compromised Hex package can trigger deletion of arbitrary directories on a developer's machine during routine commands such as gleam build, gleam check, gleam run, gleam test, or gleam export.
Affected Products
- gleam-lang gleam versions 0.32.4 through 1.19.1
- Projects depending directly on a malicious Hex release
- Projects depending transitively on a malicious Hex release
Discovery Timeline
- 2026-10-12 - hex.pm begins restricting the app metadata field to a valid directory name
- 2026-10-12 - CVE-2026-103061 published to NVD
- 2026-10-16 - Last updated in NVD database
Technical Details for CVE-2026-103061
Vulnerability Analysis
Gleam downloads dependencies from hex.pm and uses release metadata to determine where package build artifacts live on disk. The function hex_manifest_package in compiler-cli/src/dependencies.rs and ProjectPaths::build_directory_for_package consume the app field from the Hex API response. This field represents the release's OTP application name but was not constrained to a safe directory name by hex.pm before 2026-10-12. Attackers could publish a release with app set to ../../../../target or an absolute path. When Gleam attempts to compile that dependency and compilation fails, it calls remove_dir_all against the resolved path. This deletes whatever directory the traversal resolves to on the developer's filesystem.
Root Cause
The root cause is missing input validation on untrusted metadata received from a third-party registry. Gleam treated the app field as a trusted identifier and composed filesystem paths directly from it. No normalization, allowlist, or boundary check prevented .. segments or absolute paths from reaching build_directory_for_package.
Attack Vector
Exploitation requires a developer to add or transitively consume a malicious Hex package and run any build-related Gleam command. A pure Gleam package does not execute publisher code, so the deletion occurs through the compiler's own filesystem operations after a deliberately failed compile. The attack scope is limited to the privileges of the developer running the Gleam CLI.
// Security patch in compiler-cli/src/dependencies.rs
// Resolve the application name from the trusted local manifest
// rather than the raw package metadata.
let name = manifest
.packages
.iter()
.find(|p| p.name == package_name)
.map(|p| p.application_name().as_str())
.unwrap_or(package_name.as_str());
let path = paths.build_directory_for_package(mode, target, name);
if path.exists() {
tracing::debug!(package=%package_name, version=%version, "deleting_build_cache");
}
Source: GitHub Commit d13f27e
Detection Methods for CVE-2026-103061
Indicators of Compromise
- Hex release metadata where the app field contains .., path separators, or an absolute path
- Unexpected deletion of directories outside the project's build/ tree following a gleam build or gleam check invocation
- Gleam compiler log entries containing deleting_build_cache referencing paths outside the workspace
- Dependency manifests pinning Hex packages whose published app name differs from the package name
Detection Strategies
- Audit manifest.toml and gleam.toml lockfiles for packages whose app field diverges from the declared package name
- Scan CI build logs for Gleam compile failures immediately followed by directory removal events
- Compare pre- and post-build filesystem snapshots in CI runners to flag deletions outside the project root
- Monitor endpoint telemetry for gleam processes invoking unlinkat or rmdir syscalls on paths above the project directory
Monitoring Recommendations
- Alert on gleam child processes performing recursive directory removal outside developer workspaces
- Log and review all Hex dependency additions during pull request review
- Track the installed Gleam toolchain version across developer workstations and CI fleets to confirm patch coverage
How to Mitigate CVE-2026-103061
Immediate Actions Required
- Upgrade Gleam to version 1.19.2 or later on every developer workstation and CI runner
- Review existing manifest.toml files for Hex dependencies with suspicious app metadata before the next build
- Avoid running gleam build, gleam check, gleam run, gleam test, or gleam export on untrusted projects with the vulnerable toolchain
Patch Information
The fix landed in Gleam 1.19.2. Relevant commits include 54bbb2b, d13f27e, and d15c981. The patches validate the app application name in hexpm/src/lib.rs and reconcile package name versus application name resolution in compiler-cli/src/dependencies.rs. hex.pm also now rejects app values that are not valid directory names at publish time. See the CNA record and OSV entry for additional context.
Workarounds
- Pin dependencies to versions published before 2026-10-12 only after manually inspecting their Hex app metadata
- Execute Gleam builds inside ephemeral containers or sandboxes so any deletion is contained to disposable storage
- Restrict developer and CI accounts so the Gleam process cannot remove directories outside the project root
# Upgrade Gleam to the patched release
gleam --version
# If below 1.19.2, upgrade through your package manager, for example:
brew upgrade gleam
# or via asdf
asdf install gleam 1.19.2 && asdf global gleam 1.19.2
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

