Bug: Race condition in timestamp-based queue lock fallback #115

Closed
opened 2026-06-06 11:50:08 +00:00 by jmiller · 1 comment
Owner

Audit Finding

Severity: Medium

Issue:
acquireTimestampLock() reads lock time, checks staleness, then writes — classic TOCTOU race. Two concurrent processes could both acquire the lock. MySQL/PostgreSQL advisory lock paths are correct but the fallback is unreliable.

Fix: Use atomic UPDATE with WHERE clause checking old value, then verify getAffectedRows() > 0.

Files: QueueProcessor.php

## Audit Finding **Severity:** Medium **Issue:** `acquireTimestampLock()` reads lock time, checks staleness, then writes — classic TOCTOU race. Two concurrent processes could both acquire the lock. MySQL/PostgreSQL advisory lock paths are correct but the fallback is unreliable. **Fix:** Use atomic UPDATE with WHERE clause checking old value, then verify `getAffectedRows()` > 0. **Files:** `QueueProcessor.php`
Author
Owner

Branch created: feature/115-bug-race-condition-in-timestamp-based-qu

git fetch origin
git checkout feature/115-bug-race-condition-in-timestamp-based-qu
Branch created: [`feature/115-bug-race-condition-in-timestamp-based-qu`](https://git.mokoconsulting.tech/MokoConsulting/MokoJoomCross/src/branch/feature/115-bug-race-condition-in-timestamp-based-qu) ```bash git fetch origin git checkout feature/115-bug-race-condition-in-timestamp-based-qu ```
Sign in to join this conversation.
Type
Status
Priority
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MokoConsulting/MokoJoomCross#115