Skip to content

Commit

Permalink
fix: exploit allowing joining a game at any point
Browse files Browse the repository at this point in the history
  • Loading branch information
hsanger committed Oct 17, 2024
1 parent 9f8b12d commit e427351
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ export class Game implements GameData {
const { simultaneousConnections, joinAttempts } = This;

if (
(simultaneousConnections[ip] >= (maxSimultaneousConnections ?? Infinity))
|| (joinAttempts[ip] >= (maxJoinAttempts?.count ?? Infinity))
simultaneousConnections[ip] >= (maxSimultaneousConnections ?? Infinity)
|| joinAttempts[ip] >= (maxJoinAttempts?.count ?? Infinity)
) {
Logger.log(`Game ${This.id} | Rate limited: ${ip}`);
forbidden(res);
Expand All @@ -285,16 +285,16 @@ export class Game implements GameData {
}
}

const searchParams = new URLSearchParams(req.getQuery());

//
// Ensure IP is allowed
//
if ((This.allowedIPs.get(ip) ?? Infinity) < This.now) {
if ((This.allowedIPs.get(ip) ?? 0) < This.now) {
forbidden(res);
return;
}

const searchParams = new URLSearchParams(req.getQuery());

//
// Validate and parse role and name color
//
Expand Down

0 comments on commit e427351

Please sign in to comment.