Repository navigation
feat: Electron Fuses, package time feature toggles - #24241
Merged
Merged
Conversation
nornagon
reviewed
Jun 22, 2020
MarshallOfSound
force-pushed
the
fuses
branch
2 times, most recently
from
June 22, 2020 22:10
602a28c to
e7bc95c
Compare
3 tasks done
nornagon
reviewed
Jun 24, 2020
nornagon
reviewed
Jun 24, 2020
nornagon
reviewed
Sep 28, 2020
|
|
||
| dir_path = os.path.dirname(os.path.realpath(__file__)) | ||
|
|
||
| SENTINEL = "dL7pKGdnNz796PbbjQWNKmHXBZaB9tsX" |
Contributor
There was a problem hiding this comment.
. o O ( instead of using this sentinel, could we export this as a symbol and then parse ELF/PE/mach-o to directly find the location? )
nornagon
reviewed
Oct 2, 2020
Co-authored-by: Jeremy Rose <[email protected]>
nornagon
approved these changes
Oct 6, 2020
Co-authored-by: Jeremy Rose <[email protected]>
|
Release Notes Persisted
|
|
Hi Team, We tried to follow the instruction for installing the library "fuses" to our electron project? Thank you very much for feedback! Best regards, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem Statement
Certain features or Electron are undesirable for specific deployments / environments and although they can be disabled / not-utilized at the app level certain security models take account for user-level code execution. E.g. Being able to run electron apps with
ELECTRON_RUN_AS_NODEand just get a node binary is not-ideal. We want a way to toggle certain features in a way that both doesn't require app developers to build Electron in-house and ensures that OS level app integrity / code-signing protection (gatekeeper / app-locker) correctly prevent modification of these toggles.Solution: Electron Fuses
Utilizing a known address / section of the app binary we can create a series of "fuses" (toggles) that can be overwritten after Electron has been built into a
.app/.exe. These can be overwritten by writing raw data to the correct address in the binary. In order to locate this known address we use a fixed sentinel string that is guaranteed to directly prefix the fuses.The format of this string is
{sentinel}{fuse_version}{...fuses}.This allows packaging tools to find the sentinel, and then know that the next byte is the fuse version and each sequential byte is a fuse. The
fuse_versionshould be used to determine what each fuse is and how many there are. A handy tool@electron/fuseswill be built to abstract away most of this complexity for developers.Example use cases
This PR implements one use case (disabling
ELECTRON_RUN_AS_NODE), other potential use cases which could be implemented in the future using this system.--disable-sandbox,--remote-debugging-port, etc.)app,app.asar,default_app.asarload path search and enforce only one of those is ever searchedsandbox,contextIsolation, etc.)Implementation Details
Adding a new fuse is as easy as adding a new key to the
fuses.jsonfile, the fuse implementation is automatically generated as part of the build step so if you add a newfoo_thing_enabledfuse a new methodelectron::fuses::IsFooThingEnabled()will automatically exist.To Do
@electron/fusesfor controlling the fuses at the packaging phaseNotes: Implemented Electron Fuses for customizing certain Electron features at package time.