You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The work that @manidlou did in PR #582 changed a lot of sanity and edge-case checks in copy() and copySync() to use ino instead of name / paths for comparison. However, the isSrcSubdir() check still relies on checking string names, which is insufficient in the case that a single folder has multiple locations / names, e.g. a double-mounted Docker volume or a bind-mounted folder. I believe that this check should also be switched to rely on ino.
In order to exploit this name check, here is what I did:
Made an empty directory on my host Windows OS
Started a Docker container, double-mounting the empty dir into /mount/dir1 and /mount/dir2
Using fs-extra inside the container, run fs.copySync('/mount/dir1', '/mount/dir2/sub'). The current isSrcSubdir() check will fail to abort the copy, and the operation will recurse infinitely, continuing to create nested /sub dirs until execution is stopped manually, or perhaps a stack overflow occurs.
As an additional note, I noticed this issue while working on #575. Removing the string-based checks is a pre-requisite for finishing #575.
The text was updated successfully, but these errors were encountered:
@rossj another way of solving this is by checking the dest parent stats since in cases like this src and dest parent have the same inode. I already tested out the idea and implemented the function that it works fine.
fs-extra
version: 7.0.0The work that @manidlou did in PR #582 changed a lot of sanity and edge-case checks in
copy()
andcopySync()
to useino
instead of name / paths for comparison. However, theisSrcSubdir()
check still relies on checking string names, which is insufficient in the case that a single folder has multiple locations / names, e.g. a double-mounted Docker volume or a bind-mounted folder. I believe that this check should also be switched to rely onino
.In order to exploit this name check, here is what I did:
/mount/dir1
and/mount/dir2
fs-extra
inside the container, runfs.copySync('/mount/dir1', '/mount/dir2/sub')
. The currentisSrcSubdir()
check will fail to abort the copy, and the operation will recurse infinitely, continuing to create nested/sub
dirs until execution is stopped manually, or perhaps a stack overflow occurs.As an additional note, I noticed this issue while working on #575. Removing the string-based checks is a pre-requisite for finishing #575.
The text was updated successfully, but these errors were encountered: