fix(game): patch Desync DoS vulnerability with strict majority consensus#3956
fix(game): patch Desync DoS vulnerability with strict majority consensus#3956berkelmali wants to merge 1 commit into
Conversation
WalkthroughThis PR refactors error handling in game completion and adjusts desynchronization detection logic. GameManager converts from sync try/catch to promise-based error handling for game.end(), and GameServer tightens the threshold for treating all active clients as out-of-sync from ≥50% to >50%. ChangesGame Completion Error Handling
Desynchronization Detection Threshold
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
| if (phase === GamePhase.Finished) { | ||
| try { | ||
| game.end(); | ||
| } catch (error) { | ||
| game.end().catch((error: any) => { | ||
| this.log.error(`error ending game ${id}: ${error}`); | ||
| } | ||
| }); |
There was a problem hiding this comment.
this change doesn't seem relevant?
0b2d575 to
1b77466
Compare
Resolves #3959
Description:
This PR fixes a Denial of Service (DoS) vulnerability in 1v1 matches related to desync reporting. The
findOutOfSyncClientslogic previously forced a game-ending desync if half or more players reported conflicting hashes (outOfSyncClients.length >= Math.floor(this.activeClients.length / 2)). In a 1v1, this meant a single malicious player sending a bad hash could trigger a global desync, crashing their opponent's game session.The logic has been corrected to require a strict majority (
> Math.floor(this.activeClients.length / 2)) to declare a lobby-wide desync. In a 1v1 game, a single malicious actor will now simply be flagged as the out-of-sync client and disconnected, allowing the honest player to continue their session uninterrupted.Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
barfires