Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(web): constrain <webview> guest navigation to http(s)/nt-media + deny popups

enes561c4c6617f1
diff --git a/src/main/index.ts b/src/main/index.ts
index 1863b3632..f899885e8 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -180,6 +180,21 @@ function createWindow(): BrowserWindow {
app.whenReady().then(async () => {
if (!gotSingleInstanceLock) return // losing second instance — quitting; don't touch tmux
+
+ // Harden every <webview> guest (WebNode runs its page in its own webContents, so the main
+ // window's setWindowOpenHandler / will-navigate above don't cover it). Registered once at
+ // startup for all current and future guests.
+ app.on('web-contents-created', (_e, contents) => {
+ if (contents.getType() !== 'webview') return
+ // Web nodes may only show http(s) pages or local content we serve via the jailed
+ // nt-media:// scheme.
+ contents.on('will-navigate', (e, url) => {
+ if (!/^https?:\/\//i.test(url) && !/^nt-media:\/\//i.test(url)) e.preventDefault()
+ })
+ // Deny popups / window.open from guest pages (defense-in-depth; allowpopups is already unset).
+ contents.setWindowOpenHandler(() => ({ action: 'deny' }))
+ })
+
settingsStore.init()
settingsStore.registerIpc()
sshStore.registerIpc()