BitPay – Secure Bitcoin Wallet

13 minute read

Published:

Wallet Logo

This app was first launched on 1st October 2016 and currently has more than 500000 downloads, a 3.9 stars rating from 6110 users and the latest APK (version 9.3.0) was from 1st April 2020.

Our analysis was done on 29th November 2019 based on data found in their Playstore description and their website and their source repository. We discuss the issue with verification with the provider here.

We found these ways of contacting the developers:

Disclaimer

The following Analysis is not a full code review! We plan to make code reviews available in the future but even then it will never be a stamp of approval but rather a list of incidents and bad coding practice. We cannot find and tell you all the dark secrets the wallet providers might have.

Do your own research!

Try out searching for "lost bitcoins", "stole my money" or "scammers" together with the wallet's name, even if you think the wallet is generally trustworthy. For all the bigger wallets you will find accusations. Make sure you understand why they were made and if you are comfortable with the provider's reaction.

The Analysis

BitPay – Secure Bitcoin Wallet links to its source code on their Google Play app description.

Bitpay is the first wallet here that uses Angular and we are not most familiar with it. Our standard being “easily verifiable” means it is on the wallet provider to also provide clear instructions on how to build the app and the most straight forward way to well define the environment would be to explain it in code, using a Docker containers for example.

Bitpay does not advertise reproducibility for their builds and neither describes well how to build the app at all and so we are stuck after running npm install with this error message:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! secp256k1@1.1.5 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the secp256k1@1.1.5 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/name/.npm/_logs/2019-11-09T21_53_17_873Z-debug.log
[ERROR] An error occurred while running subprocess cordova.

        cordova platform add android --save exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! copay@7.1.1 prepare:copay: `npm run clean && npm run apply:copay && ionic cordova platform add ios; ionic cordova platform add android && npm run fix:fcm`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the copay@7.1.1 prepare:copay script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/name/.npm/_logs/2019-11-09T21_53_17_974Z-debug.log

which as it turns out, others are struggling with, too without much help from the provider, who closed the issue without helping.

At this point we realize, the version on Google Play, 7.1.7 is nowhere to be found in their git repository:

$ git log --grep="7.1.7"
$ git tag | grep "7.1.7"
$

Therefore for now our verdict is that Copay cannot be easily verified.

We did give compilation another try using a Cordova Docker we found here. Generally we would love to see projects share Dockerfiles with which their build instructions just worked but for now, here is what we tried:

$ docker pull beevelop/cordova:latest
me@home:~/StudioProjects/copay$ docker run --name=cordova -v /home/me/StudioProjects/copay:/mnt -it beevelop/cordova bash
root@3eae2071ceaf:/tmp# cd /mnt/
root@3eae2071ceaf:/mnt# npm install

> secp256k1@1.1.5 install /mnt/node_modules/secp256k1
> node-gyp rebuild

gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
...
root@3eae2071ceaf:/mnt# apt update ; apt install python -y
root@3eae2071ceaf:/mnt# npm install

> secp256k1@1.1.5 install /mnt/node_modules/secp256k1
> node-gyp rebuild

gyp ERR! build error
gyp ERR! stack Error: not found: make
...
root@3eae2071ceaf:/mnt# apt install make
root@3eae2071ceaf:/mnt# npm install

> secp256k1@1.1.5 install /mnt/node_modules/secp256k1
> node-gyp rebuild

make: Entering directory '/mnt/node_modules/secp256k1/build'
  CXX(target) Release/obj.target/secp256k1/functions.o
make: g++: Command not found
...
root@3eae2071ceaf:/mnt# apt install g++
root@3eae2071ceaf:/mnt# npm install
...
npm WARN lifecycle copay@8.0.4~postinstall: cannot run in wd copay@8.0.4 npm run env:dev && npm run prompt (wd=/mnt)
npm WARN @angular-devkit/build-webpack@0.12.4 requires a peer of webpack@^4.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ngtools/webpack@7.2.4 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @zxing/ngx-scanner@1.2.1 requires a peer of rxjs@^6.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN awesome-typescript-loader@5.2.1 requires a peer of typescript@^2.7 || ^3 but none is installed. You must install peer dependencies yourself.
npm WARN circular-dependency-plugin@5.0.2 requires a peer of webpack@>=4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN mini-css-extract-plugin@0.8.0 requires a peer of webpack@^4.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-barcode@0.2.4 requires a peer of @angular/core@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN terser-webpack-plugin@1.2.1 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-middleware@3.4.0 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-server@3.1.14 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 3 packages from 10 contributors and audited 76060 packages in 18.811s
found 17 vulnerabilities (7 low, 1 moderate, 9 high)
  run `npm audit fix` to fix them, or `npm audit` for details
root@3eae2071ceaf:/mnt# npm run clean-all
root@3eae2071ceaf:/mnt# npm install
root@3eae2071ceaf:/mnt# npm run apply:copay
root@3eae2071ceaf:/mnt# npm run prepare:copay
root@3eae2071ceaf:/mnt# npm run final:android
...
Checking the license for package Android SDK Platform 27 in /opt/android/licenses
Warning: License for package Android SDK Platform 27 not accepted.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Platform 27].
root@3eae2071ceaf:/mnt# $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-27"
root@3eae2071ceaf:/mnt# npm run final:android
...
45 actionable tasks: 2 executed, 43 up-to-date
Built the following apk(s):
	/mnt/platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk

> copay@8.0.4 sign:android /mnt
> rm -f platforms/android/app/build/outputs/apk/release/android-release-signed-aligned.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../copay.keystore -signedjar platforms/android/app/build/outputs/apk/release/android-release-signed.apk platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk  copay_play && $ANDROID_HOME/build-tools/28.0.3/zipalign -v 4 platforms/android/app/build/outputs/apk/release/android-release-signed.apk platforms/android/app/build/outputs/apk/release/android-release-signed-aligned.apk

Enter Passphrase for keystore:
jarsigner: you must enter key password
npm ERR! code ELIFECYCLE
npm ERR! errno 1

Although it looks bad, here we actually have what we wanted: platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk

We are not surprised to find this apk to massively differ from the one on Google Play as we were not building the (not published) correct version.

At this point we found there is a relevant commit:

$ git branch -r | grep "7.1"
  origin/v7.1
$ git checkout v7.1
Switched to branch 'v7.1'
Your branch is up to date with 'origin/v7.1'.
$ git log --grep="7.1.7"
commit 84acad445ad76e2572869d9c7bcd1eaf10764aa1 (HEAD -> v7.1, origin/v7.1)
Merge: be5809a48 685dbbb6d
Author: Matias Alejo Garcia <ematiu@gmail.com>
Date:   Thu Nov 14 16:45:11 2019 -0300

    Merge pull request #10333 from cmgustavo/bug/plugin-fcm-02

    Bump app v7.1.7 - Fix cordova-plugin-fcm

commit 685dbbb6d52f5f7db3b84c8e2fc5271b54d6e201
Author: Gustavo Maximiliano Cortez <cmgustavo83@gmail.com>
Date:   Thu Nov 14 11:33:20 2019 -0300

    Bump app v7.1.7 - Fix cordova-plugin-fcm

but compiling revision 84acad445ad76e did also result in massive differences with the version on Google Play:

BitPay diffs 1

BitPay diffs 2

this is by far not the only thing that differs

so our verdict remains: This app is not verifiable.

Above is not the whole picture of what we went through to get to this point. Here is just the command history from the Docker session:

root@3eae2071ceaf:/mnt# history
    1  cd /mnt/
    2  ll
    3  npm install
    4  apt update
    5  apt install python
    6  npm install
    7  apt install make
    8  npm install
    9  apt install g++
   10  npm install
   11  npm run clean-all
   12  npm install
   13  npm run apply:copay
   14  npm run prepare:copay
   15  git checkout v7.1.7
   16  git tag
   17  git log
   18  npm run prepare:copay
   19  npm run final:android
   20  $ANDROID_HOME/tools/bin/sdkmanager --licenses
   21  $ANDROID_HOME/tools/bin/sdkmanager update sdk --no-ui --filter android-27
   22  $ANDROID_HOME/tools/bin/sdkmanager update sdk --filter android-27
   23  $ANDROID_HOME/tools/bin/sdkmanager android-27
   24  $ANDROID_HOME/tools/bin/sdkmanager --list
   25  $ANDROID_HOME/tools/bin/sdkmanager update
   26  $ANDROID_HOME/tools/bin/sdkmanager platforms;android-27
   27  $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-27"
   28  npm run final:android
   29  ll platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk
   30  yes $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-27"
   31  yes $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-28"
   32  $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-28"
   33  $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-29"
   34  npm run final:android
   35  git checkout 84acad445ad
   36  history
   37  npm install
   38  npm run clean-all
   39  npm run apply:copay
   40  npm install
   41  npm run apply:copay
   42  history
   43  npm run prepare:copay
   44  npm run start:android
   45  history
   46  npm run final:android

With all the investigations above, this would be my build instructions:

$ docker run -v /path/to/copay:/mnt -it beevelop/cordova bash /mnt/build.sh

with this build.sh:

cd /mnt/ && \
apt update && \
apt install python make g++ -y && \
npm run clean-all && \
npm install && \
npm run apply:copay && \
npm run prepare:copay && \
yes | $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-27" && \
yes "" | npm run final:android

Other Observations

Copay has a Bug Bounty Program.

Verdict Explained

Not verifiable: The provided Open Source Code could not be verified to match the app released on Google Play

This verdict means that the provider did share some source code but that we could not verify that this source code matches the released app. This might be due to the source being released later than the app or due to the provided instructions on how to compile the app not being sufficient or due to the provider excluding parts from the public source code. In any case, the result is a discrepancy between the app we can create and the app we can find on GooglePlay and any discrepancy might leak your backup to the server on purpose or by accident.

As we cannot verify that the source provided is the source the app was compiled from, this category is only slightly better than closed source but for now we have hope projects come around and fix verifiability issues.

The app cannot be independently verified. If the provider puts your funds at risk on purpose or by accident, you will probably not know about the issue before people start losing money. If the provider is more criminally inclined he might have collected all the backups of all the wallets, ready to be emptied at the press of a button. The app might have a formidable track record but out of distress or change in management turns out to be evil from some point on, with nobody outside ever knowing before it is too late.