Repository navigation
fix(solana): preserve original bytes when signing messages - #507
Open
notorious-d-e-v wants to merge 2 commits into
Open
notorious-d-e-v wants to merge 2 commits into
notorious-d-e-v wants to merge 2 commits into
Conversation
notorious-d-e-v
force-pushed
the
fix/solana-preserve-message-bytes
branch
from
October 23, 2026 06:23
9b7fec7 to
396b692
Compare
3 of 4 tasks
This branch has not been deployed
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.
Summary
MetaMask can change binary Solana messages while converting them to text, then return the original message with a signature that does not match it. This fix signs the original bytes so applications can verify the returned signature correctly.
Explanation
The shared signing helper currently converts Base64 input to UTF-8 text before signing. The text decoder removes NUL bytes, replaces invalid UTF-8 sequences, and strips a leading byte order mark. The response nevertheless returns the unchanged Base64 input as
signedMessage.Decode Base64 directly to a byte array and pass those bytes to
createSignableMessage. BothsignMessageandsignMessagesuse this helper. Existing text-message and Sign-In With Solana fixtures remain valid.Regression tests cover NUL bytes, invalid UTF-8, a byte order mark, all 256 byte values, Unicode text, and batch signing. A separate test checks that moving a NUL byte changes the signature and prevents verification against the other message. No dependencies change.
Wallet confirmation rendering still converts messages to text; improving binary-message display is separate from this signature correctness fix.
Validation
WalletServicetests pass.Tested with Node.js 24.12.0 and Yarn 4.17.1 using local mock endpoints. No wallet approval or funded transaction was performed for these tests.
References
Fixes #506. The issue includes the supplied browser capture and independent verification of its actual wallet-returned signature.
Checklist