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 3 commits into
Conversation
game.end() is async but was called without await inside a try/catch. The try/catch only catches synchronous errors. Added .catch() to the returned promise to prevent unhandled promise rejections from crashing the server.
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 |
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