[Security] Bump tar from 4.4.13 to 4.4.19
Bumps tar from 4.4.13 to 4.4.19. This update includes security fixes.
Vulnerabilities fixed
Arbitrary File Creation/Overwrite on Windows via insufficient relative path sanitization
Impact
Arbitrary File Creation, Arbitrary File Overwrite, Arbitrary Code Execution
node-tar aims to guarantee that any file whose location would be outside of the extraction target directory is not extracted. This is, in part, accomplished by sanitizing absolute paths of entries within the archive, skipping archive entries that contain
..
path portions, and resolving the sanitized paths against the extraction target directory.This logic was insufficient on Windows systems when extracting tar files that contained a path that was not an absolute path, but specified a drive letter different from the extraction target, such as
C:some\path
. If the drive letter does not match the extraction target, for exampleD:\extraction\dir
, then the result ofpath.resolve(extractionDirectory, entryPath)
would resolve against the current working directory on theC:
drive, rather than the extraction target directory.Additionally, a
..
portion of the path could occur immediately after the drive letter, such asC:../foo
, and was not properly sanitized by the logic that checked for..
within the normalized and split portions of the path.This only affects users of
node-tar
on Windows systems.Patches
4.4.18 || 5.0.10 || 6.1.9
Workarounds
There is no reasonable way to work around this issue without performing the same path normalization procedures that node-tar now does.
... (truncated)
Patched versions: 4.4.18 Affected versions: < 4.4.18
Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning using symbolic links
Impact
Arbitrary File Creation, Arbitrary File Overwrite, Arbitrary Code Execution
node-tar aims to guarantee that any file whose location would be modified by a symbolic link is not extracted. This is, in part, achieved by ensuring that extracted directories are not symlinks. Additionally, in order to prevent unnecessary stat calls to determine whether a given path is a directory, paths are cached when directories are created.
This logic was insufficient when extracting tar files that contained two directories and a symlink with names containing unicode values that normalized to the same value. Additionally, on Windows systems, long path portions would resolve to the same file system entities as their 8.3 "short path" counterparts. A specially crafted tar archive could thus include directories with two forms of the path that resolve to the same file system entity, followed by a symbolic link with a name in the first form, lastly followed by a file using the second form. It led to bypassing node-tar symlink checks on directories, essentially allowing an untrusted tar file to symlink into an arbitrary location and subsequently extracting arbitrary files into that location, thus allowing arbitrary file creation and overwrite.
The v3 branch of
node-tar
has been deprecated and did not receive patches for these issues. If you are still using a v3 release we recommend you update to a more recent version ofnode-tar
. If this is not possible, a workaround is available below.Patches
6.1.9 || 5.0.10 || 4.4.18
Workarounds
Users may work around this vulnerability without upgrading by creating a custom filter method which prevents the extraction of symbolic links.
const tar = require('tar') </tr></table>
... (truncated)
Patched versions: 4.4.18 Affected versions: < 4.4.18
Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning using symbolic links
Impact
Arbitrary File Creation, Arbitrary File Overwrite, Arbitrary Code Execution
node-tar
aims to guarantee that any file whose location would be modified by a symbolic link is not extracted. This is, in part, achieved by ensuring that extracted directories are not symlinks. Additionally, in order to prevent unnecessary stat calls to determine whether a given path is a directory, paths are cached when directories are created.This logic was insufficient when extracting tar files that contained both a directory and a symlink with the same name as the directory, where the symlink and directory names in the archive entry used backslashes as a path separator on posix systems. The cache checking logic used both
\
and/
characters as path separators, however\
is a valid filename character on posix systems.By first creating a directory, and then replacing that directory with a symlink, it was thus possible to bypass node-tar symlink checks on directories, essentially allowing an untrusted tar file to symlink into an arbitrary location and subsequently extracting arbitrary files into that location, thus allowing arbitrary file creation and overwrite.
Additionally, a similar confusion could arise on case-insensitive filesystems. If a tar archive contained a directory at
FOO
, followed by a symbolic link namedfoo
, then on case-insensitive file systems, the creation of the symbolic link would remove the directory from the filesystem, but not from the internal directory cache, as it would not be treated as a cache hit. A subsequent file entry within theFOO
directory would then be placed in the target of the symbolic link, thinking that the directory had already been created.These issues were addressed in releases 4.4.16, 5.0.8 and 6.1.7.
The v3 branch of
node-tar
has been deprecated and did not receive patches for these issues. If you are still using a v3 release we recommend you update to a more recent version ofnode-tar
. If this is not possible, a workaround is available below.Patches
4.4.16 || 5.0.8 || 6.1.7
... (truncated)
Patched versions: 4.4.16 Affected versions: < 4.4.16
Arbitrary File Creation/Overwrite due to insufficient absolute path sanitization
Impact
Arbitrary File Creation, Arbitrary File Overwrite, Arbitrary Code Execution
node-tar
aims to prevent extraction of absolute file paths by turning absolute paths into relative paths when thepreservePaths
flag is not set totrue
. This is achieved by stripping the absolute path root from any absolute file paths contained in a tar file. For example/home/user/.bashrc
would turn intohome/user/.bashrc
.This logic was insufficient when file paths contained repeated path roots such as
////home/user/.bashrc
.node-tar
would only strip a single path root from such paths. When given an absolute file path with repeating path roots, the resulting path (e.g.///home/user/.bashrc
) would still resolve to an absolute path, thus allowing arbitrary file creation and overwrite.Patches
3.2.2 || 4.4.14 || 5.0.6 || 6.1.1
NOTE: an adjacent issue CVE-2021-32803 affects this release level. Please ensure you update to the latest patch levels that address CVE-2021-32803 as well if this adjacent issue affects your
node-tar
use case.Workarounds
Users may work around this vulnerability without upgrading by creating a custom
onentry
method which sanitizes theentry.path
or afilter
method which removes entries with absolute paths.const path = require('path') </tr></table>
... (truncated)
Patched versions: 4.4.14 Affected versions: >= 4.0.0, < 4.4.14
Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning
Impact
Arbitrary File Creation, Arbitrary File Overwrite, Arbitrary Code Execution
node-tar
aims to guarantee that any file whose location would be modified by a symbolic link is not extracted. This is, in part, achieved by ensuring that extracted directories are not symlinks. Additionally, in order to prevent unnecessarystat
calls to determine whether a given path is a directory, paths are cached when directories are created.This logic was insufficient when extracting tar files that contained both a directory and a symlink with the same name as the directory. This order of operations resulted in the directory being created and added to the
node-tar
directory cache. When a directory is present in the directory cache, subsequent calls to mkdir for that directory are skipped. However, this is also wherenode-tar
checks for symlinks occur.By first creating a directory, and then replacing that directory with a symlink, it was thus possible to bypass
node-tar
symlink checks on directories, essentially allowing an untrusted tar file to symlink into an arbitrary location and subsequently extracting arbitrary files into that location, thus allowing arbitrary file creation and overwrite.This issue was addressed in releases 3.2.3, 4.4.15, 5.0.7 and 6.1.2.
Patches
3.2.3 || 4.4.15 || 5.0.7 || 6.1.2
Workarounds
Users may work around this vulnerability without upgrading by creating a custom
filter
method which prevents the extraction of symbolic links.
... (truncated)
Patched versions: 4.4.15 Affected versions: >= 4.0.0, < 4.4.15
Commits
-
9a6faa0
4.4.19 -
70ef812
drop dirCache for symlink on all platforms -
3e35515
4.4.18 -
52b09e3
fix: prevent path escape using drive-relative paths -
bb93ba2
fix: reserve paths properly for unicode, windows -
2f1bca0
fix: prune dirCache properly for unicode, windows -
9bf70a8
4.4.17 -
6aafff0
fix: skip extract if linkpath is stripped entirely -
5c5059a
fix: reserve paths case-insensitively -
fd6accb
4.4.16 - Additional commits viewable in compare view
Dependabot commands
You can trigger Dependabot actions by commenting on this MR
-
$dependabot rebase
will rebase this MR -
$dependabot recreate
will recreate this MR rewriting all the manual changes and resolving conflicts