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(security): stop putting the hook bearer in the tmux -e argv

Claude Code1f5cd4b96ce8
diff --git a/src/core/agents/hook-server.env.test.ts b/src/core/agents/hook-server.env.test.ts
index 863552e9f..762c20130 100644
--- a/src/core/agents/hook-server.env.test.ts
+++ b/src/core/agents/hook-server.env.test.ts
@@ -53,3 +53,22 @@ describe('hookServer.setNodeAuthSecret — length guard', () => {
expect(() => hookServer.setNodeAuthSecret(new Uint8Array(31))).toThrow(/invalid|secret/i)
})
})
+
+describe('hookServer.buildPtyEnv — no credential in the tmux -e argv (the §2.1 regression guard)', () => {
+ it('emits no bearer token and no port — they leaked through /proc/<pid>/cmdline', () => {
+ const env = hookServer.buildPtyEnv('n1', 'claude')
+ expect(env).not.toHaveProperty('NODETERM_HOOK_TOKEN')
+ expect(env).not.toHaveProperty('NODETERM_HOOK_PORT')
+ // The tmux `-e` argv is built by flattening this map — assert the live token never appears in it.
+ const argv = Object.entries(env).flatMap(([k, v]) => ['-e', `${k}=${v}`])
+ expect(argv.join(' ')).not.toContain(hookServer.getToken())
+ })
+
+ it('still carries the non-credential wiring: endpoint file path, node id, agent id, version', () => {
+ const env = hookServer.buildPtyEnv('n1', 'claude')
+ expect(env.NODETERM_HOOK_ENDPOINT).toBeTruthy()
+ expect(env.NODETERM_NODE_ID).toBe('n1')
+ expect(env.NODETERM_AGENT_ID).toBe('claude')
+ expect(env.NODETERM_HOOK_VERSION).toBe('2')
+ })
+})
diff --git a/src/core/agents/hook-server.ts b/src/core/agents/hook-server.ts
index f5802c595..93cf5b607 100644
--- a/src/core/agents/hook-server.ts
+++ b/src/core/agents/hook-server.ts
@@ -539,8 +539,14 @@ class HookServer {
buildPtyEnv(nodeId: string, agentId: AgentId, permWaitSecs = 0): Record<string, string> {
if (this.port <= 0 || !this.token) return {}
return {
- NODETERM_HOOK_PORT: String(this.port),
- NODETERM_HOOK_TOKEN: this.token,
+ // NO NODETERM_HOOK_TOKEN, NO NODETERM_HOOK_PORT — measured 2026-08-13: these ride the tmux
+ // `-e` argv into a long-lived tmux CLIENT process whose /proc/<pid>/cmdline is mode 444 on a
+ // stock Linux (no hidepid), so any unprivileged local user read a live app-wide bearer and
+ // could drive canvas control — including `open-terminal --cmd`, which is NOT in the
+ // confirm-gated DESTRUCTIVE set. Every client already sources the 0600 endpoint file FIRST
+ // and prefers it, so nothing legitimate loses anything: the only regression surface is a
+ // session whose endpoint file is unreadable AND whose env held a good token, a state that
+ // means the data dir has vanished and the hook is meant to be inert anyway.
NODETERM_HOOK_VERSION: NODETERM_HOOK_PROTOCOL_VERSION,
NODETERM_HOOK_ENDPOINT: this.endpointFilePath(),
NODETERM_NODE_ID: nodeId,