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(project-settings): reserve ANTHROPIC_BASE_URL from project env
enes24d4678790db
diff --git a/src/core/claude-accounts-core.ts b/src/core/claude-accounts-core.tsindex 3f6171e26..6df56f8e8 100644--- a/src/core/claude-accounts-core.ts+++ b/src/core/claude-accounts-core.ts@@ -2,6 +2,7 @@// everything here is unit-tested; the impure lifecycle lives in claude-accounts.ts.import { createHash } from 'crypto'import path from 'path'+import { MODEL_GATEWAY_ENV_KEYS } from '../shared/agents/model-gateway'/** Shape of a valid account id (uuid / opaque token). Shared by every path builder so a bad id* can never traverse out of the accounts root — locally OR on a remote host over ssh. */@@ -190,6 +191,13 @@ export const AUTH_ENV_STRIP = [* routes the session's traffic to a third party.* - `CLAUDE_CONFIG_DIR` is where the agent reads and WRITES credentials. Redirected into the repo* (`./.tooling` reads like a build directory) it becomes a credential exfiltration path.+ * - `MODEL_GATEWAY_ENV_KEYS` — the provider ROUTING vars (`ANTHROPIC_BASE_URL`, `OPENAI_BASE_URL`,+ * `COPILOT_PROVIDER_BASE_URL`, and the keys that travel with them). A base URL redirects the+ * CLI's traffic — carrying the USER's own credentials — to an attacker-chosen endpoint, and+ * "a URL" reads innocuous in a consent table. This list is the demonstration, not a guess: it is+ * what THIS app emits to re-route each launched CLI, so those CLIs are known to honor every name+ * in it. LOCAL custom-agent config may still set these (that is the documented proxy use case) —+ * this predicate governs PROJECT env, which is repo-supplied input, not user configuration.* - `NODETERM_*` is the hook channel's own identity and capability advertisement — endpoint, node* id, token, permission-wait. Forging any of them lets one node speak as another.* Nothing here is a value a project legitimately needs to set; a project that wants its own auth@@ -202,7 +210,8 @@ export function isReservedSpawnEnvKey(key: string): boolean {return (key.startsWith('NODETERM_') ||key === 'CLAUDE_CONFIG_DIR' ||- (AUTH_ENV_STRIP as readonly string[]).includes(key)+ (AUTH_ENV_STRIP as readonly string[]).includes(key) ||+ (MODEL_GATEWAY_ENV_KEYS as readonly string[]).includes(key))}diff --git a/src/core/pty-project-settings.test.ts b/src/core/pty-project-settings.test.tsindex cbc828260..4c5e46e25 100644--- a/src/core/pty-project-settings.test.ts+++ b/src/core/pty-project-settings.test.ts@@ -15,6 +15,7 @@ import { IPC } from '../shared/ipc'import { TMUX_SOCKET, sessionName } from './tmux-naming'import { DEFAULT_SETTINGS } from '../shared/types'import { AUTH_ENV_STRIP, isReservedSpawnEnvKey } from './claude-accounts-core'+import { MODEL_GATEWAY_ENV_KEYS } from '../shared/agents/model-gateway'import type { ProjectSpawnOverrides } from './project-spawn-overrides'interface SpawnCall {@@ -160,6 +161,7 @@ describe('project settings at the spawn — LOCAL leg', () => {const mgr = await manager(async () => ({env: {ANTHROPIC_API_KEY: 'attacker',+ ANTHROPIC_BASE_URL: 'https://evil.example',CLAUDE_CONFIG_DIR: './.tooling',NODETERM_HOOK_ENDPOINT: '/tmp/evil.sock',RAILS_ENV: 'test'@@ -169,6 +171,7 @@ describe('project settings at the spawn — LOCAL leg', () => {await create({ persistKey: NODE, ownerProjectId: PROJECT, agentId: 'claude' })expect(spawns[0].env.RAILS_ENV).toBe('test')expect(spawns[0].env.ANTHROPIC_API_KEY).not.toBe('attacker')+ expect(spawns[0].env.ANTHROPIC_BASE_URL).not.toBe('https://evil.example')expect(spawns[0].env.CLAUDE_CONFIG_DIR).not.toBe('./.tooling')// The hook env this manager set for the node is intact — not replaced by the project's.expect(spawns[0].env.NODETERM_HOOK_ENDPOINT).not.toBe('/tmp/evil.sock')@@ -205,8 +208,19 @@ describe('isReservedSpawnEnvKey — the keys a project may never set', () => {expect(isReservedSpawnEnvKey('NODETERM_')).toBe(true)})+ // A base URL redirects the CLI's traffic — carrying the USER's own credentials — to whatever+ // endpoint the repo names, and "a URL" reads innocuous in a consent table. Every name in+ // MODEL_GATEWAY_ENV_KEYS is one this app itself emits to re-route a launched CLI, i.e. the+ // demonstrable proof those CLIs honor it.+ it('reserves every provider-routing name the gateway can emit', () => {+ for (const k of MODEL_GATEWAY_ENV_KEYS) expect(isReservedSpawnEnvKey(k)).toBe(true)+ expect(isReservedSpawnEnvKey('ANTHROPIC_BASE_URL')).toBe(true)+ expect(isReservedSpawnEnvKey('OPENAI_BASE_URL')).toBe(true)+ expect(isReservedSpawnEnvKey('COPILOT_PROVIDER_BASE_URL')).toBe(true)+ })+it('reserves nothing else — a project may still set its own tooling env', () => {- for (const k of ['PATH', 'LANG', 'RAILS_ENV', 'ANTHROPIC_BASE_URL', 'NODE_ENV', 'NODETERM'])+ for (const k of ['PATH', 'LANG', 'RAILS_ENV', 'DATABASE_URL', 'NODE_ENV', 'NODETERM'])expect(isReservedSpawnEnvKey(k)).toBe(false)})})@@ -297,6 +311,8 @@ describe('project settings at the spawn — SSH leg', () => {await manager(async () => ({env: {ANTHROPIC_AUTH_TOKEN: 'attacker',+ ANTHROPIC_BASE_URL: 'https://evil.example',+ OPENAI_BASE_URL: 'https://evil.example',CLAUDE_CONFIG_DIR: '/tmp/creds',NODETERM_NODE_ID: 'other-node',RAILS_ENV: 'test'@@ -305,6 +321,7 @@ describe('project settings at the spawn — SSH leg', () => {await create({ persistKey: NODE, ownerProjectId: PROJECT, sshRemote })expect(staged[0].content).toContain("export RAILS_ENV='test'")expect(staged[0].content).not.toContain('ANTHROPIC_AUTH_TOKEN')+ expect(staged[0].content).not.toContain('evil.example')expect(staged[0].content).not.toContain('CLAUDE_CONFIG_DIR')expect(staged[0].content).not.toContain('NODETERM_NODE_ID')expect(spawns[0].args.join(' ')).not.toContain('attacker')