Unlucky Linux boxes trampled by NPM code update, patch zapped

Devs stumble into pre-release beta by using command they didn't understand

By Thomas Claburn in San Francisco


NPM – the biz behind the Node.js package management software used to wrangle JavaScript code and various related frameworks – on Thursday undid a code update less than 24 hours after it was issued because the software was messing with Linux file permissions.

The release of npm 5.7.0 on Wednesday – under the company's pre-release next distribution tag rather than its latest distribution tag – prompted reports of server crashes, application failures, and other undesirable behavior for users of some Linux distributions.

The issue was not particularly widespread. To be affected, NPM told The Register, users had to download the software using the npm update npm -g command rather than the more common npm install npm -g command.

About 4,000 individuals, or 0.6 per cent of installs, did so during the 21 hours or so that the subpar update was available.

And then those affected had to be running one of several Linux distributions and had to execute the update command with sudo, a significantly smaller subset of the susceptible group.

Nonetheless, a GitHub Issues post highlighting the mayhem made it sound like a disaster.

Developer Jared Tiala kicked the discussion off by noting the issue "seems to have completely broken my filesystem permissions and caused me to have to manually fix the permissions of critical files and folders."

Tiala pegged the problem to running the sudo command as a non-root user.

NPM via Twitter acknowledged the issue, noting, "We’ve reverted a patch that could cause ownership changes on some system files."

In its Thursday blog post, the code biz explained, "The original patch was added to increase consistency and reliability of methods npm uses to avoid writing files as root in places it shouldn't, but the change was applied in places that should have used regular mkdirp. This release reverts that patch."

In a phone interview with The Register, Laurie Voss, COO and cofounder of NPM, explained the intent with the withdrawn revision was to make npm handle permissions in a safer way by moving away from mkdirp. But, he said, doing so across the entire code base turned out to be not always appropriate.

mkdirp is a Node.js version of the Unix mkdir command, which, with the -p flag, creates new directories and necessary parent directories that may not yet exist.

The Oakland-based company insists only those participating in its staggered release system would receive code with the distribution tag "next," which is intended to prevent bugs like this from affecting everyone.

Bugs of this sort might be expected from pre-release code but some users of the software contend they were unaware the release was unstable. Allegedly, email notifications went out about the update without making it adequately clear that the release wasn't cleared for public consumption.

In the litany of complaints littering the GitHub Issues thread, doubts about the consistency of NPM's distribution mechanism abound. There's also a fair amount of blaming those affected for not knowing better.

Voss said that while users should not be blamed, there is a misunderstanding of how npm update differs from npm install.

"NPM intends to change the behavior of npm update in global mode to be less confusing to users," said Voss. "It’s absolutely true that the behavior of update -g is poorly understood." ®

Sign up to our NewsletterGet IT in your inbox daily


More from The Register

Hackers seed StatCounter with nasty JavaScript in elaborate Bitcoin cyber-heist caper

Updated exchange believed to be target of embedded attack

How evil JavaScript helps attackers tag possible victims – and gives away their intent

Countdown to ancient IE a telltale sign of malice

Oracle demands dev tear down iOS app that has 'JavaScript' in its name

Ordinary folk may be confused by title, takedown demand suggests

StatCounter fingers cache-poisoning caper for Bitcoin-slurping JavaScript hijack

The good news? Nobody appears to have lost any Bitcoin, says

Google logins make JavaScript mandatory, Huawei China spy shock, Mac malware, Iran gets new Stuxnet, and more

Roundup Plus, SystemD gets system de-bugged, again

One-in-two JavaScript project audits by NPM tools sniff out at least one vulnerability...

...and those devs are then applying patches, we hope

Talk about a cache flow problem: This JavaScript can snoop on other browser tabs to work out what you're visiting

Special report Yes, even the Tor browser can be spied on by this nasty code

Next; tech; meltdown..? Mandatory; semicolons; in; JavaScript; mulled;

Punctuation-averse devs, you're coding it wrong

'No, we are not rewriting Office in JavaScript' and other Microsoft tales

The week's good, bad and weird from Redmond

CSS and Javascript on GOV.UK page take early Christmas holiday

Updated El Reg asks why; they magically reappear. Fancy that!