-
Notifications
You must be signed in to change notification settings - Fork 71
Home
Electronegativity is a tool to identify misconfigurations and security anti-patterns in Electron-based applications. It leverages AST and DOM parsing to look for security-relevant configurations, as described in our Electron Security Checklist - A Guide for Developers and Auditors white-paper.
The Electron security white-paper introduces a checklist of security anti-patterns and must-have features to illustrate misconfigurations and vulnerabilities in Electron-based applications. Software developers and security auditors can benefit from this document as it provides a concise, yet comprehensive, summary of potential weaknesses and implementation bugs when developing applications using Electron. Based on this study, we developed Electronegativity to automate the discovery of those security anti-patterns.
It is important to remember that the security of your Electron application is the result of the overall security of the framework foundation (Chromium, Node.js), Electron itself, all NPM dependencies and your code. In addition to all application code vulnerabilities potentially discovered by this tool, it is your responsibility to follow a few important best practices:
-
Keep your application up-to-date with the latest Electron framework release. When releasing your product, you’re also shipping a bundle composed of Electron, Chromium shared library and Node.js. Vulnerabilities affecting these components may impact the security of your application. By updating Electron to the latest version, you ensure that critical vulnerabilities (such as nodeIntegration bypasses) are already patched and cannot be exploited in your application.
-
Evaluate your dependencies. While NPM provides half a million reusable packages, it is your responsibility to choose trusted 3rd-party libraries. If you use outdated libraries affected by known vulnerabilities or rely on poorly maintained code, your application security could be in jeopardy.
-
Adopt secure coding practices. The first line of defense for your application is your own code. Common web vulnerabilities, such as Cross-Site Scripting (XSS), have a higher security impact on Electron applications hence it is highly recommended to adopt secure software development best practices and perform security testing.
While installing and using Electronegativity is fairly easy, the following section covers some of the details around the tool command line arguments and internal heuristics.
To get Electronegativity up and running, it's possible to use NPM since major releases are pushed to the repository:
$ npm install @doyensec/electronegativity -gAt this stage, the tool can be invoked by using the following command line:
$ electronegativity -i [TARGET]Where [TARGET] is either the application source code directory, a single JavaScript file (.js), a single HTML file (.html), or an application ASAR package (.asar). In case of single files, the tool will only invoke checks that are relevant for the target. Please note that it is also possible to use wildcard * characters.
Since the tool can be used on both source code and application packages, it is easy to perform testing on both open-source and commercial applications.
In addition to the mandatory -i [TARGET] command line argument, the user can also specify the following options:
-
-o, --output This is used for selecting a different output type. By default, the application uses standard terminal output to display results in a compacted table. The user can select Comma-Separate file (CSV) or Sarif (SARIF) to obtain a more detailed description of the findings. SARIF stands for Static Analysis Results Interchange Format and it defines a standard format for the output of static analysis tools.
-
-c, --checks By default, the tool will run all checks on the target file(s). However, the user may be interested in specific classes of vulnerabilities only thus it is possible to select a list of checks (comma-separated) to be used. Checks are defined by its name (e.g. CSPJSCheck).
Electronegativity currently implements the following checks:
- AllowPopupCheck.js - ALLOWPOPUPS_HTML_CHECK
- AuxclickJSCheck.js - AUXCLICK_JS_CHECK
- AuxclickHTMLCheck.js - AUXCLICK_HTML_CHECK
- BlinkFeaturesJSCheck.js - BLINK_FEATURES_JS_CHECK
- BlinkFeaturesHTMLCheck.js - BLINK_FEATURES_HTML_CHECK
- CertificateErrorEventJSCheck.js - CERTIFICATE_ERROR_EVENT_JS_CHECK
- CertificateVerifyProcJSCheck.js - CERTIFICATE_VERIFY_PROC_JS_CHECK
- ContextIsolationJSCheck.js - CONTEXT_ISOLATION_JS_CHECK
- CustomArgumentsJSCheck.js - CUSTOM_ARGUMENTS_JS_CHECK
- CSPGlobalCheck.js - CSP_GLOBAL_CHECK
- DangerousFunctionsJSCheck.js - DANGEROUS_FUNCTIONS_JS_CHECK
- ElectronVersionJSCheck.js - ELECTRON_VERSION_JSON_CHECK
- ExperimentalFeaturesHTMLCheck.js - EXPERIMENTAL_FEATURES_HTML_CHECK
- ExperimentalFeaturesJSCheck.js - EXPERIMENTAL_FEATURES_JS_CHECK
- HTTPResourcesJSCheck.js - HTTP_RESOURCES_JS_CHECK
- HTTPResourcesHTMLCheck.js - HTTP_RESOURCES_HTML_CHECK
- InsecureContentHTMLCheck.js - INSECURE_CONTENT_HTML_CHECK
- InsecureContentJSCheck.js - INSECURE_CONTENT_JS_CHECK
- NodeIntegrationHTMLCheck.js - NODE_INTEGRATION_HTML_CHECK
- NodeIntegrationAttachEventJSCheck.js - NODE_INTEGRATION_ATTACH_EVENT_JS_CHECK
- NodeIntegrationJSCheck.js - NODE_INTEGRATION_JS_CHECK
- OpenExternalJSCheck.js - OPEN_EXTERNAL_JS_CHECK
- PermissionRequestHandlerJSCheck.js - PERMISSION_REQUEST_HANDLER_JS_CHECK
- PreloadJSCheck.js - PRELOAD_JS_CHECK
- ProtocolHandlersJSCheck.js - PROTOCOL_HANDLER_JS_CHECK
- SandboxJSCheck.js - SANDBOX_JS_CHECK
- WebSecurityHTMLCheck.js - WEB_SECURITY_HTML_CHECK
- WebSecurityJSCheck.js - WEB_SECURITY_JS_CHECK
This content is used within the tool to document findings and mitigations.