# Diving Into Electron Web API Permissions

DevFeed: [Diving Into Electron Web API Permissions](<https://devfeed.tech/articles/diving-into-electron-web-api-permissions-92017.md>)

Original publisher: [Read original article](<https://blog.doyensec.com/2022/09/27/electron-api-default-permissions.html>)

Published: 2022-09-26T22:00:00Z

Content type: article

Language: en

Sources: [Doyensec](<https://devfeed.tech/sources/doyensec.md>)

Topics: [Electron](<https://devfeed.tech/topics/electron.md>), [Access Control](<https://devfeed.tech/topics/access-control.md>), [XSS](<https://devfeed.tech/topics/xss.md>)

Tags: [app-permissions](<https://devfeed.tech/tags/app-permissions.md>), [auditing](<https://devfeed.tech/tags/auditing.md>), [automation](<https://devfeed.tech/tags/automation.md>), [doyensec](<https://devfeed.tech/tags/doyensec.md>), [doyensecurity](<https://devfeed.tech/tags/doyensecurity.md>), [electron](<https://devfeed.tech/tags/electron.md>), [exploit](<https://devfeed.tech/tags/exploit.md>), [hacking](<https://devfeed.tech/tags/hacking.md>), [infosec](<https://devfeed.tech/tags/infosec.md>), [offensive](<https://devfeed.tech/tags/offensive.md>), [pentest](<https://devfeed.tech/tags/pentest.md>), [pentester](<https://devfeed.tech/tags/pentester.md>), [permissions](<https://devfeed.tech/tags/permissions.md>), [reverse-engineering](<https://devfeed.tech/tags/reverse-engineering.md>), [security](<https://devfeed.tech/tags/security.md>), [security-and-privacy](<https://devfeed.tech/tags/security-and-privacy.md>), [vulnerability](<https://devfeed.tech/tags/vulnerability.md>), [web-api](<https://devfeed.tech/tags/web-api.md>)

## AI overview

Electron's default permission handling can expose sensitive web APIs to a compromised renderer. The excerpt reports that webcam and microphone access, clipboard reading, notifications, idle detection, and local font access are granted by default; local font access bypasses the main-process permission handler. Electron groups camera, microphone, and media capture under one "media" permission, while screen recording also requires a source configured through desktopCapturer. Electron permits enumeration of media devices even when access is denied. File reads are granted after a user selects a file or directory, without Chrome's access notice or restrictions on sensitive locations; file writes are always denied. The article recommends denying permissions by default with a Session permission handler, allowing only needed requests after checking the origin, and resetting the handler to null so previously granted permissions are requested again.

## Source excerpt

Introduction When a Chrome user opens a site on the Internet that requests a permission, Chrome displays a large prompt in the top left corner. The prompt remains visible on the page until the user interacts with it, reloads the page, or navigates away. The permission prompt has Block and Allow buttons, and an option to close it. On top of this, Chrome 98 displays the full prompt only if the permission was triggered "through a user gesture when interacting with the site itself". These precautionary measures are the only things preventing a malicious site from using APIs that could affect user privacy or security. Since Chrome implements this pop-up box, how does Electron handle permissions? From Electron's documentation: "In Electron the permission API is based on Chromium and implements the same types of permissions. By default, Electron will automatically approve all permission requests unless the developer has manually configured a custom handler. While a solid default, security-conscious developers might want to assume the very opposite." This approval can lead to serious security and privacy consequences if the renderer process of the Electron application were to be compromised via unsafe navigation (e.g., open redirect, clicking links) or cross-site scripting. We decided to investigate how Electron implements various permission checks to compare Electron's behavior to that of Chrome and determine how a compromised renderer process may be able to abuse web APIs. Webcam, Microphone, and Screen Recording Permissions The webcam, microphone, and screen recording functionalities present a serious risk to users when approval is granted by default. Without implementing a permission handler, an Electron app's renderer process will have access to a user's webcam and microphone. However, screen recording requires the Electron app to have configured a source via a desktopCapturer in the main process. This leaves little room for exploitability from the renderer process, un