Project 01
electron-hardening
Secure-by-default building blocks for Electron apps, plus a static audit that finds what is already wrong.
- MIT licensed, published on npm
- Zero dependencies
- 119 unit tests, 34 checks inside real Electron
What I built
- One call locks down navigation, popups, <webview>, permissions and the Content-Security-Policy for every window and session the app creates, including ones created before the call.
- An IPC router that checks who is calling and what they sent. Other origins, subframes, invalid arguments and rate-limit overruns are rejected before your handler runs.
- A preload bridge that never hands the page ipcRenderer.
- A static audit CLI with SARIF output: npx electron-hardening audit, no install needed.
- Performance helpers for startup and high-frequency IPC, including a “show when ready” helper so windows never flash white or get stuck invisible.
The hard parts
Tested in real Electron, not just mocks
The end-to-end suite launches Electron 45 and attacks a hardened app from inside sandboxed renderers. It runs 34 checks on Windows, macOS and Linux in CI.
Security that costs almost nothing
An origin check costs about 0.1–0.3 µs. A guarded IPC call adds about 0.8 µs over a bare ipcMain.handle. Batched IPC cuts serialization about 40x for chatty channels.
Origin rules that resist tricks
Subdomain wildcards don’t match lookalikes, file URL rules resist ../ and encoded slashes, and URLs with embedded credentials never match. A malformed rule throws at startup instead of silently trusting nothing.





