Skip to content

security: serialize concurrent unlock attempts #34

Closed

Description

@abruption

Priority

P0 — v0.2 safety gate discovered by #24.

Problem

Two independent codex-unlock processes can inspect and revalidate the same completed owner concurrently. Both can reach process.kill before the owner exits, both send SIGTERM to the same PID, and both report outcome unlocked. The native writer lock cannot coordinate doctors because it is exclusively held by the Codex owner.

Required changes

  • serialize unlock attempts for the same canonical CODEX_HOME and thread UUID across processes
  • keep the coordination primitive outside Codex native lock paths and never delete a native lock file
  • use an actual advisory lock rather than lock-file existence
  • keep coordination data private to the same user and validate directory/file ownership, type, mode, symlink state, and canonical home identity
  • fail closed without signaling when coordination cannot be established
  • leave list and inspect read-only and unaffected
  • do not add force, waiting takeover, SIGKILL, or stale native lock deletion

Acceptance criteria

  • two concurrent CLI unlock commands against one real advisory lock produce exactly one SIGTERM attempt
  • the competing invocation is refused with a stable reason and sends no signal
  • release of the operation lease allows a later invocation
  • coordination setup, contention, symlink/permission failure, and cleanup paths are tested
  • existing owner, transcript, inode, lock-set, and post-signal invariants remain unchanged

Dependencies

Discovered by and should land with the regression matrix in #24 before #16.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions