Repository navigation
Conversation
openAsBlob() and openAsBlobSync() stored the caller path and reopened it on every read. A relative path was resolved against the cwd again, so process.chdir() could read a different file of the same size and mtime, or fail the read. Pin the directory the path was opened against when the blob is created, without lexically collapsing ".." so symlink traversal stays the same. Signed-off-by: Ihar Ivaniuk <ihar.o.ivaniuk@gmail.com>
Contributor
|
Welcome to Node.js, and thank you for your first contribution! Before review, please take a moment to read:
Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal. |
jazelly
reviewed
Nov 9, 2026
| return buf; | ||
| } | ||
|
|
||
| #ifdef _WIN32 |
Member
There was a problem hiding this comment.
On Windows, could we just store the path already resolved by ToNamespacedPath() instead of adding all this?
| const { pathToFileURL } = require('node:url'); | ||
|
|
||
| if (process.argv[2] !== 'child') { | ||
| const child = spawnSync(process.execPath, [__filename, 'child'], { |
Member
There was a problem hiding this comment.
Is this to avoid the worker thread from the test harness? You can skip instead. It's not necessary to test this under worker mode.
if (!common.isMainThread)
common.skip('process.chdir is not available in Workers');| assert.strictEqual(child.status, 0, output); | ||
| } else { | ||
| (async () => { | ||
| const root = fs.mkdtempSync(path.join(os.tmpdir(), 'openasblob-chdir-')); |
Member
There was a problem hiding this comment.
The convention is to use common/tmpdir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
openAsBlob() and openAsBlobSync() stored the caller path and reopened it on every read. A relative path was resolved against the cwd again, so process.chdir() could read a different file of the same size and mtime, or fail the read. Pin the directory the path was opened against when the blob is created, without lexically collapsing ".." so symlink traversal stays the same.
Verified on Linux x64 by building this tree. The new test failed on the
unfixed binary (
'from-b' !== 'from-a') and passed after the rebuild.Also passed:
test-blob-file-backed,test-fs-openAsBlobSync,test-vfs-fs-openAsBlob,test-blob-file-webidl,test-permission-fs-read, andtest-permission-fs-supported.cpplint, the include check, clang-format, and ESLint were clean.
Windows and macOS were not run.
A coding agent prepared the change. The build and the test results above
were run locally.
Fixes: #67282