/

CVE-2026-23939

Severity:

HIGH RISK

(7.5)

Path Traversal in Elixir.Hexpm.Store.Local Local Storage

CVE-2026-23939

Modified

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Read/Write/Delete on Server Filesystem

Severity:

HIGH RISK

(7.5)

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

A path traversal flaw in the Elixir Hexpm.Store.Local module allows crafted relative paths to escape the intended storage directory when accessing or modifying files.

In self-hosted HexPM deployments using the Local Storage backend, an attacker who can influence object keys or storage paths may read, overwrite, or delete files outside the configured storage root.

Affected context

The vulnerability occurs in self-hosted HexPM instances that use the Local Storage backend implemented by Elixir.Hexpm.Store.Local.

The affected routines (get/3, put/4, delete/2, delete_many/2) operate on filesystem paths derived from user-controlled or externally influenced identifiers.

When these identifiers are not normalized or safely joined against a fixed root, directory traversal sequences (such as ../) can allow operations to break out of the intended storage directory.

The hosted hex.pm service itself is not impacted; only deployments that explicitly configure and run the vulnerable local storage module are exposed.

Exploit preconditions

  • Attack surface: Application interfaces that ultimately call Elixir.Hexpm.Store.Local.get/3, put/4, delete/2, or delete_many/2 with path-like inputs (e.g., package names, versions, or file keys).
  • Required access: Ability to create, upload, request, or delete stored objects such that the attacker controls or significantly influences the key or path segments.
  • Trigger point: Any file operation where the backend converts the supplied key into a filesystem path without robust normalization and enforcement of a fixed base directory.
  • Why exploitation is possible: The code constructs filesystem paths directly from attacker-influenced values without sufficiently constraining them to remain within the configured storage root, enabling relative path traversal sequences to reach unintended directories.

Why this happens

This issue stems from improper validation and normalization of file paths derived from untrusted input in the Elixir.Hexpm.Store.Local module.

The backend treats user-influenced keys as trusted path segments and concatenates them with a base directory, but does not consistently canonicalize the resulting path or verify that it stays within the intended storage root.

As described by CWE-22: Improper Limitation of a Pathname to a Restricted Directory, the application fails to restrict paths to a controlled directory, allowing traversal via relative components (e.g., ..) or similar constructs.

Abstractly, this pattern appears whenever storage or caching layers map logical keys to filesystem paths without using safe path-joining mechanisms and without a final check that the resolved absolute path is still under an allowed directory.

Potential impact

  • Read access to arbitrary files that the HexPM process user can access on the underlying server.
  • Overwriting or corrupting files outside the intended storage directory, potentially impacting application configuration or data integrity.
  • Deletion of files outside the storage root, which could lead to denial of service or data loss.
  • Indirect escalation of impact if sensitive credentials, API keys, or configuration files are exposed through unauthorized reads.

General mitigation guidance

Effective mitigation focuses on strictly confining all filesystem operations to a well-defined storage root and treating all path components as untrusted:

  • Use robust, platform-aware path-joining helpers that construct paths from a fixed base directory and user-supplied segments without string concatenation.
  • Normalize and canonicalize paths (e.g., resolving . and ..) and enforce a post-check that the resolved absolute path is a descendant of the configured storage root before performing any file operation.
  • Reject or sanitize any key or path segment containing directory traversal markers, path separators, or other unexpected characters according to a strict allowlist.
  • Run the HexPM process with the least privileges necessary, ensuring the service account only has access to directories intended for storage.
  • Consider isolating local storage into a dedicated directory or filesystem partition with minimal access to the rest of the system.

How teams detect issues like this

Detection typically combines code-level review with behavioral monitoring:

  • Use static analysis or code review to identify any file operations where user-controlled values are concatenated into paths without normalization and explicit base-directory checks.
  • Look for patterns such as direct string concatenation when building paths and absence of checks to ensure the resolved path remains within a configured root directory.
  • Implement security-focused tests or fuzzing that attempt to access files via ../ sequences or similar traversal patterns through the application's public interfaces.
  • Monitor server logs and application telemetry for suspicious access patterns, such as requests targeting unexpected directories or repeated attempts to reach sensitive files (e.g., configuration or system files).

Sources

SourceLink
cna.erlef.orgcna.erlef.org/cves/CVE-2026-23939.html
github.comgithub.com/hexpm/hexpm/commit/5d2ccd2f14f45a63225a73fb5b1c937baf36fdc0
github.comgithub.com/hexpm/hexpm/security/advisories/GHSA-42mv-r64p-4869
osv.devosv.dev/vulnerability/EEF-CVE-2026-23939

Frequently asked

questions

It can be, depending on how the self-hosted HexPM instance exposes operations backed by Elixir.Hexpm.Store.Local. If remote users can control keys or identifiers that map to local storage paths, the path traversal may be triggered over the network.

An attacker must be able to create, read, or delete stored objects through application functions that eventually call the local storage module with attacker-controlled or influenced path segments. No direct shell or filesystem access is required if the application exposes these operations over HTTP or another protocol.

Constrain all file operations to a predefined storage root by using safe path-joining routines, normalizing paths, and verifying that the final resolved path remains under the storage root before use. Additionally, reject or sanitize any path components that contain traversal tokens or path separators.

Treat all path components derived from user or external input as untrusted, enforce strict validation and allowlists for file names and keys, centralize filesystem access through well-reviewed utility functions, and include automated checks in code review and testing to flag any direct string-based path assembly.

Find out what's already
exploitable in your codebase.