Skip to content

Reject sign exact solana tx in sign msg request#1152

Open
0xh3rman wants to merge 1 commit into
mainfrom
reject-sol-tx-msg-sign
Open

Reject sign exact solana tx in sign msg request#1152
0xh3rman wants to merge 1 commit into
mainfrom
reject-sol-tx-msg-sign

Conversation

@0xh3rman
Copy link
Copy Markdown
Collaborator

@0xh3rman 0xh3rman commented May 24, 2026

Summary

  • Reject Solana signMessage payloads that decode as serialized transactions or bare transaction messages.
  • Route Gemstone Base58 message signing through SolanaChainSigner so WalletConnect Solana message signing uses the same guard.
  • Keep transaction payload detection internal to gem_solana instead of expanding the public API surface.

Root Cause

Solana signMessage could receive bytes that are actually a transaction or transaction message. Signing those bytes through the message path can produce a signature suitable for transaction signing, so the signer now rejects those payloads and points callers to signTransaction.

Validation

  • cargo check -p gemstone
  • just format
  • cargo clippy -p gem_solana --features signer -- -D warnings
  • cargo clippy -p gemstone -- -D warnings
  • just test gem_solana
  • just test gemstone

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a safeguard in the Solana signer to prevent signing serialized transactions through the sign_message interface, ensuring stricter validation via new is_transaction_bytes and try_decode_transaction_bytes functions. It also refactors the MessageSigner to utilize GemChainSigner for Base58 signing. Feedback was provided regarding a security risk where calling .to_vec() on private keys creates non-zeroized copies in memory, potentially exposing sensitive data.

Comment thread gemstone/src/message/signer.rs Outdated
@0xh3rman 0xh3rman marked this pull request as draft May 24, 2026 13:58
@0xh3rman 0xh3rman marked this pull request as ready for review May 24, 2026 14:54
@0xh3rman 0xh3rman force-pushed the reject-sol-tx-msg-sign branch from dc9e3af to b7611e9 Compare May 26, 2026 13:24
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.

1 participant