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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(security): keep the codex node token out of the tmux argv
Claude Codebce8809153cc
diff --git a/src/core/agents/hook-server.env.test.ts b/src/core/agents/hook-server.env.test.tsindex 762c20130..668742173 100644--- a/src/core/agents/hook-server.env.test.ts+++ b/src/core/agents/hook-server.env.test.ts@@ -20,9 +20,14 @@ beforeAll(async () => {initPlatform(fakePlatform({ userDataDir: dir }))// buildPtyEnv returns {} until the server has a port and a token.await hookServer.start()+ // ...and the per-node capability branch is dead code until a node-auth secret is armed. Without+ // this line the argv-leak guard below passes for the wrong reason: it asserts the absence of a+ // key the code was never going to emit.+ hookServer.setNodeAuthSecret(new Uint8Array(32).fill(7))})afterAll(() => {+ hookServer.clearNodeAuthSecretForTests() // module singleton — otherwise it leaks into other fileshookServer.stop()fs.rmSync(dir, { recursive: true, force: true })})@@ -71,4 +76,24 @@ describe('hookServer.buildPtyEnv — no credential in the tmux -e argv (the §2.expect(env.NODETERM_AGENT_ID).toBe('claude')expect(env.NODETERM_HOOK_VERSION).toBe('2')})++ /**+ * The PER-NODE capability is the same class of leak as the app-wide bearer above and needs its own+ * assertion, on an agent that can actually trigger the emitting branch: `claude` is not in+ * SHARED_IDENTITY_CAPABLE, so the case above never reaches the mint at all. Both preconditions —+ * a capable agent AND an armed secret — are asserted here, because a guard that reads green while+ * its subject is unreachable is worse than no guard.+ */+ it('emits no PER-NODE capability either, for a shared-identity agent with identity armed', () => {+ expect(hookServer.identityAvailable()).toBe(true)+ const minted = hookServer.codexNodeAuthToken('n1')+ expect(minted).toBeTruthy() // the value that must NOT be reachable via /proc/<pid>/cmdline+ const env = hookServer.buildPtyEnv('n1', 'codex')+ expect(Object.keys(env).filter((k) => /token/i.test(k))).toEqual([])+ const argv = Object.entries(env).flatMap(([k, v]) => ['-e', `${k}=${v}`])+ expect(argv.join(' ')).not.toContain(minted)+ // ...while the rest of the codex wiring is untouched, so the launcher still reaches the shell.+ expect(env.NODETERM_AGENT_ID).toBe('codex')+ expect(env.NODETERM_HOOK_ENDPOINT).toBeTruthy()+ })})diff --git a/src/core/agents/hook-server.ts b/src/core/agents/hook-server.tsindex 6b47725f0..284215558 100644--- a/src/core/agents/hook-server.ts+++ b/src/core/agents/hook-server.ts@@ -3,7 +3,7 @@ import { createHmac, randomUUID, timingSafeEqual } from 'crypto'import { writeFileSync, mkdirSync } from 'fs'import path from 'path'import { platform } from '../platform'-import { canControlCanvas, hasSharedIdentity, type AgentId } from '../../shared/agents/config'+import { canControlCanvas, type AgentId } from '../../shared/agents/config'import { normalizeFor, type NormalizedAgentEvent } from '../../shared/agents/normalize'import type { CodexIdentityEvent } from '../../shared/types'import { nodeTokenDir } from './node-token-files'@@ -632,12 +632,19 @@ class HookServer {NODETERM_NODE_ID: nodeId,NODETERM_AGENT_ID: agentId,...(permWaitSecs > 0 ? { NODETERM_PERM_WAIT_SECS: String(permWaitSecs) } : {}),- ...(canControlCanvas(agentId) ? { NODETERM_CANVAS_CONTROL: '1' } : {}),- // The per-node capability for the identity routes. Gated by the CAPABILITY LIST, never by- // `agentId === 'codex'`. No secret ⇒ no token ⇒ the launcher falls back to plain codex.- ...(hasSharedIdentity(agentId) && this.codexNodeAuthSecret- ? { NODETERM_CODEX_NODE_TOKEN: this.codexNodeAuthToken(nodeId) }- : {})+ ...(canControlCanvas(agentId) ? { NODETERM_CANVAS_CONTROL: '1' } : {})+ // NO NODETERM_CODEX_NODE_TOKEN either. The per-node capability is the same class of leak as+ // the app-wide bearer above, and a worse one to reason about: it is the credential that+ // proves WHICH node is calling, so a sibling uid reading it off /proc/<pid>/cmdline could+ // bind its own codex thread to that node — the exact reparenting this capability exists to+ // prevent. It reaches the client through the 0600 token file instead (nodeTokenDir(), keyed+ // by $NODETERM_NODE_ID and advertised in the endpoint file).+ //+ // The launcher (core/codex-identity-proxy.ts) still reads the ENV var and is not yet wired to+ // the file — that retrofit is its own task. Until then a codex node finds no capability, its+ // preflight reports `node-token-unavailable`, and it execs plain codex: shared identity is+ // INERT, not broken. That is the fallback this launcher was built around, and an inert+ // feature is a straight trade against a live cross-uid credential leak.}}