/

CVE-2026-44705

Severity:

HIGH RISK

(8.2)

Path Traversal (CWE-22) in Node.js tmp Temp Creator

CVE-2026-44705

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Creation Outside Intended Directory

Severity:

HIGH RISK

(8.2)

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

The Node.js tmp package contained a path traversal flaw that allowed attackers to influence where temporary files and directories are created.

When untrusted data is passed into prefix, postfix, or dir options, tmp could create files outside the intended temporary directory with the application's privileges.

Affected context

This vulnerability arises in Node.js applications that use the tmp package for temporary file or directory creation and pass user-controlled data directly into the prefix, postfix, or dir options.

It is most relevant in contexts where:

  • The application dynamically customizes temp paths or names based on request data, query parameters, or other untrusted input
  • The runtime user account has write permissions to directories outside the designated temp base
  • There is an assumption that tmp will always confine file creation to a safe temporary directory

In such cases, malicious path components in these options can bypass the intended temp directory boundary.

Exploit preconditions

  • Attack surface: Application code that calls tmp's file/directory creation functions and exposes their prefix, postfix, or dir parameters to external input (e.g., HTTP requests, job metadata, user configuration).
  • Required access: Ability to supply or influence values used for tmp options, such as attacker-controlled request fields, environment variables, or config entries.
  • Trigger point: Invocation of tmp's APIs (like tmp.file() or tmp.dir()) with unvalidated path-related options containing traversal sequences (../) or path separators.
  • Why exploitation is possible: The vulnerable versions did not normalize or restrict option-derived paths against the configured temporary base directory, allowing directory traversal and file creation at attacker-chosen locations within the process' writable filesystem scope.

Why this happens

The root cause is insufficient validation and normalization of path parameters passed to tmp's temporary file and directory creation routines.

Instead of enforcing that all created paths remain confined to a designated temporary base directory, the implementation allowed raw option values (prefix, postfix, dir) to influence the final filesystem path.

When these values contain traversal sequences or injected path separators, the resulting path can escape the intended directory, which maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').

Conceptually, the bug is a failure to treat path fragments derived from untrusted input as tainted and to canonicalize and validate them against a fixed, trusted root.

Potential impact

  • Attackers may cause files or directories to be created outside the trusted temporary directory hierarchy.
  • Attackers could plant files in application-controlled paths, potentially influencing configuration loading or later file-based logic.
  • Attackers can overwrite or collide with existing files if the process has write access and the application does not guard against overwrites.
  • Attackers may create files in more sensitive locations (e.g., log directories, upload areas, or other app-managed folders), enabling indirect privilege escalation or persistence depending on how those files are later used.

General mitigation guidance

Effective mitigation focuses on restricting how path-related options are derived and enforcing strict directory boundaries:

  • Treat all prefix, postfix, and dir values influenced by external sources as untrusted and subject to strong validation.
  • Normalize and validate paths against a fixed, trusted base directory before passing them to temporary file utilities, rejecting any input that attempts to escape that base.
  • Prefer using library defaults for temporary directories instead of dynamically constructing paths from user data wherever possible.
  • Implement allowlists for acceptable path fragments (e.g., limited character sets and no path separators) when customization is necessary.
  • Run the application with least-privilege filesystem permissions so that even if temp handling fails, writable areas are tightly constrained.

How teams detect issues like this

Detection generally combines code-level inspection with automated analysis:

  • Perform static code review to identify all call sites of tmp's file/directory creation APIs, focusing on where prefix, postfix, or dir are derived from request parameters, headers, form fields, or other untrusted sources.
  • Use static analysis tools or custom linters to flag direct propagation of user-controlled data into filesystem path construction without canonicalization or validation.
  • Implement secure coding guidelines and CI checks that prohibit passing raw user input into path-related parameters for temp files.
  • During dynamic testing, include test cases that inject traversal sequences and path separators into any inputs that can reach tmp configuration, and monitor whether files appear outside the expected temporary directory.

Sources

SourceLink
github.comgithub.com/raszi/node-tmp/security/advisories/GHSA-ph9p-34f9-6g65

Frequently asked

questions

Yes, it can be remotely exploitable when external users can influence values passed into tmp's prefix, postfix, or dir options via network-facing interfaces such as web APIs or other remote inputs.

An attacker needs the ability to control or significantly influence the data that is ultimately used to configure tmp's path-related options.

No direct filesystem access is required beyond what the vulnerable process already has.

The safest pattern is to avoid using user input directly in tmp's path options, instead relying on trusted defaults or carefully validated, canonicalized values that are guaranteed to stay within a known base directory.

Prevent them by treating all path components derived from external input as tainted, applying strict validation and canonicalization, enforcing directory confinement checks, and integrating automated checks or code review practices that flag unsafe path construction patterns.

Find out what's already
exploitable in your codebase.