In-depth lesson · Race condition
Typical fixes
Every point the Race condition reports back under this heading, best-backed first, each with the reports it is seen in.
-
Enforce limits with atomic counters or database constraints rather than a separate check
Seen in 7 reports
-
Use file descriptors opened with no-follow semantics and avoid check-then-use on paths
Seen in 6 reports
-
Use atomic check-and-record operations for follow and reaction endpoints
Seen in 4 reports
-
Record votes with an atomic insert or unique constraint per user and item
Seen in 3 reports
-
Lock or serialise redemption so the balance update and validation happen in one transaction
Seen in 3 reports
-
Enforce membership uniqueness with a database constraint and an atomic insert
Seen in 3 reports
-
Add idempotency keys and locking to payout and retest payment processing
Seen in 2 reports
-
Perform email change and verification in a single database transaction tied to the specific change request
Seen in 2 reports
-
Protect the shared resolver buffer with a mutex
Seen in 2 reports
-
Isolate privileged file operations from concurrent manipulation
-
Make vote and entry counting atomic per account
-
Make transaction handling atomic
Seen in 2 reports
-
$5,000 -
$5,000 Critical
-
-
Make the claim check and bonus award atomic
-
Lock the approval record and enforce one approval per user per merge request
Seen in 1 report
-
Remove approvals synchronously when a new commit is pushed
Seen in 1 report
-
Make the flag check and point award atomic and idempotent
Seen in 1 report
-
Treat parallel reset requests as one operation so cancelling one cancels all
Seen in 1 report
-
Lock the balance during transfer validation and deduction
Seen in 1 report
-
Make the balance check and transfer a single atomic step
Seen in 1 report
-
$5,000 Critical
-
-
Enforce eligibility with an atomic lock per account
Seen in 1 report
-
Add a database-level constraint preventing cyclic parent-child relationships
Seen in 1 report
-
Set a restrictive umask at daemon startup
Seen in 1 report
-
Make reference counting thread-safe
Seen in 1 report
-
Add proper locking around the IPv6 packet options structure
Seen in 1 report
-
Add locking and ownership checks around shared path pointers
Seen in 1 report
-
$10,000 High
-
-
Sanitise user-supplied job IDs before using them in file paths
-
Complete certificate validation before deciding to reuse a connection
Seen in 1 report
-
Synchronise updates to the shared DNS cache
-
Match queued responses to their originating requests
Seen in 1 report
-
Zero-fill buffers even when allocation times out
Seen in 1 report
-
Copy or lock shared buffers before decoding
-
Prevent iterator replay of previously executed writes
-
Synchronise teardown of shared handles with list destruction
Seen in 1 report
-
Make the GSS context per-thread or protect it with a lock
Seen in 1 report
-
Guard against double close of eventfd descriptors
Seen in 1 report
-
Make the resume check and append atomic
Seen in 1 report
-
Verify and use the file through the same descriptor
-
Make lock screen state changes atomic
Seen in 1 report
-
Invalidate all concurrent sessions on logout
Seen in 1 report
-
Serialise ban and unban actions
Seen in 1 report
-
Make membership changes atomic
Seen in 1 report
-
Bind recovery steps to a single flow instance
Seen in 1 report
-
Check purchase before accepting a publish request
Seen in 1 report
-
Make creation checks atomic
Seen in 1 report
-
Make review submission checks atomic per user
Seen in 1 report
-
Match pipelined responses reliably to their requests
Seen in 1 report
-
Add database constraints instead of relying on application-level validation
Seen in 1 report
-
Make security feature checks atomic with their use
-
Synchronise feature entitlement checks across parallel requests