Fix errors caused by missing signature in packet player_chat - #1511
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 aplayer_chatpacket without asignatureattribute, which raises an error atsrc/client/chat.js:199:packet.signatureis declared asoptionin the protocol data, so it isundefinedwhen the server does not sign the message.updateAndValidateSessionthen passes it tocrypto.verify('RSA-SHA256', ...), which throws aTypeErrorand kills the packet handler beforeplayerChatis emitted.Fix
Short-circuit on a missing signature before attempting validation, matching vanilla behavior:
PlayerChatMessage#verifynull-checks the signature before verifying (this.signature != null && ...)ChatTrustLevel#evaluatetreats a missing signature asNOT_SECURE— the message is still displayed, just flagged; it is never an error conditionWith this change,
verifiedisfalsefor unsigned messages and theplayerChatevent still fires.The same guard is not needed in the 1.19.1
chainedChatWithHashingbranch, wheresignatureis declared as a required buffer in the protocol data.