CVE-2021-32803
Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning
Severity Score
Exploit Likelihood
Affected Versions
Public Exploits
0Exploited in Wild
-Decision
Descriptions
The npm package "tar" (aka node-tar) before versions 6.1.2, 5.0.7, 4.4.15, and 3.2.3 has an arbitrary File Creation/Overwrite vulnerability via 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 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 where `node-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.
El paquete npm "tar" (también se conoce como node-tar) versiones anteriores a 6.1.2, 5.0.7, 4.4.15 y 3.2.3 presenta una vulnerabilidad de Creación y Sobrescritura de archivos arbitraria por medio de una protección insuficiente de enlaces simbólicos. El objetivo de "node-tar" es garantizar que no se extraiga ningún archivo cuya ubicación pueda ser modificada por un enlace simbólico. Esto se consigue, en parte, al asegurar que los directorios extraídos no sean enlaces simbólicos. Adicionalmente, para evitar llamadas innecesarias a "stat" para determinar si una ruta dada es un directorio, las rutas se almacenan en caché cuando los directorios son creados. Esta lógica era insuficiente cuando se extraían archivos tar que contenían tanto un directorio como un enlace simbólico con el mismo nombre que el directorio. Este orden de operaciones resultaba que el directorio fuera creado y se añadiera a la caché de directorios del "nodo-tar". Cuando un directorio está presente en la caché de directorios, las siguientes llamadas a mkdir para ese directorio se saltan. Sin embargo, aquí es también donde "node-tar" comprueba que los enlaces simbólicos ocurran. Al crear primero un directorio, y luego reemplazando ese directorio con un enlace simbólico, era posible así omitir las comprobaciones de enlaces simbólicos de "node-tar" en los directorios, permitiendo esencialmente que un archivo tar no confiable se enlazara simbólicamente en una ubicación arbitraria y que subsecuentemente se extrajeran archivos arbitrarios en esa ubicación, permitiendo así la creación y sobrescritura de archivos arbitraria. Este problema se solucionó en las versiones 3.2.3, 4.4.15, 5.0.7 y 6.1.2
The npm package "tar" (aka node-tar) has an arbitrary File Creation/Overwrite vulnerability via 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.
CVSS Scores
SSVC
- Decision:-
Timeline
- 2021-05-12 CVE Reserved
- 2021-08-03 CVE Published
- 2024-04-18 EPSS Updated
- 2024-08-03 CVE Updated
- ---------- Exploited in Wild
- ---------- KEV Due Date
- ---------- First Exploit
CWE
- CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
- CWE-59: Improper Link Resolution Before File Access ('Link Following')
CAPEC
References (8)
URL | Tag | Source |
---|---|---|
https://github.com/npm/node-tar/security/advisories/GHSA-r628-mhmh-qjhw | Mitigation | |
https://www.npmjs.com/advisories/1771 | Mitigation | |
https://www.npmjs.com/package/tar | Product |
URL | Date | SRC |
---|
URL | Date | SRC |
---|---|---|
https://access.redhat.com/security/cve/CVE-2021-32803 | 2021-12-13 | |
https://bugzilla.redhat.com/show_bug.cgi?id=1990415 | 2021-12-13 |
Affected Vendors, Products, and Versions
Vendor | Product | Version | Other | Status | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Vendor | Product | Version | Other | Status | <-- --> | Vendor | Product | Version | Other | Status |
Tar Project Search vendor "Tar Project" | Tar Search vendor "Tar Project" for product "Tar" | < 3.2.3 Search vendor "Tar Project" for product "Tar" and version " < 3.2.3" | node.js |
Affected
| ||||||
Tar Project Search vendor "Tar Project" | Tar Search vendor "Tar Project" for product "Tar" | >= 4.0.0 < 4.4.15 Search vendor "Tar Project" for product "Tar" and version " >= 4.0.0 < 4.4.15" | node.js |
Affected
| ||||||
Tar Project Search vendor "Tar Project" | Tar Search vendor "Tar Project" for product "Tar" | >= 5.0.0 < 5.0.7 Search vendor "Tar Project" for product "Tar" and version " >= 5.0.0 < 5.0.7" | node.js |
Affected
| ||||||
Tar Project Search vendor "Tar Project" | Tar Search vendor "Tar Project" for product "Tar" | >= 6.0.0 < 6.1.2 Search vendor "Tar Project" for product "Tar" and version " >= 6.0.0 < 6.1.2" | node.js |
Affected
| ||||||
Oracle Search vendor "Oracle" | Graalvm Search vendor "Oracle" for product "Graalvm" | 20.3.3 Search vendor "Oracle" for product "Graalvm" and version "20.3.3" | enterprise |
Affected
| ||||||
Oracle Search vendor "Oracle" | Graalvm Search vendor "Oracle" for product "Graalvm" | 21.2.0 Search vendor "Oracle" for product "Graalvm" and version "21.2.0" | enterprise |
Affected
| ||||||
Siemens Search vendor "Siemens" | Sinec Infrastructure Network Services Search vendor "Siemens" for product "Sinec Infrastructure Network Services" | < 1.0.1.1 Search vendor "Siemens" for product "Sinec Infrastructure Network Services" and version " < 1.0.1.1" | - |
Affected
|