Skip to content

Commit 0f39af8

Browse files
codergautamclaude
andcommitted
fix: Prevent session hijacking via rejoinCode validation
Only accept UUID format rejoinCodes (containing dashes). This blocks attackers from using MongoDB accountIds as rejoinCodes to hijack logged-in users' disconnected sessions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 076f9ee commit 0f39af8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ws/classes/Player.js

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

0 commit comments

Comments
 (0)