Repository navigation
Description
What happened
If the update cache file path is a FIFO, list, inspect, and unlock (including --json) block indefinitely before producing any output.
readUpdateCache opens the cache file with O_RDONLY | O_NOFOLLOW but without O_NONBLOCK, and only checks that it is a private regular file after open returns. Opening a FIFO for reading blocks until a writer appears. The cache read happens in prepareAutomaticAdvisory before the primary command runs, and --json mode reads the cache even in CI or non-TTY contexts.
Reproduction with a fake XDG_CACHE_HOME: create codex-unlock/ (mode 0700) and mkfifo -m600 codex-unlock/update.json, then run codex-unlock list --json --codex-home <empty-dir>. After 6 seconds there was still no output; removing the FIFO immediately restored normal output.
The refresh lease path opens update.lock with O_CREAT | O_RDWR and the same pattern.
What you expected
As documented in docs/update-security.md, a missing, stale, invalid, or unavailable cache behaves as "no advisory", and unsafe files are rejected. A special file at the cache path should be classified invalid immediately and must never delay the primary command.
Environment
codex-unlock0.4.0 at6227e6c- macOS 27.0 arm64, Node.js 22.14.0
Source evidence
- Blocking open before type check:
Lines 303 to 309 in 6227e6c
let descriptor: number | undefined; try { descriptor = openSync(location.cacheFile, constants.O_RDONLY | noFollowFlag()); const before = fstatSync(descriptor); if (!privateRegularFile(before, uid)) { return { status: "invalid", reason: "cache_file_is_not_private" }; } - Same pattern for the lease file:
Lines 461 to 468 in 6227e6c
let descriptor: number | undefined; try { descriptor = openSync( location.lockFile, constants.O_CREAT | constants.O_RDWR | noFollowFlag(), 0o600, ); const value = fstatSync(descriptor); - Cache read happens before the primary command:
Lines 363 to 380 in 6227e6c
const advisory = prepareAutomaticAdvisory(parsed.json, parsed.noUpdateNotice); try { if (parsed.command === "list") { const result = await listThreads(parsed.options); if (parsed.json) console.log(JSON.stringify(withClientUpdate(result, advisory.clientUpdate), null, 2)); else printList(result); finishAutomaticAdvisory(advisory); return 0; } if (parsed.command === "inspect") { const result = await inspectThread(parsed.threadId!, parsed.options); if (parsed.json) console.log(JSON.stringify(withClientUpdate(result, advisory.clientUpdate), null, 2)); else printInspection(result); finishAutomaticAdvisory(advisory); return 0; } const result = await unlockThread(parsed.threadId!, parsed.options);
Acceptance criteria
- Cache and lease files are opened with
O_NONBLOCK(and/orlstat-checked as regular files first, thenfstat-revalidated). - FIFOs and other special files at either path are classified
invalid/unavailablewithout blocking. - A regression test places a FIFO at the cache path and asserts that
list --jsoncompletes within a bounded time with a valid result.
Scope and limitations
- Not exploitable by another user: the cache directory must be owned by the same user with mode 0700. This is a reliability issue triggered by the same user's tooling or mistakes.
- It occurs before any unlock safety check, so it cannot cause a wrong signal.
Checked
- security: specify update-cache privacy and failure isolation #28 specified cache privacy and failure isolation; this case is not covered by it or by existing tests.
Activity
fix: harden update cache boundary