sec: require strict majority in 1v1 winner-vote consensus (backport)#4581
Conversation
…er spoof VoteRound.result() treated an exact tie (votes * 2 >= total) as a majority. With a 1v1 game's electorate of 2 unique IPs, a single client's vote alone satisfied that check (1 * 2 >= 2), letting one player unilaterally declare themselves the winner without the other player agreeing. Requiring a strict majority (votes * 2 > total) closes this while still resolving immediately once the electorate shrinks to 1 (e.g. the other player actually disconnects). Resolves #4136
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Walkthrough
ChangesStrict majority resolution
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Add approved & assigned issue number here:
Resolves #4136
Description:
Backport of #4580 to
main.VoteRound.result()(used byhandleWinnerinGameServer.tsto reach consensus on a reported game winner) accepted an exact tie as a majority:votes * 2 >= totalUniqueIPs. In a 1v1 game the electorate is 2 unique IPs, so a single client's vote alone satisfied1 * 2 >= 2and was accepted immediately — letting one player unilaterally declare themselves the winner without any agreement from the other player, and without the server ever checking the report against the actual simulation outcome.This fixes the comparison to require a strict majority (
votes * 2 > totalUniqueIPs), so a 1v1 now requires both clients to agree. Legitimate forfeit-on-disconnect is unaffected: once a player actually disconnects, the electorate shrinks to 1 unique IP, and the sole remaining vote still resolves immediately (1 * 2 > 1).The
v32hotfix (#4580) is being deployed first; this PR keepsmainin sync with the same fix.Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
jish