Skip to content

fix(solana): preserve original bytes when signing messages - #507

Open
notorious-d-e-v wants to merge 5 commits into
MetaMask:mainfrom
notorious-d-e-v:fix/solana-preserve-message-bytes
Open

notorious-d-e-v wants to merge 5 commits into
MetaMask:mainfrom
notorious-d-e-v:fix/solana-preserve-message-bytes

Conversation

@notorious-d-e-v

@notorious-d-e-v notorious-d-e-v commented Oct 23, 2026 •

Copy link
Copy Markdown

Summary

MetaMask can change binary Solana messages before signing, then return the original bytes with a signature that does not match. This signs the exact requested bytes, blocks transaction messages from message-only signing, and shows binary data accurately so applications and users can check what was signed.

Changes

  • Decode Base64 directly to bytes for the shared single/batch signing helper. Preserve NUL bytes, invalid UTF-8 sequences, byte order marks, and Unicode text; return the exact signed message.
  • Reject compiled Solana transaction messages at both approval rendering and the signing authority. Transaction signing continues through its existing confirmation and scanning flow. Filter impossible headers and use Kit’s version-specific transaction size limits so large ordinary text remains signable.
  • Show the full Base64 payload with an explicit binary/hidden-data warning whenever text decoding would change or hide content. Keep valid Unicode and multiline text readable; show an escaped text preview alongside Base64 for hidden but byte-preserving UTF-8, including emoji sequences and CRLF. Add English and Spanish labels.
  • Cover legacy, v0, and codec-supported v1 transaction rejection, single/batch errors, distinct hidden-byte displays, binary preservation, and existing text/sign-in fixtures.

Validation

  • Full Solana package suite: 90 suites; 1,078 tests pass, 5 skipped, 1 todo. Coverage thresholds pass.
  • Solana Snap build, package TypeScript check, changed-source ESLint, and changelog validation pass.
  • An independent software-key reproduction confirms a compiled transfer message is refused by the fixed signing service and the previously identical NUL-byte displays now differ. No RPC or funded transaction is involved.
  • Rebased onto current main release commit 80b21f6; all five PR commits are SSH-signed.

Review

Claude Fable 5.1 was rerun at xhigh effort after the transaction guard and display fixes. The final read-only review found no remaining actionable P0–P3 findings. All prior findings and follow-up regressions were addressed; tests and builds were run separately by the author.

References

Fixes #506. Its browser evidence independently verifies the wallet-returned signature against converted bytes rather than the returned message. The regression tests use software keys; patched-extension and payment lifecycle testing remain separate.

Checklist

  • Updated tests and documentation
  • Updated the package changelog
  • Signed commits

@notorious-d-e-v
notorious-d-e-v force-pushed the fix/solana-preserve-message-bytes branch from 396b692 to c374e06 Compare October 24, 2026 11:05

This branch has not been deployed

No deployments
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.

Solana signMessage returns a signature invalid for its returned signedMessage on binary input (13.53.0)

1 participant