-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
event-stream
dependency attack steals wallets from users of copay
#9346
Comments
HTTP POST traffic on port 8080 to Just going to aggregate other related info to help investigators:
The GitHub account of the The NPM account of the The GitHub repo for the malicious The NPM account of the malicious 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):
|
TL;DR of dominictarr/event-stream#116:
|
We are investigating |
Relevant: bitpay/copay@6cc4b75#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 == 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. |
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. |
This fix removes a dependency on event-stream introduced by nodemon via pstree by bumping nodemon and pstree.remy through nodemon to a verson that does not include pstree. The [event-stream issue](dominictarr/event-stream#116) appears to have specifically targeted [copay](https://github.com/bitpay/copay/issues/9346) which does appear to have caught the issue before anything was deployed. We encourage all users of Reaction Commerce to update.
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? |
This fix removes a dependency on event-stream introduced by `nodemon` via `pstree` by bumping `nodemon` and `pstree.remy` through `nodemon` to a version that does not include `pstree`. [event-stream](dominictarr/event-stream#116) had a malicious bit of code added to version `3.3.6` which has since been removed from github and appears to have specifically targeted [copay](https://github.com/bitpay/copay/issues/9346). From the original post in the `event-stream` repo: > **Am I affected?:** > If you are using anything crypto-currency related, then maybe. As discovered by @maths22, the target seems to have been identified as copay related libraries. It only executes successfully when a matching package is in use (assumed to by copay at this point). If you are using a crypto-currency related library and if you see [email protected] after running npm ls event-stream flatmap-stream, you are most likely affected. For example: > ``` > $ npm ls event-stream flatmap-stream > ... > [email protected] > ... > ``` > **What does it do**: > Other users have done some good analysis of what these payloads actually do. > dominictarr/event-stream#116 (comment) > dominictarr/event-stream#116 (comment) > dominictarr/event-stream#116 (comment) > **What can I do:** > By this time fixes are being deployed and npm has yanked the malicious version. Ensure that the developer(s) of the package you are using are aware of this post. If you are a developer update your event-stream dependency to [email protected]. This protects people with cached versions of event-stream. See the issue on the `event-stream` repo for more information: dominictarr/event-stream#116
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. 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 |
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? |
@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. |
I'm not an employee of BitPay but 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. |
Perhaps a good first step in testing dependency upgrades is to look for the new appearance of high-entropy blobs, the inclusion of crypto, new dependency additions to sub-dependencies. This is a seemingly innocuous commit from a raw code perspective: dominictarr/event-stream@e316336 However, if the build validation paused for a human to examine and approve why a dependency was added to the chain, they would have deduced that this looks super fishy and shouldn't be trusted. Additionally, this update added a large high-entropy blob (note: a future attacker could break this up into tiny blobs and join them). |
So when the new version is going to be available in app store? You say that we need to move funds asap to a brand new wallet on updated version but it’s still not available. |
I put more info about the malicious code in this thread dominictarr/event-stream#116 (comment) final result is:
|
@mshanx Copay have been submitted already, there should be available soon. There are available already in some platforms. You can import your seed on Bitpay Wallet app & access your wallet there. Also, we have reported and taken down the endpoints where the malicious code post the data, so they are not working now. @atomantic Thanks for your comments and suggestions. We will be taking multiple measures to mitigate future issues like this one. The dependencies problem on node.js is a huge problem and many projects are facing issues like this. Almost 4000 projects were "infected" just to access Copay. On the other hand, trying to build a competitive app, GUI-wise, multiplatform not using JS seems impossible. Some of the measures we are doing:
thanks, matías |
@matiu I like the idea of 3. Create a new app, with very few dependencies, to sign TXs. |
JFYI, Copay v5.2.2 is already available on Android (https://play.google.com/store/apps/details?id=com.bitpay.copay&hl=en), iOs and all platforms. |
The problem will remain if those tests are public and the project has dependencies on 3rd party submitters - automatic testing cannot be trusted. The offending code can be made to not activate under the tests and rather easily at that if the tests are public. The core of the problem is trusting hundreds of 3rd party maintainers to stay straight. The only reasonable action would be to work to remove the dependencies(possibly fork known good versions of them). For me the 1) and 3) are the reasonable things to do. When any of the dependencies change, go through the changes manually, if they are not relevant/necessary not include the updates. In addition to just go through the dependencies to remove any that are so small as to just include in the main project, just to lower the amount of people that need to be trustworthy. Restricting network access within the dependencies of the app is very hard to do practically as is only allowing access to storage from certain code parts(in a fashion that you could trust it). |
@lassikin regarding 2), in the just released 5.3.0 we will be using CSP to restrict network access to whitelisted sites (bitpay backend and a couple of affiliates). CSP should be a secure method to prevent network access to all JS code in the app, do you have any commment on that? thanks. |
|
I think network egress monitoring is really important during end-to-end automated tests and build process. I have implemented a way to automatically discover and restrict outbound traffic during GitHub Actions workflow runs. It can detect DNS exfiltration as well. If it sounds interesting, please try it out. You can try a hands-on tutorial here: https://github.com/step-security/supply-chain-goat/blob/main/RestrictOutboundTraffic.md |
@varunsh-coder what about if the egress isn't happening on-install or on initialization but has a built-in clock delay for say 3 weeks in? or some other form of delay? |
Good point! In fact, not just time delay, it could also be based on a different condition. Example in the Having said that, there is always a chance that the attacker may send outbound call during reconnaissance (while the exploit is being developed) or make a mistake in the condition logic, and it may get caught in the automated (end-to-end) tests. It makes the attacker's job harder, which is a good thing. So, this method doesn't make attacks impossible but more improbable and more difficult. |
Don't get me wrong, I think this is a great idea and for the threat model of build-time, an immediate network egress request monitoring makes a lot of sense. |
dominictarr/event-stream#116
The text was updated successfully, but these errors were encountered: