CVE-2026-49982: tmp Node.js Path Traversal — Remote File Creation Vulnerability
The tmp Node.js library, versions up to 0.2.6, contains a path traversal vulnerability that allows attackers to create files or directories outside the intended temporary directory. The vulnerability exists because the library's path validation only checks string inputs for the '..' substring, but fails to properly validate non-string inputs like Arrays, Buffers, and objects. When these objects are converted to strings during file creation, they can contain path traversal sequences that bypass the check. An attacker can exploit this by sending malicious data through application parameters (such as JSON fields or query strings) that get passed to tmp functions, potentially creating files or directories anywhere on the system with the privileges of the running process.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 8.2 HIGH · CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L
- Weaknesses (CWE)
- CWE-20, CWE-22
- Affected products
- 1 configuration(s)
- Published / Modified
- 2026-06-11 / 2026-06-17
NVD description (verbatim)
tmp is a temporary file and directory creator for node.js. In version 0.2.6, the _assertPath guard added to tmp rejects only string values that contain the substring ... It is bypassed when prefix, postfix, or template is supplied as a non-string value (Array, Buffer, or any object) whose includes('..') returns falsy but whose stringification still contains ../. The value flows through Array.prototype.join/String coercion inside _generateTmpName and path.join(tmpDir, opts.dir, name), producing a final path that escapes tmpdir and creates a file or directory at an attacker-controlled location with the host process's privileges. This affects any application that forwards untrusted request data (a common pattern is JSON body fields or qs-parsed bracket-array query strings such as ?prefix[]=...) into tmp.file, tmp.fileSync, tmp.dir, tmp.dirSync, tmp.tmpName, or tmp.tmpNameSync without explicit type coercion. This vulnerability is fixed in 0.2.7.
2 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
CVE-2026-49982 exploits a type-confusion vulnerability in tmp's _assertPath validation function. The guard specifically rejects string values containing '..' but does not apply the same validation to Array, Buffer, or generic object types. During path generation in _generateTmpName, these non-string objects undergo implicit String coercion via Array.prototype.join and String conversion, which can produce output containing '../' sequences that the initial guard never inspected. These malformed paths then flow into path.join(tmpDir, opts.dir, name), where the path traversal sequences are normalized and resolved relative to the file system, enabling arbitrary file or directory creation. The vulnerability manifests when applications directly pass untrusted input (such as deserialized JSON objects or parsed query parameters) into tmp.file, tmp.fileSync, tmp.dir, tmp.dirSync, tmp.tmpName, or tmp.tmpNameSync without type-checking.
Business impact
For organizations using Node.js applications built on the tmp library, this vulnerability creates a critical integrity and availability risk. Attackers can write arbitrary files to the server, potentially overwriting application code, configuration files, or system binaries—leading to remote code execution or application compromise. Alternatively, attackers could exhaust disk space or corrupt essential system files, causing denial of service. The attack surface is broad: any web application that deserializes user input and passes it to tmp functions without validation is affected. This is especially concerning for APIs that accept JSON payloads or query strings with array-like structures.
Affected systems
The tmp package version 0.2.6 and earlier are affected. Any Node.js application using these versions is vulnerable if it forwards untrusted input (from HTTP requests, external APIs, or file uploads) into tmp functions without explicit type coercion or validation. The risk is highest for web servers and backend services that process JSON bodies or query parameters with minimal input sanitization. Applications using tmp only for internal, controlled purposes (e.g., hardcoded paths) are not at risk.
Exploitability
This vulnerability is relatively straightforward to exploit. An attacker needs only to craft a malicious request containing a non-string value in a field that the application passes to a tmp function. For example, sending ?prefix[]=../../../etc/passwd or a JSON body with {"prefix": ["../../../"]} can trigger the vulnerability. No authentication or special privileges are required, and exploitation does not depend on race conditions or user interaction. The attack is reliable and repeatable, making it a practical threat in the wild.
Remediation
Update the tmp package to version 0.2.7 or later immediately. This version includes a corrected validation function that properly handles non-string inputs. Additionally, apply defense-in-depth measures: ensure all application code that accepts external input performs explicit type checking before passing values to tmp functions, and consider restricting file creation to specific, read-only temporary directories using OS-level permissions or containerization.
Patch guidance
Verify your Node.js project's package.json and package-lock.json to confirm the tmp package version. If any version 0.2.6 or earlier is in use, run npm update tmp or npm install [email protected] (or the latest available version). Re-run your test suite to ensure compatibility. If your application is subject to strict change management, prioritize this update as a high-priority security patch. No breaking changes are expected when upgrading from 0.2.6 to 0.2.7; however, verify against the vendor advisory for any edge cases in your specific usage patterns.
Detection guidance
Monitor for suspicious file or directory creation attempts in temporary directories and their parent paths. Log all tmp function calls with their input parameters; anomalies such as Array or Buffer objects (or objects with unusual toString() representations) being passed as options should trigger alerts. On running systems, audit the file system for unexpected files outside of designated temp directories that were created around the time of suspicious requests. In application logs, look for error messages from path.join() or file system operations that contain '../' or similar traversal patterns in unexpected contexts.
Why prioritize this
This vulnerability scores 8.2 (HIGH) due to its network accessibility, lack of authentication requirement, and significant impact on integrity and availability. The ease of exploitation and broad applicability across Node.js web applications make it a strong candidate for immediate patching. Organizations running production services that accept external input should treat this as critical.
Risk score, explained
The CVSS 3.1 score of 8.2 reflects: (1) network vector (AV:N) — no local access required; (2) low attack complexity (AC:L) — no special conditions or race windows needed; (3) no privileges or user interaction required (PR:N, UI:N); (4) high integrity impact (I:H) — arbitrary file creation/modification; (5) low availability impact (A:L) — potential for denial of service through disk exhaustion or file corruption. The vulnerability does not disclose confidentiality (C:N), hence the score does not reach critical severity, but the integrity and availability consequences are substantial.
Frequently asked questions
Can this vulnerability be exploited remotely without authentication?
Yes. The vulnerability requires only that an attacker can send a request to an affected application — typically via HTTP — with malicious input in JSON bodies, query strings, or other parameters. No authentication or special privileges are required on the attacker's side.
How can I quickly identify if my application is vulnerable?
Search your source code for calls to tmp.file, tmp.fileSync, tmp.dir, tmp.dirSync, tmp.tmpName, or tmp.tmpNameSync. If any of these functions receive input from untrusted sources (request bodies, query parameters, file contents, etc.) without explicit type coercion (e.g., String(input) or input.toString() followed by validation), your application is likely vulnerable. Also check your package-lock.json for tmp version 0.2.6 or earlier.
Are there temporary workarounds if I cannot patch immediately?
Implement strict input validation at the application level: coerce all user input to strings before passing to tmp functions, whitelist allowed characters in prefix/postfix/template fields, and reject any input that contains '..' or '/'. This is not a permanent fix but can reduce risk while you plan and execute the upgrade to tmp 0.2.7.
Does updating tmp to 0.2.7 require code changes in my application?
No. The patch is a drop-in replacement. However, verify your specific usage patterns against the vendor advisory to ensure no edge cases affect your application. Run your test suite after the update to confirm compatibility.
This analysis is provided for informational and educational purposes. The information reflects the vulnerability as publicly disclosed and the source data provided. Organizations should conduct their own risk assessment and testing in controlled environments before implementing any remediation. Patch version availability and specific vendor advisory details should be verified directly with the maintainers of the tmp package. No exploit code or weaponized proof-of-concept is provided; this analysis is intended to support defensive security operations only. Source: NVD (public-domain), retrieved 2026-07-20. Analysis generated by SEC.co (claude-haiku-4-5).
Related vulnerabilities
- CVE-2026-45565HIGHRoxy-WI Path Traversal & Shell Injection in Input Validation
- CVE-2026-44705HIGHPath Traversal in raszi tmp npm Package (v<0.2.6)
- CVE-2016-20076HIGHWordPress Simple-Backup 2.7.11 Unauthenticated File Access & Deletion Vulnerability
- CVE-2016-20081HIGHHB Audio Gallery Lite Path Traversal Vulnerability – Unauthenticated File Download
- CVE-2017-20248HIGHApptha Slider Gallery Path Traversal Vulnerability
- CVE-2017-20250HIGHMac Photo Gallery 3.0 Path Traversal File Download Vulnerability
- CVE-2018-25408HIGHOpen ISES Project Path Traversal Vulnerability (High Severity)
- CVE-2024-40646HIGHVertex Path Traversal Vulnerability – Remote File Access Risk