Skip to content

fix: a FIFO at the update cache path hangs list, inspect, and unlock #57

Closed

Description

@abruption

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-unlock 0.4.0 at 6227e6c
  • macOS 27.0 arm64, Node.js 22.14.0

Source evidence

  • Blocking open before type check:

    codex-unlock/src/update.ts

    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:

    codex-unlock/src/update.ts

    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:

    codex-unlock/src/cli.ts

    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/or lstat-checked as regular files first, then fstat-revalidated).
  • FIFOs and other special files at either path are classified invalid/unavailable without blocking.
  • A regression test places a FIFO at the cache path and asserts that list --json completes 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

Activity

  1. added
    bug
    on Sep 28, 2026
  2. added this to the v0.4.1 milestone on Sep 28, 2026
  3. added a commit that references this issue on Sep 29, 2026
    d15c9f3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions