Five Cves Hidden In Npm Dependencies
Five CVEs were found across three npm packages: decompress mishandles hardlink, symlink and prefix-based containment checks so archives can read or write files outside the extraction directory, adm-zip allocates memory based on an attacker-declared ZIP header size, and pathe normalises backslashes so a '../' check can be bypassed. An attacker who can supply an untrusted archive or path to these libraries could disclose files, write outside the output directory, or crash the process.
blog.devploit.dev
Published on blog.devploit.dev
A month ago, I shared on LinkedIn that MITRE had assigned me five CVEs across three npm packages. I could not share the IDs or technical details at the time.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the libraries treat attacker-controlled archive metadata and path strings as trusted, checking only string prefixes or POSIX assumptions instead of resolving and constraining the final filesystem path or allocation size.
Impact
Applications that pass untrusted archives or paths to these libraries could disclose files, write outside the extraction directory, or crash through memory exhaustion; hardlink reach is limited by filesystem and OS protections, and the adm-zip issue is bounded in 0.6.0.
What the attacker needed
Untrusted archive or path reaches the API; application reads or serves extracted files; POSIX filesystem for link demos
The fix
adm-zip was fixed in 0.6.0 by bounding the allocation to data actually present; decompress and pathe had no fixed release at the time of writing, so consumers should reject link entries, normalise once and check containment with a separator-aware check.
How it was found
- Install the vulnerable package versions in a disposable directory.
- Build a tar archive containing a hardlink, symlink or sibling-prefix entry.
- Run decompress on the archive into an output directory.
- Observe that the extracted link reads or writes a file outside the output directory.
- For adm-zip, craft a ZIP whose header claims a huge uncompressed size and request the entry data.
- For pathe, pass a backslash-based path through a POSIX-style check and then through pathe.join.
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 write-up has not been written yet. The Original tab links to the source.
These are small helper libraries that other programs use to unpack zip and tar files or to join file paths together. If a program lets a stranger upload an archive, the library may trust what is inside it and touch files it should not, or ask for a huge amount of memory. The fix is to check the real, final file path and to cap how much memory an archive can request.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.