Blog

An Electron plugin system: sandbox and permissions in ideagent

Open notebook and glowing light bulb in front of a desktop window frame

When you add a plugin system to an editor, you agree to run code you did not write inside your own app. In Electron, if that code gets hold of Node, it also reaches the file system, the network and the user's keys. The common belief is that a plugin API is either powerful or safe, never both. While building ideagent I accepted half of that. I kept the API narrow on purpose and turned every capability into a door with a known size.

ideagent is a desktop editor where I run, watch and approve Claude, Codex and Gemini agents, each project with its own account. The app itself is closed source. The plugin and theme SDK (@ideagent/api), the examples and the guide are MIT licensed in the public repo. The first release, 0.1.0, shipped on 5 November 2026 with plugin and theme support already in it. So plugins were not bolted on later; the security boundaries had to be drawn on day one. Every rule below is written out in the repo's guide and SDK code.

Plugin code runs in a separate process with no Node

The first decision was where a plugin runs. An ideagent plugin can have two parts: a hidden host script (main.js) that handles commands, status items in the top bar and events, and optional panels (panel.html, panel.js). Both run in a separate, sandboxed process with no Node.js access. Electron has enabled the sandbox for renderer processes by default since Electron 20, but a single per-window setting turns it off. For plugin code, that door had to stay shut.

Pages load not from file:// but from a custom protocol, ideagent-plugin://<id>/, and can read only the plugin's own folder. Electron's security checklist also recommends custom protocols over file://. The reasoning is simple: a page opened under file:// sits closest to every other file on disk. With a custom protocol, the app decides what gets served.

The third layer is the content security policy. Direct fetch and WebSocket are blocked in panels, and so are inline scripts. A panel loads its script from a file: <script src="panel.js">. That costs plugin authors a little effort, but it stops any text that leaks into the HTML from ever running as a script.

A Node-free process has one more cost, and I wrote it into the guide plainly. main.js runs as an ES module, so top-level await works. Bare package imports such as @ideagent/api do not resolve at runtime, though. The package is for types and validation only; any runtime dependency has to be bundled into the plugin's own files.

Every capability is a declared door with a known size

A sandboxed process can do almost nothing on its own. A useful plugin needs doors. I tied each door to a single call on window.ideagent and made three permissions explicit in the manifest: network, docker and project. Permissions are shown to the user at install time and must be approved. Without one, the call fails with an izin yok (no permission) error.

Network: Since a plugin cannot call fetch directly, it reaches the network only through ideagent.net.fetch, and only to the HTTPS hosts listed in its manifest. The list takes up to 20 public hostnames. The SDK's validator rejects IP addresses and local network suffixes: const LOCAL = /\.(local|localhost|internal|lan|home\.arpa)$/. The body is capped at 1 MB, the response at 5 MB, the time at 30 seconds. The most important rule: redirects are not followed. If an allowed host could redirect elsewhere, a single 302 would punch through the host list. I ran into the mirror image of this problem in ui-deck's screenshot tool, which measures live sites; that post explains why checking redirect hops is hard. Here I took the easier road and do not follow redirects at all.

Docker: ideagent.docker.request goes to the Docker Engine API, but not to all of it. Allowed GET paths are _ping, version, info, system/df, container and image lists, networks and volumes. For POST there is only start, stop and restart of an existing container. No request body. So a plugin cannot create a container, pull an image or run a command inside one. Full access to the Docker socket is, in practice, full access to the machine, so I opened the door only as wide as a Docker panel needs.

Project: The project permission grants the active project's path and file reads through ideagent.project.readFile. Without it, project.current() still returns the project's name, but the path comes back as null.

Calls outside the permissions have sizes too. storage holds at most 200 keys of up to 64 KB of JSON each. The event list has three names: project.active, session.status and git.changed. The manifest is validated strictly: an unknown key makes it invalid, and when parseManifest fails it names the path of the broken field, for example commands[1].id. On install, ideagent copies the plugin folder; a file changed in the folder afterwards does not reach the running plugin until you load the folder again. The code you approved is the code that runs.

What a narrow API costs

These limits have a price, and the clearest view of it is the Docker example in the repo. The plugin shows the number of running containers in the top bar. Since the Docker event stream is not among the allowed paths, it asks again every 15 seconds and whenever the panel requests it:

  • const r = await ideagent.docker.request('GET', '/containers/json')
  • setInterval(refresh, 15_000)

A wide API would make this instant. A narrow one means accepting a 15-second lag. For a status item I think that is the right trade, but someone who wants a plugin that tails live logs cannot do it with this API, and they should know that up front.

The second cost is distribution. The ideagent team publishes the plugins in the in-app catalog; you apply through a GitHub issue template, linking a public repo that contains the plugin folder. The catalog asks for a stable version (no prerelease), at most 500 files, 5 MB per file and 20 MB in total, and an explanation of each permission in the issue. That slows a plugin store down. In return, every plugin in the catalog has a written reason for each door it opens. Loading from a folder is always available: Settings, Plugins, Load From Folder.

The third cost is on my side. Every new capability means a new door, a new permission and a new limit. When a request comes in to "let plugins do this too", the answer is not to add a function; it is to write down that function's size, its permission and how it could be abused. The API version is single for now as well: the manifest accepts only apiVersion: 1.

If you are building a plugin system for an Electron app, these are the four rules I would take from this work:

  1. Run plugin code in a sandboxed process with no Node, served from a custom protocol; Electron's sandbox guide is a good start.
  2. Give the network to your own call, not to the plugin; set a host list, size limits and a timeout, and do not follow redirects.
  3. Ask for every permission in the manifest and show it at install; a call without permission should fail with a clear error.
  4. When you grant access to a powerful backend (Docker, the file system, a shell), give an allowlist of paths, not the full API.

You can install the SDK with npm install @ideagent/api and find three working examples (a counter, Docker, and a theme-only package) in the repo's packages/api/examples folder. ideagent and my other work are on the projects page, and more posts are on the blog.

ElectronSecurityTypeScript