Skip to content

[Crash] Unchecked GameTypes array access in room initialization #64

@coderabbitai

Description

@coderabbitai

Summary

Room initialization crashes when GameTypes[this.gameType] is undefined.

Affected Code

server-game/src/rooms.js:53-54

this.gameOptionsOriginal = JSON.parse(JSON.stringify(GameTypes[this.gameType].options));
this.gameOptions = JSON.parse(JSON.stringify(GameTypes[this.gameType].options));
// CRASH if GameTypes[this.gameType] is undefined

Vulnerability

If client sends invalid gameType index outside valid range.

Impact

  • Game server crash on room creation
  • Denial of service

Proof of Concept

Send joinGame with gameType: 999

Recommended Fix

const gameType = GameTypes[this.gameType];
if (!gameType) {
  throw new Error(`Invalid game type: ${this.gameType}`);
}
this.gameOptionsOriginal = JSON.parse(JSON.stringify(gameType.options));
this.gameOptions = JSON.parse(JSON.stringify(gameType.options));

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions