Skip to content

Commit 879ba22

Browse files
codergautamclaude
andcommitted
fix: Add type check to prevent DoS via non-string rejoinCode
Validate rejoinCode is a string before calling .includes() to prevent TypeError crashes from malicious payloads. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0f39af8 commit 879ba22

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ws/classes/Player.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export default class Player {
161161
// account verification
162162
if((!json.secret) ||(json.secret === 'not_logged_in')) {
163163
if(!this.verified) {
164-
if(json.rejoinCode && json.rejoinCode.includes('-')) {
164+
if(typeof json.rejoinCode === 'string' && json.rejoinCode.includes('-')) {
165165
// Only accept UUID format rejoinCodes (contain dashes), reject MongoDB ObjectIds
166166
const dcPlayerId = disconnectedPlayers.get(json.rejoinCode);
167167
if(dcPlayerId) {

0 commit comments

Comments
 (0)