Skip to main content
Vulnerability Database/CVE-2026-96612

CVE-2026-96612: hexpm hex Path Traversal Vulnerability

CVE-2026-96612 is a path traversal flaw in hexpm hex that allows malicious package publishers to delete directories and extract files outside the project scope. This post explains its impact, affected versions, and mitigation steps.

Published:

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-96612 Overview

CVE-2026-96612 is a path traversal vulnerability [CWE-22] in hexpm hex, the package manager client used by Elixir and Erlang developers. A malicious package publisher can set a dependency's application label to a traversal string such as ../../target. When a developer runs mix deps.get or mix deps.update, Hex resolves the label into a filesystem path, deletes the target directory with File.rm_rf!/1, and extracts the package contents into it. The flaw affects hex versions from 0.6.0 before 2.5.2 and executes before any dependency code is compiled.

Critical Impact

Any direct or transitive dependency on a malicious Hex package can trigger destruction of arbitrary filesystem directories and arbitrary file writes on a developer or CI machine during dependency fetch.

Affected Products

  • hexpm/hex client versions 0.6.0 through 2.5.1
  • Elixir/Erlang projects using Mix for dependency resolution with vulnerable Hex
  • CI/CD pipelines that execute mix deps.get or mix deps.update against hex.pm

Discovery Timeline

  • 2026-10-12 - CVE-2026-96612 published to NVD
  • 2026-10-16 - Last updated in NVD database

Technical Details for CVE-2026-96612

Vulnerability Analysis

A package release's requirements list carries an app label that names the dependency's OTP application. Hex reads this label from the repository's signed registry and uses it as the dependency's application name without validating that it is a safe directory component. The flow passes through Hex.RemoteConverger.deps/2 and Hex.Mix.to_lock/1, where the untrusted label becomes authoritative.

Mix then derives the dependency's checkout path as deps/<app>. Hex.SCM.update/1 calls File.rm_rf!/1 on that path and unpacks the tarball into it. Because hex.pm only validates the label's length, a publisher can set it to a traversal string. The deletion and extraction occur during dependency fetch, before any dependency source is compiled or executed.

Root Cause

The root cause is missing validation of the app label returned by the registry. The Hex client trusted a publisher-controlled string as a directory name and applied destructive filesystem operations to the resolved path. Server-side length checks on hex.pm were insufficient to block path traversal sequences such as ../../target.

Attack Vector

An attacker publishes a Hex package whose release metadata declares a dependency with a crafted app label. The attack succeeds when any project includes the package directly or transitively and runs mix deps.get or mix deps.update. Hex deletes the directory the label resolves to relative to deps/ and writes the package's files there. User interaction is limited to triggering a routine dependency fetch.

text
# Patch excerpt — lib/hex/registry/server.ex
# Rejects dependency application names that cannot be directory names

  def dependencies(repo, package, version) do
    case GenServer.call(@name, {:dependencies, repo, package, version}, @timeout) do
      {:ok, deps} -> {:ok, Enum.map(deps, &solver_dependency(package, version, &1))}
      :error -> :error
    end
  end

  # Raises on a dependency with an invalid application name, for callers that
  # use the application names as lock keys, atoms or directories
  def app_dependencies(repo, package, version) do
    case GenServer.call(@name, {:dependencies, repo, package, version}, @timeout) do
      {:ok, deps} -> {:ok, Enum.map(deps, &app_dependency(package, version, &1))}
      :error -> :error
    end
  end

  defp solver_dependency(package, version, %{name: name, label: app} = dependency) do
    if valid_app_name?(app) do
      dependency
    else
      warn_invalid_app_name(package, version, name, app)

Source: GitHub Commit 1b3e2ae

Detection Methods for CVE-2026-96612

Indicators of Compromise

  • Unexpected deletion or replacement of directories outside the project tree following a mix deps.get or mix deps.update run.
  • Files appearing at traversal-derived paths such as ../target relative to deps/ after dependency resolution.
  • mix.lock entries where the application atom does not match the package name field.
  • Hex registry responses containing dependency app labels with .., /, or shell metacharacters.

Detection Strategies

  • Audit mix.lock files across repositories for application atoms that contain path separators or parent-directory references.
  • Instrument CI runners to compare the pre- and post-fetch filesystem state outside the project's deps/ directory.
  • Monitor Hex client versions reported by build agents and flag any runtime below 2.5.2.

Monitoring Recommendations

  • Alert on build-time file deletions outside the project workspace, particularly during Mix dependency phases.
  • Record and review the full dependency graph produced by mix deps.tree to surface unexpected transitive packages.
  • Capture Hex HTTP traffic in CI and inspect decoded registry entries for malformed app labels.

How to Mitigate CVE-2026-96612

Immediate Actions Required

  • Upgrade the Hex client to version 2.5.2 or later on all developer workstations and CI/CD runners.
  • Rebuild projects in isolated environments after upgrade to validate dependency integrity.
  • Review recent mix deps.get and mix deps.update runs on shared build systems for signs of exploitation.

Patch Information

The fix is tracked in the hexpm/hex Security Advisory GHSA-2vjj-c5hr-6xc3 and delivered through commits 1b3e2ae, 380f870, and 72279a8. The patches introduce app_dependencies/3, validate application names with valid_app_name?/1, and reject labels that cannot serve as directory names. Additional details are available in the CNA advisory and the OSV record EEF-CVE-2026-96612.

Workarounds

  • Run mix deps.get only inside sandboxed or containerized build environments with no write access outside the project directory.
  • Pin dependencies to known-good releases and avoid resolving transitive updates until the Hex client is patched.
  • Restrict CI service accounts to the project workspace so traversal writes cannot reach host-level paths.
bash
# Upgrade Hex to the patched release
mix local.hex 2.5.2 --force

# Verify the installed version
mix hex.info | grep -i "Hex:  "

# Re-fetch dependencies in a clean workspace
rm -rf deps/ _build/
mix deps.get

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

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.