// For flags

CVE-2021-32803

Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning

Severity Score

8.1
*CVSS v3.1

Exploit Likelihood

*EPSS

Affected Versions

*CPE

Public Exploits

0
*Multiple Sources

Exploited in Wild

-
*KEV

Decision

-
*SSVC
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.

*Credits: N/A
CVSS Scores
Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
Required
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
High
Attack Vector
Local
Attack Complexity
Low
Privileges Required
None
User Interaction
Required
Scope
Changed
Confidentiality
High
Integrity
High
Availability
None
Attack Vector
Network
Attack Complexity
Medium
Authentication
None
Confidentiality
None
Integrity
Partial
Availability
Partial
* Common Vulnerability Scoring System
SSVC
  • Decision:-
Exploitation
-
Automatable
-
Tech. Impact
-
* Organization's Worst-case Scenario
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
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