How NPM’s Binary Planting Bug Lets Attackers Access Any File

The article explains two critical npm vulnerabilities—arbitrary file access via a crafted bin field and binary planting that lets globally installed packages replace executables—detailing their impact, how they can be exploited, and urging users to upgrade promptly.

Node Underground
Node Underground
Node Underground
How NPM’s Binary Planting Bug Lets Attackers Access Any File

On December 11, 2019, the npm team blog issued a security warning about “binary injection” affecting npm versions prior to v6.13.3 and v6.13.4.

Arbitrary File Access

The vulnerability allows a package publisher to craft a malicious entry in the bin field that can read or modify any file on the user’s system.

If exploited, a malicious package combined with social engineering—such as replacing a package with a mining script or abusing lockfile attacks—could cause severe damage.

Although npm did not disclose full details, analysis of the commit history of read-package-json shows that relative paths can be used to access resources.

Binary Planting

The second vulnerability permits globally installed packages to replace any executable file in the installation directory.

Global packages typically create symlinks in system directories like /usr/local/bin. While this does not grant arbitrary file access, it can be more damaging because the malicious executable persists and runs on each invocation. For example, a compromised ssh command could leak login credentials.

Testing npm’s test cases can help understand the details; interested readers can follow the links in the “Related Reading” section.

Although npm has not observed any exploited packages yet, it advises users to upgrade promptly.

securityVulnerabilitynodejsnpmPackage Managementbinary planting
Node Underground
Written by

Node Underground

No language is immortal—Node.js isn’t either—but thoughtful reflection is priceless. This underground community for Node.js enthusiasts was started by Taobao’s Front‑End Team (FED) to share our original insights and viewpoints from working with Node.js. Follow us. BTW, we’re hiring.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.