specter-desktop/pyinstaller
Sergev ₱ 2c8e5533a0
Patched Fix Electron vulnerable to out-of-package code execution when launched with arbitrary cwd (#2380)
This project used electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS. Affected of this project are vulnerable to Arbitrary Code Execution allowing out-of-package code execution when apps are launched as command-line executables.

```diff
diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js
- index 5a50d5d6afab6e6648f72a1c0efa1df4cd80bcd9..0be45309028b00a6957ee473322a9452a7fa7d67 100644
--- a/lib/internal/modules/run_main.js
+ +++ b/lib/internal/modules/run_main.js
@@ -13,6 +13,12 @@ const {
```
CWE-94
`CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:L/I:H/A:L`
CVE-2023-39956

Co-authored-by: k9ert <k9ert@gmx.de>
2023-09-19 13:48:22 +02:00
..
bitcoind Upgrade internal bitcoind version (#1173) 2021-05-24 13:44:03 +02:00
electron Patched Fix Electron vulnerable to out-of-package code execution when launched with arbitrary cwd (#2380) 2023-09-19 13:48:22 +02:00
hooks Feature: Extension Framework upgrade incl. middleware, extensionsdependencies and -callbacks (#2186) 2023-02-11 11:21:31 +01:00
tor Chore: shrink tor binaries (#2255) 2023-02-27 17:07:24 +01:00
windll Pyinstaller builds (#258) 2020-07-26 11:20:13 +02:00
build-ci.sh build-ci.sh fix 2022-01-27 18:14:06 +01:00
build-win-ci.bat Chore: shrink tor binaries (#2255) 2023-02-27 17:07:24 +01:00
build-win.bat Bugfix: Final Swan service updates (#1533) 2022-01-24 14:47:26 +01:00
hwibridge.py backup files on write (#542) 2020-10-26 12:47:54 +01:00
hwibridge.spec Fix release issue with embit (#1372) 2021-08-27 10:37:14 -05:00
README.md Docs: added necessary command to build instructions (#1808) 2022-07-18 18:56:03 +02:00
requirements.in Chore: Upgrade to python 3.10 (#1688) 2022-09-13 10:44:49 +02:00
requirements.txt Chore: Upgrade to python 3.10 (#1688) 2022-09-13 10:44:49 +02:00
specterd.py Feature: Better Error-management, logging for the APP and Macos builds improvements (#1405) 2021-09-27 14:09:43 +02:00
specterd.spec Chore: shrink tor binaries (#2255) 2023-02-27 17:07:24 +01:00

Build scripts

Run build-<your-os> <version_number> file to build everything.

For example, build-osx.sh 1.2.3 will create SpecterDesktop-1.2.3.dmg and specterd-1.2.3-osx.zip in the release folder.

If you're making a real release, you should append "make hash" at the end of your command calling the build script. This will update the file hash and version name the Specter Desktop app expects to download from GitHub.

Pyinstaller build

Install requirements:

virtualenv --python=python3 .buildenv
source .buildenv/bin/activate 
pip3 install -r requirements.txt --require-hashes
cd pyinstaller
pip3 install -r requirements.txt --require-hashes

Now run:

pyinstaller specterd.spec

And for HWIBridge, run:

pyinstaller hwibridge.spec

Code signing the macOS app for Apple GateKeeper

Note: for this, you'll need to have an active Apple Developer account

If this is the first time you go through this process, you'll need to first set up the following:

Apple Developer Certificate for Code-Signing

  1. Go to the Apple Developer website: https://developer.apple.com
  2. Click Account -> Certificates, Identifiers & Profiles
  3. Click the + icon to create a new certificate. Select Developer ID Application and click Continue
  4. You'll need now to create a certificate signing request, which you can do by following these instructions: https://help.apple.com/developer-account/#/devbfa00fef7, After that you should be able to generate and download the certificate.
  5. Download the certificate, then double-click the downloaded certificate to install it in your keychain.

App Specific Password for authenticating to iTunesConnect for notarization

  1. Sign into you Apple ID account: https://appleid.apple.com
  2. Go to Security -> App Specific Passwords and click Generate Password…, you'll be asked to enter a label and click Create, then you'll receive a new password.
  3. Copy the password generated, then open the Terminal and run:
xcrun altool --store-password-in-keychain-item "AC_PASSWORD" -u "<your-apple-id>" -p "<the-generated-password>"

After having these set up, you can use the automated script to sign by passing it 2 extra parameters:

  • Your certificate name, which you can see on the Keychain app going to the sidebar -> My Certificates and copying the name of the certificate you've created in step 1.
  • Your Apple ID.

With these two, you can run the command like so:

./build-osx.sh <version_number> "<certificate_name>" "<apple_id>" "make-hash"

Note: "make-hash" is optional and will automatically calculate hash of specterd generated for the macOS app. Should be used only for real release.

This should take 10 minutes, during which you should receive an email from Apple notifying whatever the notarization was successful. If for some reason the notarization failed, you'll be able to get the reason by copying the Request Identifier (you should be able to find this in the email and in the logs). Then run the following command:

xcrun altool --verbose --notarization-info <request_identifier> -u "<apple_id>" -p "@keychain:AC_PASSWORD"

This will output a long message, at the end of which you should have be able to find the LogFileURL:. This URL should contain a JSON with the issues found by Apple and which you'll need to fix to be able to pass Apple's notarization.