Executive brief
The 'tmp' library, a popular Node.js package for creating temporary files and directories, contains a vulnerability that allows attackers to create files in unauthorized locations on a server. By providing specially crafted input (such as an array instead of a string) to the library's functions, an attacker can bypass security checks and write data outside of the intended temporary folder. This could lead to the corruption of sensitive system files, unauthorized data placement in web roots, or service disruptions.
Technical details
A type-confusion vulnerability exists in the `_assertPath` function of the `tmp` library. The function intended to block path traversal by checking for the `..` substring, but it assumes the input is always a string. When an attacker provides a non-string value (such as an Array or an Object with a custom `includes` method), the check can be bypassed. Subsequent string coercion during path construction (via `Array.prototype.join` or `path.join`) reintroduces the traversal sequence. This allows an attacker to escape the designated temporary directory and create files or directories anywhere the process has write permissions. The vulnerability is reachable over the network if an application passes untrusted request data (e.g., from JSON bodies or query strings) directly into `tmp` library functions like `tmp.file()` or `tmp.dir()`. A fix is available in version 0.2.7 which enforces string type checking.
Affected products
- raszi tmp >= 0.2.6, < 0.2.7
Timeline
- 2026-05-27: disclosed
- 2026-06-15: advisory