Skip to content
Path traversal Disclosed report Intermediate CVE-2018-1002203

Arbitrary File Write through archive extraction

The unzipper module before version 0.8.13 is vulnerable to a directory traversal flaw when extracting archives, allowing an attacker to write files outside the intended extraction directory. This can lead to overwriting executable or configuration files, potentially enabling remote command execution.

danny_grander Follow

Originally disclosed on HackerOne

High 8.2 View original
  • Triaged in 27 days
  • Fixed in 2 months
  • Disclosed after 2 months

I would like to report arbitrary file write vulnerability in adm-zip module It allows attackers to write arbitrary files when a malicious archive is extracted. More info here: https://snyk.io/research/zip-slip-vulnerability https://github.com/snyk/zip-slip-vulnerability#affected-libraries

Module

module name: unzipper version: <0.8.13 npm page: https://www.npmjs.com/package/unzipper

Module Description

This is a fork of node-unzip which has not been maintained in a while. This fork addresses the following issues:

  • finish/close events are not always triggered, particular when the input stream is slower than the receivers
  • Any files are buffered into memory before passing on to entry

Module Stats

80k downloads in the last week

Vulnerability

Vulnerability Description

The vulnerability is a form of directory traversal that can be exploited by extracting files from an archive. The premise of the directory traversal vulnerability is that an attacker can gain access to parts of the file system outside of the target folder in which they should reside. The attacker can then overwrite executable files and either invoke them remotely or wait for the system or user to call them, thus achieving remote command execution on the victim’s machine. The vulnerability can also cause damage by overwriting configuration files or other sensitive resources, and can be exploited on both client (user) machines and servers.

More info here: https://snyk.io/research/zip-slip-vulnerability https://github.com/snyk/zip-slip-vulnerability

Steps To Reproduce:

Sample files can be found here: https://github.com/snyk/zip-slip-vulnerability/tree/master/archives

Patch

Vulnerability is already fixed in ver 0.8.13 We opened a fix PR on 16th of April, https://github.com/ZJONSSON/node-unzipper/pull/59

CVE id for the vuln was assigned: CVE-2018-1002203

Supporting Material/References:

There are multiple libraries affected, across different ecosystems. Full list here: https://github.com/snyk/zip-slip-vulnerability#affected-libraries

https://snyk.io/research/zip-slip-vulnerability https://github.com/snyk/zip-slip-vulnerability

Wrap up

  • I contacted the maintainer to let them know: Y, and helped fix the issue
  • I opened an issue in the related repository: N

Impact

Arbitrary file write

The original report as published on HackerOne, by danny_grander. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the module does not properly sanitise file paths in the archive, allowing '../' sequences to escape the extraction directory.

Impact

An attacker could overwrite executable files and either invoke them remotely or wait for the system or user to call them, thus achieving remote command execution on the victim’s machine.

What the attacker needed

Victim extracts a malicious archive

The fix

The vulnerability was fixed in version 0.8.13.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When you unzip a file, the program should only put files inside the folder you chose. But this bug lets a malicious zip file sneak files into other places on your computer, like your system folders. An attacker could replace a program you run with their own, and then when you run it, they can take control.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More by danny_grander

View all

2 more disclosed reports, best first.

More from Node.js third-party modules

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.