Skip to content

[Crash] Unchecked this.player.stateBuffer[idx] access in sync handler #70

@coderabbitai

Description

@coderabbitai

Summary

Game server crashes when this.player.stateBuffer[idx] is undefined during sync processing.

Affected Code

server-game/src/client.js:317-319

for (startIdx, i = 0; i < FramesBetweenSyncs; i++) {
  var idx = Math.mod(startIdx + i, stateBufferSize);
  this.player.stateBuffer[idx].controlKeys = input.unPackInt8U();
  this.player.stateBuffer[idx].yaw = input.unPackRadU();
  this.player.stateBuffer[idx].pitch = input.unPackRad();
  // CRASH if stateBuffer[idx] is undefined
}

Vulnerability

If player initialization incomplete or buffer not properly allocated.

Impact

  • Game server crash on sync packet
  • Denial of service

Recommended Fix

if (!this.player.stateBuffer[idx]) {
  console.error('stateBuffer not initialized at index', idx);
  return;
}
this.player.stateBuffer[idx].controlKeys = input.unPackInt8U();

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