tar@3.2.1

tar for node

  • latest version

    7.5.22

  • latest non vulnerable version

  • first published

    14 years ago

  • latest version published

    1 months ago

  • licenses detected

    • >=2.1.1 <7.5.2
  • Direct Vulnerabilities

    Known vulnerabilities in the tar package. This does not include vulnerabilities belonging to this package’s dependencies.

    Fix vulnerabilities automatically

    Snyk's AI Trust Platform automatically finds the best upgrade path and integrates with your development workflows. Secure your code at zero cost.

    Fix for free
    VulnerabilityVulnerable Version
    • M
    Uncontrolled Recursion

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Uncontrolled Recursion in the mapHas helper and filesFilter function in src/list.ts, which walk an entry path upward with one path.dirname() call per recursion and no segment cap. An attacker can terminate the Node process with an uncatchable stack-overflow RangeError by supplying a tar archive whose GNU L or PAX x long-path header carries tens of thousands of /-separated segments, when that archive is listed or extracted with a member-selection filter. Exploitation requires the application to call tar.t() or tar.x() with a non-empty member-selection list on an untrusted archive, and on async or streaming consumers the error is uncatchable while synchronous APIs can catch it.

    How to fix Uncontrolled Recursion?

    Upgrade tar to version 7.5.21 or higher.

    <7.5.21
    • M
    Uncaught Exception

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Uncaught Exception through improper handling of NUL bytes in the src/pax.ts file. An attacker can cause the application to terminate unexpectedly by providing a crafted archive containing NUL bytes in PAX path or linkpath records, which leads to an uncaught exception when these values are passed to filesystem operations.

    How to fix Uncaught Exception?

    Upgrade tar to version 7.5.17 or higher.

    <7.5.17
    • H
    Allocation of Resources Without Limits or Throttling

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling due to the lack of enforced upper bounds on total decompressed data, entry counts, or decompression ratio in extraction and parsing paths such as src/extract.ts. An attacker can exhaust disk space and CPU resources by submitting a small crafted gzip archive with a high decompression ratio.

    How to fix Allocation of Resources Without Limits or Throttling?

    Upgrade tar to version 7.5.19 or higher.

    <7.5.19
    • M
    Incorrect Type Conversion or Cast

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Incorrect Type Conversion or Cast via the src/pax.ts file. An attacker can cause a process crash by providing all-digit PAX path or linkpath values that are coerced to JavaScript numbers, leading to a TypeError during downstream path handling.

    How to fix Incorrect Type Conversion or Cast?

    Upgrade tar to version 7.5.18 or higher.

    <7.5.18
    • H
    Infinite loop

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Infinite loop via the replace method. An attacker can cause the archive scanner to enter an infinite loop by providing a tar header with a negative base-256 encoded entry size.

    How to fix Infinite loop?

    Upgrade tar to version 7.5.18 or higher.

    <7.5.18
    • M
    Interpretation Conflict

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Interpretation Conflict due to improper handling of PAX extended header size overrides in intermediary metadata headers. An attacker can cause inconsistent archive parsing results between different tar implementations by crafting a malicious tar archive that desynchronizes the parser's interpretation, potentially hiding files from scanners or extractors that rely on different tools.

    How to fix Interpretation Conflict?

    Upgrade tar to version 7.5.16 or higher.

    <7.5.16
    • H
    Symlink Attack

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Symlink Attack via tar.x() extraction, which allows an attacker to overwrite arbitrary files outside the intended extraction directory with a drive-relative symlink target - like C:../../../target.txt.

    How to fix Symlink Attack?

    Upgrade tar to version 7.5.11 or higher.

    <7.5.11
    • H
    Symlink Attack

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Symlink Attack exploitable via stripAbsolutePath(), used by the Unpack class. An attacker can overwrite arbitrary files outside the intended extraction directory by including a hardlink whose linkpath uses a drive-relative path such as C:../target.txt in a malicious tar.

    How to fix Symlink Attack?

    Upgrade tar to version 7.5.10 or higher.

    <7.5.10
    • H
    Directory Traversal

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Directory Traversal via the extract() function. An attacker can read or write files outside the intended extraction directory by causing the application to extract a malicious archive containing a chain of symlinks leading to a hardlink, which bypasses path validation checks.

    How to fix Directory Traversal?

    Upgrade tar to version 7.5.8 or higher.

    <7.5.8
    • M
    Directory Traversal

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Directory Traversal via processing of hardlinks. An attacker can read or overwrite arbitrary files on the file system by crafting a malicious TAR archive that bypasses path traversal protections during extraction.

    How to fix Directory Traversal?

    Upgrade tar to version 7.5.7 or higher.

    <7.5.7
    • M
    Directory Traversal

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Directory Traversal via insufficient sanitization of the linkpath parameter during archive extraction. An attacker can overwrite arbitrary files or create malicious symbolic links by crafting a tar archive with hardlink or symlink entries that resolve outside the intended extraction directory.

    How to fix Directory Traversal?

    Upgrade tar to version 7.5.3 or higher.

    <7.5.3
    • M
    Improper Handling of Unicode Encoding

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Improper Handling of Unicode Encoding in Path Reservations via Unicode Sharp-S (ß) Collisions on macOS APFS. An attacker can overwrite arbitrary files by exploiting Unicode normalization collisions in filenames within a malicious tar archive on case-insensitive or normalization-insensitive filesystems.

    Note:

    This is only exploitable if the system is running on a filesystem such as macOS APFS or HFS+ that ignores Unicode normalization.

    How to fix Improper Handling of Unicode Encoding?

    Upgrade tar to version 7.5.4 or higher.

    <7.5.4
    • M
    Uncontrolled Resource Consumption ('Resource Exhaustion')

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Uncontrolled Resource Consumption ('Resource Exhaustion') due to the lack of folders count validation during the folder creation process. An attacker who generates a large number of sub-folders can consume memory on the system running the software and even crash the client within few seconds of running it using a path with too many sub-folders inside.

    How to fix Uncontrolled Resource Consumption ('Resource Exhaustion')?

    Upgrade tar to version 6.2.1 or higher.

    <6.2.1
    • H
    Arbitrary File Write

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Arbitrary File Write. 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 is possible to bypass node-tar symlink checks on directories, essentially allowing an untrusted tar file to symlink into an arbitrary location. This can lead to 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 named foo, 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 the FOO directory would then be placed in the target of the symbolic link, thinking that the directory had already been created.

    How to fix Arbitrary File Write?

    Upgrade tar to version 6.1.7, 5.0.8, 4.4.16 or higher.

    >=6.0.0 <6.1.7>=5.0.0 <5.0.8<4.4.16
    • H
    Arbitrary File Write

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Arbitrary File Write. 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 is insufficient when extracting tar files that contain 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 can 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. This leads to bypassing node-tar symlink checks on directories, essentially allowing an untrusted tar file to symlink into an arbitrary location and extracting arbitrary files into that location.

    How to fix Arbitrary File Write?

    Upgrade tar to version 6.1.9, 5.0.10, 4.4.18 or higher.

    >=6.0.0 <6.1.9>=5.0.0 <5.0.10<4.4.18
    • H
    Arbitrary File Write

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Arbitrary File Write. 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 is insufficient on Windows systems when extracting tar files that contain a path that is not an absolute path, but specify a drive letter different from the extraction target, such as C:some\path. If the drive letter does not match the extraction target, for example D:\extraction\dir, then the result of path.resolve(extractionDirectory, entryPath) resolves against the current working directory on the C: drive, rather than the extraction target directory.

    Additionally, a .. portion of the path can occur immediately after the drive letter, such as C:../foo, and is not properly sanitized by the logic that checks for .. within the normalized and split portions of the path.

    Note: This only affects users of node-tar on Windows systems.

    How to fix Arbitrary File Write?

    Upgrade tar to version 6.1.9, 5.0.10, 4.4.18 or higher.

    >=6.0.0 <6.1.9>=5.0.0 <5.0.10<4.4.18
    • H
    Arbitrary File Overwrite

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Arbitrary File Overwrite. This is due to insufficient absolute path sanitization.

    node-tar aims to prevent extraction of absolute file paths by turning absolute paths into relative paths when the preservePaths flag is not set to true. This is achieved by stripping the absolute path root from any absolute file paths contained in a tar file. For example, the path /home/user/.bashrc would turn into home/user/.bashrc.

    This logic is insufficient when file paths contain repeated path roots such as ////home/user/.bashrc. node-tar only strips 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) still resolves to an absolute path.

    How to fix Arbitrary File Overwrite?

    Upgrade tar to version 3.2.2, 4.4.14, 5.0.6, 6.1.1 or higher.

    <3.2.2>=4.0.0 <4.4.14>=5.0.0 <5.0.6>=6.0.0 <6.1.1
    • H
    Arbitrary File Overwrite

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Arbitrary File Overwrite. This is due to insufficient symlink protection. 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 is insufficient when extracting tar files that contain both a directory and a symlink with the same name as the directory. This order of operations results 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 where node-tar checks for symlinks occur. By first creating a directory, and then replacing that directory with a symlink, it is 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.

    How to fix Arbitrary File Overwrite?

    Upgrade tar to version 3.2.3, 4.4.15, 5.0.7, 6.1.2 or higher.

    <3.2.3>=4.0.0 <4.4.15>=5.0.0 <5.0.7>=6.0.0 <6.1.2
    • H
    Arbitrary File Overwrite

    tar is a full-featured Tar for Node.js.

    Affected versions of this package are vulnerable to Arbitrary File Overwrite. Extracting tarballs containing a hard-link to a file that already exists in the system, and a file that matches the hard-link may overwrite system's files with the contents of the extracted file.

    How to fix Arbitrary File Overwrite?

    Upgrade tar to version 2.2.2, 4.4.2 or higher.

    <2.2.2>=3.0.0 <4.4.2