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 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. These issues were addressed in releases 4.4.16, 5.0.8 and 6.1.7. Reference: https://github.com/npm/node-tar/security/advisories/GHSA-9r2w-394v-53qc
Created nodejs-tar tracking bugs for this issue: Affects: epel-7 [bug 1999738] Affects: fedora-all [bug 1999737]
Upstream commit: https://github.com/npm/node-tar/commit/53602669f58ddbeb3294d7196b3320aaaed22728 [main, v6] https://github.com/npm/node-tar/commit/ab3e9036dc4504413fb6f154ea6943af5c187e26 [v5] https://github.com/npm/node-tar/commit/3f2e2da3866c4e5f26ca0c0d6721cb371c5a3933 [v4]
It's also worth noting the following commit, where "the path normalization of \ to / is made more comprehensive": https://github.com/npm/node-tar/commit/c2a0948fb7b70862f92828e7b37b622566ed367e [main, v6] https://github.com/npm/node-tar/commit/e120d38cef8792f9dec4ee30c7d79699c419f9ef [v5] https://github.com/npm/node-tar/commit/ce5148e12d1f9fed671e84673a4c7bd6ef743cfb [v4]
This issue has been addressed in the following products: Red Hat OpenShift Data Foundation 4.9.0 on RHEL-8 Via RHSA-2021:5086 https://access.redhat.com/errata/RHSA-2021:5086
This issue has been addressed in the following products: Red Hat Software Collections for Red Hat Enterprise Linux 7 Via RHSA-2022:0041 https://access.redhat.com/errata/RHSA-2022:0041
This issue has been addressed in the following products: Red Hat Enterprise Linux 8.4 Extended Update Support Via RHSA-2022:0246 https://access.redhat.com/errata/RHSA-2022:0246
This issue has been addressed in the following products: Red Hat Enterprise Linux 8 Via RHSA-2022:0350 https://access.redhat.com/errata/RHSA-2022:0350
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s): https://access.redhat.com/security/cve/cve-2021-37701
This issue has been addressed in the following products: Red Hat Software Collections for Red Hat Enterprise Linux 7 Via RHSA-2022:4914 https://access.redhat.com/errata/RHSA-2022:4914