CVE-2021-23484: Arbitrary File Write via Archive Extraction in zip-local

zip-local Updated 02 Oct 2025

Summary

01/02/2022
Yes i
Critical
9.8

CVE-2021-23484: Exposure of Resource to Wrong Sphere in Zip-Local. Affects zip-local versions < 0.3.5. Fixed in 0.3.5. How to fix ↓

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

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

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 zip-local package is an npm package that provides functionality for working with zip archives in Node.js. It allows users to create, extract, and manipulate zip files. The package is commonly used in applications that require file compression and decompression capabilities. However, versions of zip-local before 0.3.5 are vulnerable to an Arbitrary File Write via Archive Extraction (Zip Slip) attack. This vulnerability allows an attacker to craft a malicious zip file that, when extracted using the zip-local library, can write files to arbitrary locations on the file system, potentially leading to unauthorized access or code execution.

Vulnerability Detail

The vulnerability in zip-local arises from a lack of proper validation of file paths during the extraction process. When a zip file is extracted using the vulnerable versions of zip-local, the library does not adequately check if the extracted files are being written to the intended extraction directory. This allows an attacker to craft a zip file with specially crafted file paths that can traverse directories and write files to arbitrary locations on the file system. The consequences of this vulnerability can be severe, as it can lead to unauthorized access to sensitive files or the execution of arbitrary code.

How To Fix

Minimum fixed version

0.3.5

This is the first release that contains the fix.

npm install zip-local@0.3.5

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If upgrading to the latest version of zip-local is not immediately feasible, a temporary workaround is to implement additional validation of file paths before extracting zip files using the zip-local library. This can be done by checking if the extracted file paths are within the intended extraction directory and rejecting any files that are outside this directory. Here is an example of how this can be implemented in Node.js:

const zip = require('zip-local');

function extractZipFile(zipFilePath, extractionDirectory) {
  const files = zip.sync.unzip(zipFilePath);

  files.forEach(file => {
    const extractedFilePath = file.name;
    const absoluteFilePath = path.resolve(extractionDirectory, extractedFilePath);

    if (!absoluteFilePath.startsWith(extractionDirectory)) {
      throw new Error('Invalid file path: ' + extractedFilePath);
    }

    // Extract the file
    file.extract(extractionDirectory);
  });
}

Conclusion

The vulnerability in zip-local before version 0.3.5 allows for arbitrary file write via archive extraction, potentially leading to unauthorized access or code execution. It is recommended to upgrade to version 0.3.5 or later to fix this vulnerability. If immediate upgrade is not possible, implementing additional validation of file paths can serve as a temporary workaround. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for zip-local →

Share this vulnerability

FAQ

The vulnerability allows an attacker to write files to arbitrary locations on the file system when a zip file is extracted using the vulnerable versions of zip-local. This can lead to unauthorized access to sensitive files or the execution of arbitrary code.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability. The playground allows you to analyze your package-lock.json file and provides real-time alerts for open-source vulnerabilities, including this one.

Yes, a fix is available in version 0.3.5 of the zip-local package. It is recommended to upgrade to this version or later to mitigate the vulnerability.

Yes, a temporary workaround is to implement additional validation of file paths before extracting zip files using the zip-local library. This can help prevent the extraction of files outside the intended extraction directory.

How To Fix

Minimum fixed version

0.3.5

This is the first release that contains the fix.

npm install zip-local@0.3.5

Tip — Not sure which version your app runs? Vulert can match this fix to it. 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