`event-stream` dependency attack steals wallets from users of copay
https://github.com/dominictarr/event-stream/issues/116
HTTP POST traffic on port 8080 to copayapi.host (which currently resolves to 51.38.112.212 and previously resolved to 145.249.104.239) or 111.90.151.134 indicates compromised and exfiltrated wallet private keys.
Just going to aggregate other related info to help investigators:
51.38.112.212 is owned by OVH, 145.249.104.239 is owned by Liberty VPS, and 111.90.151.134 is owned by Shinjiru, a Malaysian web hosting provider.
copayapi.host's SOA record indicates the domain registrant's email address is [email protected] (sharklasers.com is a temporary/disposable email provider).
The GitHub account of the event-stream hijacker: https://github.com/right9ctrl (email address [email protected])
The NPM account of the event-stream hijacker: https://www.npmjs.com/~right9ctrl
The GitHub repo for the malicious flatmap-stream package: https://github.com/hugeglass/flatmap-stream
The NPM account of the malicious flatmap-stream package's owner: https://www.npmjs.com/~hugeglass
I believe it's likely "right9ctrl", "hugeglass", and "[email protected]" are all the same person or group of people.
Full list of network indicators (malicious infrastructure operated by the wallet thief/thieves - note that the IPs may correspond to compromised servers and may not be owned by the thieves):
- copayapi.host
- 51.38.112.212
- 145.249.104.239
- 111.90.151.134
TL;DR of https://github.com/dominictarr/event-stream/issues/116:
@nicolasnoble
So, for people who try to understand what the malicious payload is doing: it's basically crawling your dependencies for a peer dependency on the package copay-dash, and it's an attack basically crafted towards this package.
If your overall application has both this malicious package and "copay-dash", then it's going to try stealing the bitcoins stored in it.
https://github.com/dominictarr/event-stream/issues/116#issuecomment-441749105
We are investigating
Relevant: https://github.com/bitpay/copay/commit/6cc4b757f6fbd111b9716b50d645390dd1f15105#diff-32607347f8126e6534ebc7ebaec4853dL12251
Seems you were affected at one point.
Actually, looking closer at the code, it's not even trying to crawl anything. The code can ONLY work if the malicious payload is run FROM the copay package itself. This is really crafty.
Thanks a lot for the detailed help.
thankfully the code with the malicious package was not deployed in any platform. We will remove the dependency now.
We are contacting copay-dash, which is a fork of this proyect, to let them know.
==
Further examination of the code was relieved we did release some platforms with the affected code. We still investigating and communicate ASAP.
Narrowly escaped a mass theft/liquidation event. Network egress monitoring would be good to add to automated tests if not already part of the build validation process.
@atomantic: this probably wouldn't have worked. The malware was only trying to move wallets matching certain criteria. Surely they could easily have avoided the hypothetical test criteria.
@atomantic: this probably wouldn't have worked. The malware was only trying to move wallets matching certain criteria. Surely they could easily have avoided the hypothetical test criteria.
good point--if the tests are only in the open source package. I would hope BitPay has other tests that are a process wrapping these tests in a more robust release process.
Such tests would definitely require some secrecy and having them completely transparent to the attacker would be quite stupid. @atomantic how would you automate such tests? Any tools you can recommend?
Our team is investigating this issue and the extent of the vulnerability. Currently we have only confirmed that the malicious code was deployed on versions 5.0.2 through 5.1.0 of our Copay and BitPay apps. However, the BitPay app was not vulnerable to the malicious code. If you are using any version from 5.0.2 to 5.1.0, you should not run or open the Copay app. We are still investigating whether this code vulnerability was ever exploited against Copay users. A security update version (5.2.0) has been released and will be available for all Copay and BitPay wallet users in the app stores. If users do not see the updated version, please try again momentarily.
As this affects private keys, we recommend users immediately update the affected wallet and send all funds from any affected wallets to a brand new wallet on version 5.2.0 by using the Send Max feature to initiate a transaction and not by restoring using the wallet's twelve word phrase.
What is the name of the patch and are any white-label partners affected? (i.e. other wallets that use the tech branded with their names) such as Bitcoin.com?
are the legacy wallets affected? v4.8.1, v4.8.0 etc...
@sweetppro No, the old versions are not.
So does this effect iOS and Android end users of Copay app? It is unclear. There is actually code running on our iOS app the extracts private keys held iOS keychain and transmits these to a 3rd party?
Would version 5.2 on bitcoin.com's version of the copay app be the same fix described above as a security update? They patched that three days ago.
OSS should be treated with a no trust mentality when dealing with sensitive data. Strict Content Security Policies can prevent hacks that steal data and thorough E2E/unit tests can prevent hacks that mess with UX.
Hi, may you mention if this bug affect the Andriod client, the latest apk in google play store is from november 16, version 5.1.1.
Such tests would definitely require some secrecy and having them completely transparent to the attacker would be quite stupid. @atomantic how would you automate such tests? Any tools you can recommend?
I'm not an employee of BitPay but npm run test is only part of a release process. BitPay doesn't commit their Apple publisher keys to the open source library and depend entirely on an open source build/release pipeline. The publication of a new version is part of a hidden process within their secure environment. Likewise, they should have other tests that more robustly validate the integrity of module dependencies and run a production-equivalent version of the release candidate in a sandbox environment with monitors for network egress/connections (netstat, lsof, etc). If some environments/candidates can't be automated, manual testing/monitoring must be in place until automation is sufficient. Something like Charles Proxy or Little Snitch can be used to proxy network connections from an iOS/Android device and network connection attempts can be captured. This isn't nearly enough though as the malicious code could potentially see the network settings and only act if there isn't a proxy configured.
Hopefully this particular case acts as a sample of what BitPay can do in the future within their meta release validation process. The question is posed to them: what are they going to add to their process that will make BitPay and their users confident that this kind of attack will not go unnoticed before a release is put out into the wild?
Note that the malware was really sneaky, and only triggering the upload of the private keys for wallets that had genuinely over 100 BTC in there.