bug(server): leaderboard opt-in check is not atomic — TOCTOU race condition #61
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
In
solitaire_server/src/sync.rs, the leaderboard submission path reads the user's opt-in flag and then writes the score in separate database operations. Between the read and the write, another request could change the opt-in status, leading to scores being submitted for users who have since opted out (or vice versa).Affected file
solitaire_server/src/sync.rsFix
Wrap the opt-in check and score insert in a single SQL transaction:
Or use a single conditional INSERT with a subquery that checks opt-in atomically.