Skip to content
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

[Request] Support the Electron Fuse: "EnableEmbeddedAsarIntegrityValidation" #6930

Closed
Nantris opened this issue Jun 8, 2022 · 15 comments
Closed

Comments

@Nantris
Copy link

Nantris commented Jun 8, 2022

See here for more info: electron/fuses#7 (comment)

@kevinlinv
Copy link
Contributor

+1, I think support for electron/fuses would be a great addition.

FYI, there was also a closed #6365 issue that request support.

@mmaietta
Copy link
Collaborator

mmaietta commented Jul 4, 2022

Closing this one and reopening the other ticket.

@mmaietta mmaietta closed this as completed Jul 4, 2022
@Nantris
Copy link
Author

Nantris commented Jul 5, 2022

@mmaietta all the other fuses can be used without necessitating changes to Electron Builder itself. This one cannot. I think this should remain open because of that distinction.

@Nantris
Copy link
Author

Nantris commented Jul 27, 2022

From electron/fuses#7 (comment):

We're using Electron-Builder to package our app.

That would be your problem 😅. If you look at the official @electron/asar package, there is a module dedicated to generating these hashes. electron-builder, however, rolled their own ASAR creation code which doesn't have support for creating these hashes.

@mmaietta mmaietta reopened this Jul 27, 2022
@rafaberaldo
Copy link
Contributor

Would love to see this on electron-builder, Electron@30 added support for Windows machines as well.

@osztenkurden
Copy link

Is this currently on the roadmap? Given added support for Windows its kinda a big feature.

@mmaietta
Copy link
Collaborator

The only way to support this is by migrating to @electron/asar package. Unfortunately, I've tried to do so several times over the past few years and still haven't gotten to a solution that works. There's a lot of additional functionality that electron-builder relies on, such as transforming file data instead of copying a file directly. I can try and investigate this again, but can't promise anything. I'm the only maintainer on this project that remains (community contributions welcome!), so there's not really an "official" roadmap tbh, just trying to keep my head above the water with the combo of work+life outside of this project.

@mmaietta
Copy link
Collaborator

Quick update, this should officially be supported in an upcoming release once these two PRs are merged in for an alpha release
#8570 - electron/asar migration (what a PITA that was lol)
#8588 - electron/fuses integration

@mmaietta
Copy link
Collaborator

Released in v26.0.0-alpha.2. Please give it a shot!

Verified it locally (on mac build machine) that it launches with that fuse set:

npx @electron/fuses read --app dist/mac-universal/electron-quick-start-typescript.app
Analyzing app: electron-quick-start-typescript.app
Fuse Version: v1
  RunAsNode is Enabled
  EnableCookieEncryption is Disabled
  EnableNodeOptionsEnvironmentVariable is Enabled
  EnableNodeCliInspectArguments is Enabled
  EnableEmbeddedAsarIntegrityValidation is Enabled
  OnlyLoadAppFromAsar is Disabled
  LoadBrowserProcessSpecificV8Snapshot is Disabled

@osztenkurden
Copy link

Gonna test in a few hours, doing the gods work here, thank you! @mmaietta

@osztenkurden
Copy link

osztenkurden commented Oct 14, 2024

Hmm, while packaging works fine, I'm getting Integrity check failed for asar archive when trying to run the app

Edit: it seems like adding afterPack script with asarmor breaks, but also not cleaning the dist directory

@mmaietta
Copy link
Collaborator

mmaietta commented Oct 14, 2024

Hmmm yeah, from a quick read of asarmor, it's modifying the asar, which then causes the integrity generated/recorded by electron/asar to no longer be valid.

Can you try force setting resetAdHocDarwinSignature in electronFuses config to true?

Alternatively, you can play around with @electron/fuses in your afterPack via a convenience method I opened up as part of the integration for those that want to leverage strictlyRequireAllFuses: true to make sure their fuse config stays up to date. This approach replaces usage of electronFuses (so set it undefined/null)

const { FuseConfig, FuseVersion, FuseV1Options } = require("@electron/fuses")

exports.default = function (context: AfterPackContext) {
   // asarmor logic

  const fuses: FuseConfig = {
    version: FuseVersion.V1,
    resetAdHocDarwinSignature: true
    [FuseV1Options. EnableEmbeddedAsarIntegrityValidation]: true,
    ... // all other flags must be specified if `strictlyRequireAllFuses = true`
  }
  await context.packager.addElectronFuses(context, fuses)
}

I'm wondering if you need the resetAdHocDarwinSignature flag set.

@osztenkurden
Copy link

@mmaietta That doesnt do the trick, maybe because Im on windows, but its not huge deal

@mmaietta
Copy link
Collaborator

Dam. Well it looks like asarmor is the issue as it manipulates the asar post electron/asar integrity generation since asarmor is injecting random bytes into the asar to prevent extraction.

An alternative approach could be using bytenode to obfuscate your code. It doesn't disable extraction like asarmor, but it doesn't require any asar manipulation either.

@osztenkurden
Copy link

Ill take a look, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants