(CVE-2023-32003) fs.mkdtemp() and fs.mkdtempSync() are missing getValidatedPath() checks
The fs.mkdtemp() and fs.mkdtempSync() functions in Node.js did not run the same path validation as other file system calls, so a path traversal could slip past the experimental permission model. An attacker able to run code under that model could then create a directory outside the permitted area.
- Triaged in 44 hours
- Fixed in 29 days
- Paid in 29 days
- Disclosed after 59 days
Summary by the program
###fs.mkdtemp() and fs.mkdtempSync() are missing getValidatedPath() checks (LOW)(CVE-2023-32003)
fs.mkdtemp() and fs.mkdtempSync() can be used to bypass the permission model check using a path traversal attack. This flaw arises from a missing check in the fs.mkdtemp() API and the impact is a malicious actor could create an arbitrary directory.
Please note that at the time this CVE was issued, the permission model is an experimental feature of Node.js.
Impacts:
This vulnerability affects all users using the experimental permission model in Node.js 20.
The report
https://hackerone.com/reports/2037887
Patch was provided.
Impact
See reports
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the two mkdtemp functions were not routed through the shared getValidatedPath() helper, so the permission model's path check never ran on their arguments.
Impact
A malicious actor could create an arbitrary directory, but only where the experimental permission model is in use in Node.js 20.
What the attacker needed
Experimental permission model enabled; Node.js 20; ability to run code in the process
The fix
The functions should be changed to run the same getValidatedPath() validation as other file system calls; the text says a patch was provided.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Node.js has an optional, still experimental 'permission model' that is meant to stop a program from touching files outside allowed folders. Two functions that create temporary directories skipped the check that other file functions use, so a crafted path could escape the allowed folder. The result is that a program running under those restrictions could still create a directory where it should not.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.