Repository navigation
Description
What happened
On Linux without XDG_RUNTIME_DIR, the unlock coordination directory falls back to $TMPDIR or /tmp with a predictable name, codex-unlock-<uid>. Another local user can create that path first (as a directory they own or a symlink). The privacy check then fails, and every unlock by the victim is refused with coordination_directory_is_not_private.
Symlink and ownership attacks are correctly rejected (lstat, owner, mode, O_NOFOLLOW, and nlink checks), so the remaining impact is denial of service only.
Also, chmodSync(root, 0o700) runs only after privateDirectory has already confirmed that no group/other bits are set, so it has no effect.
What you expected
The fallback location cannot be pre-empted by other users; for example it lives under a user-owned directory such as $XDG_STATE_HOME or ~/.cache, or the refusal reason clearly identifies a foreign-owned coordination directory.
Environment
codex-unlock0.4.0 at6227e6c- Linux with a shared
/tmpand noXDG_RUNTIME_DIR(for example non-login SSH sessions, cron, containers). macOS uses a per-userTMPDIRand is not affected.
Source evidence
- Predictable shared fallback:
codex-unlock/src/coordination.ts
Lines 36 to 45 in 6227e6c
function runtimeRoot(uid: number, override?: string): string { const configured = override ?? process.env.XDG_RUNTIME_DIR; if (configured !== undefined) { if (!isAbsolute(configured) || !privateDirectory(configured, uid)) { throw new Error("runtime_directory_is_not_private"); } return join(configured, "codex-unlock"); } return join(tmpdir(), `codex-unlock-${uid}`); } - Refusal when the directory is not private:
codex-unlock/src/coordination.ts
Lines 65 to 70 in 6227e6c
root = runtimeRoot(uid, runtimeDirectory); mkdirSync(root, { mode: 0o700, recursive: true }); if (!privateDirectory(root, uid)) { return { status: "unknown", reason: "coordination_directory_is_not_private" }; } chmodSync(root, 0o700);
Acceptance criteria
- The fallback directory is in a user-owned location, or the limitation is documented.
- A foreign-owned pre-existing directory yields a specific, actionable reason.
- A test covers a pre-existing foreign-owned or symlinked fallback path.
Scope and limitations
- Availability impact only; no signal is sent to a wrong process, and no data is read or written through the attacker's path.
- Analysed from source and fixtures; a multi-user reproduction was not performed.
Checked
- security: serialize concurrent unlock attempts #34 / fix: serialize concurrent unlock attempts #35 introduced the coordination directory; no existing issue covers the shared-tmp fallback.
Activity
abruption commentedon Sep 28, 2026
The same fallback is also reached on macOS: when
TMPDIRis unset (cron, some SSH sessions,sudo -u),os.tmpdir()returns/tmpand the lease root becomes/tmp/codex-unlock-<uid>. The pre-creation denial described here is therefore not Linux-only.Source:
codex-unlock/src/coordination.ts
Lines 36 to 45 in 6227e6c
fix: key unlock leases by native lock identity