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
harden(session-host): close CodeQL file-system-race + insecure-temp alerts
enes1de2def054a8
diff --git a/src/core/fs-atomic.ts b/src/core/fs-atomic.tsindex af8c4dd8c..5e176efce 100644--- a/src/core/fs-atomic.ts+++ b/src/core/fs-atomic.ts@@ -345,7 +345,11 @@ export async function writeFileAtomic(): Promise<void> {const tmp = tempNameFor(target)try {- await fs.writeFile(tmp, data, { encoding: 'utf-8', ...opts })+ // `wx`: fail if the temp already exists rather than following it. The name is unique per call,+ // so this never fires in normal operation — its job is to refuse a symlink an attacker+ // pre-planted at the (now guessable-in-principle) temp path, so a publish can never be+ // redirected to write through it. On the expected fresh path it is a plain exclusive create.+ await fs.writeFile(tmp, data, { encoding: 'utf-8', flag: 'wx', ...opts })await renameAtomic(tmp, target)} catch (e) {await fs.rm(tmp, { force: true }).catch(() => {})diff --git a/src/session-host/host.ts b/src/session-host/host.tsindex 444b00204..da262ce20 100644--- a/src/session-host/host.ts+++ b/src/session-host/host.ts@@ -74,8 +74,16 @@ const LOG_CAP_BYTES = 512 * 1024function log(line: string): void {if (!logPath) returntry {- const stat = fs.existsSync(logPath) ? fs.statSync(logPath) : null- if (stat && stat.size > LOG_CAP_BYTES) fs.writeFileSync(logPath, '')+ // Stat directly and treat "not there" as size 0 — an existsSync-then-statSync pair is both a+ // TOCTOU race and redundant here. Diagnostics only, single daemon process, so a truncation that+ // races an append at worst drops a log line.+ let size = 0+ try {+ size = fs.statSync(logPath).size+ } catch {+ /* no log file yet — size stays 0 */+ }+ if (size > LOG_CAP_BYTES) fs.writeFileSync(logPath, '')fs.appendFileSync(logPath, `${new Date().toISOString()} ${line}\n`)} catch {/* diagnostics only */