Skip to content

Fix errors caused by missing signature in packet player_chat - #1511

Merged
u9g merged 1 commit into
PrismarineJS:masterfrom
u9g:fix/player-chat-missing-signature
Aug 16, 2026
Merged

Fix errors caused by missing signature in packet player_chat#1511
u9g merged 1 commit into
PrismarineJS:masterfrom
u9g:fix/player-chat-missing-signature

Conversation

@u9g

@u9g u9g commented Aug 16, 2026

Copy link
Copy Markdown
Member

Replaces #1509 (original by @TAOtxi, branch became unpushable after maintainer edits were disabled).

Problem

On offline servers (tested on 1.21.11), running bot.chat('/w xx something') causes the bot to receive a player_chat packet without a signature attribute, which raises an error at src/client/chat.js:199:

const verified = !packet.unsignedChatContent && updateAndValidateSession(packet.senderUuid, packet.plainMessage, packet.signature, packet.index, packet.previousMessages, packet.salt, packet.timestamp) && !expired

packet.signature is declared as option in the protocol data, so it is undefined when the server does not sign the message. updateAndValidateSession then passes it to crypto.verify('RSA-SHA256', ...), which throws a TypeError and kills the packet handler before playerChat is emitted.

Fix

Short-circuit on a missing signature before attempting validation, matching vanilla behavior:

  • PlayerChatMessage#verify null-checks the signature before verifying (this.signature != null && ...)
  • ChatTrustLevel#evaluate treats a missing signature as NOT_SECURE — the message is still displayed, just flagged; it is never an error condition

With this change, verified is false for unsigned messages and the playerChat event still fires.

The same guard is not needed in the 1.19.1 chainedChatWithHashing branch, where signature is declared as a required buffer in the protocol data.

@u9g
u9g merged commit f42801d into PrismarineJS:master Aug 16, 2026
34 checks passed
@u9g
u9g deleted the fix/player-chat-missing-signature branch August 16, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants