Hacker backdoors popular JavaScript library to steal Bitcoin funds

Users of BitPay's Copay desktop and mobile wallet apps are affected. An update has been released earlier today that doesn't contain the malicious code.
Written by Catalin Cimpanu, Contributor

A hacker has gained (legitimate) access to a popular JavaScript library and has injected malicious code that steals Bitcoin and Bitcoin Cash funds stored inside BitPay's Copay wallet apps.

The presence of this malicious code was identified last week, but only today have researchers been able to understand what the heavily obfuscated malicious code actually does.

The library loading the malicious code is named Event-Stream, a JavaScript npm package for working with Node.js streaming data.

Also: Young women dominate in software, but still face setbacks CNET

This is an extremely popular JavaScript library, with over two million weekly downloads on the npmjs.com repository, but about three months ago, its original author, due to a lack of time and interest, handed its development over to another programmer named Right9ctrl.

But according to an eagle-eyed user who spotted issues with Event-Stream last week, Right9ctrl had immediately poisoned the library with malicious code.

Right9ctrl released Event-Stream 3.3.6 which contained a new dependency --for the Flatmap-Stream library version 0.1.1. The Flatmap-Stream library v0.1.1 is where the malicious code resides.

According to users on Twitter, GitHub, and Hacker News, this malicious code lays dormant until it's used inside the source code of Copay, a desktop and mobile wallet app developed by Bitcoin payment platform BitPay.

Once the malicious code has been compiled and shipped inside poisoned versions of the Copay wallet app, it will steal users' wallet information, including private keys, and send it to the copayapi.host URL on port 8080.

It is believed that the hacker is using this information to empty victims' wallets. In a blog post, the Copay team said all versions between 5.0.1 and 5.1.0 were officially deemed infected, and urged users to update to version 5.2.0 or later.

Maintainers of the npmjs.com JavaScript package repository have also intervened and taken down the Flatmap-Stream library from their site, making it inaccessible to all the projects where this was being loaded via the npm package installer utility.

The malicious Event-Stream v3.3.6 has also been taken down from npmjs.com, but the Event-Stream library is still available. This is because Right9ctrl, in an attempt to hide his malicious code, released subsequent versions of Event-Stream that didn't contain any malicious code.

Project maintainers who use these two libraries are advised to update their dependency trees to the latest version available --Event-Stream version 4.0.1. This link contains a list of all the 3,900+ JavaScript npm packages where Event-Stream is loaded as a direct or indirect dependency.

This manual update/removal step is necessary as some projects are configured to cache all dependencies locally, and might not trigger the usual console error when attempting to download a non-existent npm package from npmjs.com when building a new project version.

This is not the first JavaScript/npm-related security issue that has taken place in the past years. In July this year, a hacker compromised the ESLint library with malicious code that was designed to steal the npm credentials of other developers.

Also: The 10 languages developers use most in open source projects TechRepublic

In May 2018, a hacker tried to hide a backdoor in another popular npm package named getcookies.

In August 2017, the npm team removed 38 JavaScript npm packages that were caught stealing environment variables from other projects, in an attempt to collect project-sensitive information, such as passwords or API keys.

Update on November 27, 03:00am ET: Updated to add link to Copay's blog post.

These are the worst hacks, cyberattacks, and data breaches of 2018


Editorial standards