sec: require strict majority in 1v1 winner-vote consensus#4580
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
ChangesVote consensus
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
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 |
…4581) **Add approved & assigned issue number here:** Resolves #4136 ## Description: Backport of #4580 to `main`. `VoteRound.result()` (used by `handleWinner` in `GameServer.ts` to 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 satisfied `1 * 2 >= 2` and 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 `v32` hotfix (#4580) is being deployed first; this PR keeps `main` in sync with the same fix. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory ## Please put your Discord username so you can be contacted if a bug or regression is found: jish
Add approved & assigned issue number here:
Resolves #4136
Description:
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).Same fix as previously proposed in #4137, adapted to the current
VoteTally.ts(which didn't exist at the time of that PR) plus corrected test coverage intests/server/VoteTally.test.tsfor the affected tie cases.This targets
v32for a hotfix deploy; a backport PR tomainfollows separately.Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
jish