CVE-2021-32803: Arbitrary File Creation/Overwrite in tar

tar Updated 02 Oct 2025

Summary

03/08/2021
Yes i
High
8.2

CVE-2021-32803: Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning. Affects tar across 4 version ranges.

>= 3.0.0, < 3.2.3 >= 4.0.0, < 4.4.15 >= 5.0.0, < 5.0.7 >= 6.0.0, < 6.1.2

Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-32803 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

The 'tar' package is an npm module used for creating and extracting tar archives in Node.js applications. It provides functionality to compress and decompress files and directories. The vulnerability identified as CVE-2021-32803 allows an attacker to create or overwrite arbitrary files on the system by exploiting insufficient symlink protection in the 'node-tar' module, which is used by 'tar'. This vulnerability can lead to arbitrary code execution and poses a high risk to affected systems.

Vulnerability Detail

The vulnerability arises from a flaw in the logic of 'node-tar' when extracting tar files that contain both a directory and a symlink with the same name as the directory. Due to the order of operations, the directory is created and added to the 'node-tar' directory cache before symlink checks are performed. This allows an attacker to first create a directory and then replace it with a symlink, bypassing symlink checks on directories. As a result, an untrusted tar file can symlink into an arbitrary location and extract arbitrary files, leading to arbitrary file creation and overwrite. The impact of this vulnerability includes arbitrary file creation, arbitrary file overwrite, and potential arbitrary code execution.

How To Fix

Latest published version: 7.5.22 as of 22 Oct 2026

npm install tar@7.5.22

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • >= 3.0.0, < 3.2.3 3.2.3
    npm install tar@3.2.3
  • >= 4.0.0, < 4.4.15 4.4.15
    npm install tar@4.4.15
  • >= 5.0.0, < 5.0.7 5.0.7
    npm install tar@5.0.7
  • >= 6.0.0, < 6.1.2 6.1.2
    npm install tar@6.1.2

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If upgrading is not immediately possible, users can implement a custom 'filter' method to prevent the extraction of symbolic links. The following code snippet demonstrates how to create a custom filter method:

const tar = require('tar')

tar.x({
  file: 'archive.tgz',
  filter: (file, entry) => {
    if (entry.type === 'SymbolicLink') {
      return false
    } else {
      return true
    }
  }
})

Conclusion

The vulnerability CVE-2021-32803 in the 'tar' package allows for arbitrary file creation and overwrite, potentially leading to arbitrary code execution. It is crucial to upgrade to the latest patch version (3.2.3, 4.4.15, 5.0.7, or 6.1.2) or implement the provided workaround to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tar →

Share this vulnerability

FAQ

The impact includes arbitrary file creation, arbitrary file overwrite, and potential arbitrary code execution.

The vulnerability affects versions 0.0.0 to 3.2.2, 4.0.0 to 4.4.14, 5.0.0 to 5.0.6, and 6.0.0 to 6.1.1 of the 'tar' package.

Upgrade to the latest patch version of the 'tar' package (3.2.3, 4.4.15, 5.0.7, or 6.1.2) to fix this vulnerability.

Yes, users can implement a custom 'filter' method to prevent the extraction of symbolic links. Refer to the 'workaround' section for more details.

Related vulnerabilities

Recent vulnerabilities recorded for tar.

How To Fix

Latest published version: 7.5.22 as of 22 Oct 2026

npm install tar@7.5.22

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • >= 3.0.0, < 3.2.3 3.2.3
    npm install tar@3.2.3
  • >= 4.0.0, < 4.4.15 4.4.15
    npm install tar@4.4.15
  • >= 5.0.0, < 5.0.7 5.0.7
    npm install tar@5.0.7
  • >= 6.0.0, < 6.1.2 6.1.2
    npm install tar@6.1.2

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback