Skip to content

progress-state: withHumanDecisionsLock stale-lock breaker TOCTOU (lstat-then-unlink window) #1152

Open

Description

@jflowers

Severity: LOW
Source: Divisor review on PR #1145 (divisor-adversary)
Location: .opencode/lib/progress-state.ts:732 (withHumanDecisionsLock, lines 726-733)

withHumanDecisionsLock checks the lock's mtime via lstatSync (lines 726-727) then unconditionally rmSyncs the lock path (line 733) with no revalidation between the two. A concurrent writer that acquires a fresh lock (new mtime) between check and unlink has its lock deleted, letting two writers enter the critical section concurrently — a lost-update risk on human-decisions.json via the read-stamp-write race.

Suggested fix (from review): a re-stat or inode comparison before the unlink closes the window.

Review comment: #1145 (comment)

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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions