permission: check symlink target in cpSync (incomplete CVE-2025-55130)#63208
Open
fg0x0 wants to merge 1 commit intonodejs:mainfrom
Open
permission: check symlink target in cpSync (incomplete CVE-2025-55130)#63208fg0x0 wants to merge 1 commit intonodejs:mainfrom
fg0x0 wants to merge 1 commit intonodejs:mainfrom
Conversation
b7a57bf to
76d3603
Compare
fs.cpSync with recursive:true calls create_symlink() and copy_symlink() without checking if the symlink target is within the allowed permission paths. fs.symlinkSync already validates symlink targets against the permission model (added as the fix for CVE-2025-55130 at src/node_file.cc:1353-1357). The same check was missing in CpSyncCopyDir for both the standard symlink copy path and the verbatimSymlinks code path. Add permission checks for both kFileSystemRead and kFileSystemWrite on the resolved symlink target before create_symlink, create_directory_symlink, and copy_symlink calls in CpSyncCopyDir. Fixes: nodejs#63179 Refs: CVE-2025-55130 Signed-off-by: fg0x0 <fg0x0@local>
76d3603 to
7a2f106
Compare
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.
What
Add permission checks for symlink target paths in
CpSyncCopyDir(src/node_file.cc).Why
fs.cpSyncwithrecursive: truecopies symlinks viastd::filesystem::create_symlink()andcopy_symlink()without validating the symlink target against the permission model. This allows reading and writing files outside permitted paths through copied symlinks.fs.symlinkSyncwas fixed for this in the CVE-2025-55130 patch (lines 1353-1357) but the same check was not added to cpSync.Reproduction
Output (before fix):
How
Added permission checks using
env->permission()->is_granted()for bothkFileSystemReadandkFileSystemWriteon the resolved symlink target before:create_symlink()call (line ~3819)create_directory_symlink()call (line ~3822)copy_symlink()call in theverbatimSymlinkspath (line ~3754)Test
Added
test/parallel/test-fs-cp-permission-symlink.jswhich verifies thatfs.cpSyncthrowsERR_ACCESS_DENIEDwhen copying a directory containing a symlink pointing outside the allowed permission paths.Fixes: #63179
Refs: CVE-2025-55130