#electron #security #command-line #command-line-tool #hardening

bin+lib electron-hardener

Utility to remove features from Electron that modify runtime behavior

4 releases

0.2.2 Sep 22, 2021
0.2.1 Jun 2, 2021
0.2.0 Jun 1, 2021
0.1.0 Apr 23, 2021

#763 in Filesystem

Download history 10344/week @ 2023-12-13 4185/week @ 2023-12-20 4014/week @ 2023-12-27 12901/week @ 2024-01-03 12241/week @ 2024-01-10 15714/week @ 2024-01-17 12956/week @ 2024-01-24 13210/week @ 2024-01-31 12924/week @ 2024-02-07 15340/week @ 2024-02-14 21419/week @ 2024-02-21 19789/week @ 2024-02-28 22239/week @ 2024-03-06 15724/week @ 2024-03-13 23584/week @ 2024-03-20 14940/week @ 2024-03-27

80,170 downloads per month

MIT/Apache

35KB
578 lines

electron-hardener

crates.io version crate documentation MSRV crates.io downloads CI

A Rust library and command line tool to harden Electron binaries against runtime behavior modifications.

This provides a way to harden Electron applications against a specific class of runtime behavior modification. Specifically, if an unprivileged process can't write to the application's binary file or process address space, it should not be able to change what an app does at runtime.

The library provides two sets of functionality:

  • An interface to view and modify the status of fuses in an application, similar to the official fuses package.
  • A fast and configurable alternative implementation of the electron-evil-feature-patcher tool created by Dimitri Witkowski. All patches it can perform are also exposed in this crate. See its README for more details on how it works.

Usage

Library

The library exposes a simple and configurable interface:

use electron_hardener::{ElectronApp, Fuse, NodeJsCommandLineFlag};

let mut app = ElectronApp::from_bytes(&mut application_bytes)?;

app.set_fuse_status(Fuse::RunAsNode, false)?;

app.patch_option(NodeJsCommandLineFlag::Inspect)?;

Check out the command line tool's source or the example to see more ways to use it.

Command line tool

The command line tool exposes the same functionality and interface as electron-evil-feature-patcher:

electron-hardener ./path/to/packaged/electron/app

Install

Library

In your project's Cargo.toml file:

electron_hardener = "0.1"

Command line tool

Make sure you have a Rust compiler installed and then run

cargo install electron-hardener

Electron compatibility

electron-harder tracks the latest stable version of Electron. Functionality is currently tested on a minimum version of Electron 15. Older versions may partially work but this is not guaranteed.

MSRV

The Minimum Supported Rust Version is currently 1.46.0. This will be bumped to the latest stable version of Rust when needed.

Credits

Made with ❤️ by the 1Password team, with full credits to Dimitri Witkowski for taking the time and effort to discover the command line flags that can be disabled, and finally creating the original tool which served as inspiration for this project.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~2.8–4MB
~67K SLoC