node/solana: base58-decode websocket account pubkey#4894
Open
peaktwilight wants to merge 1 commit into
Open
Conversation
The Pythnet account-subscription websocket path built the account PublicKey with solana.PublicKeyFromBytes([]byte(value.Pubkey)), but value.Pubkey is a base58-encoded string. Casting the string to a byte slice reinterprets the base58 text as raw key bytes, producing an incorrect PublicKey. This key is used as the observation TxID on the account-based path, so the effect is a wrong/garbled TxID in emitted observations and logs. It does not affect the VAA digest (derived from emitter, sequence and payload), so this is a correctness/observability fix, not a consensus or security change. Decode the base58 string with solana.PublicKeyFromBase58 and surface any decode error, matching how pubkey strings are parsed elsewhere in the watcher. Add table-driven coverage that decodes real base58 account addresses, asserts the decoded key round-trips to its address while the old byte cast yields a different key, and drives processAccountSubscriptionData end to end so the emitted TxID matches the decoded pubkey and a non-base58 pubkey surfaces an error.
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.
The Pythnet account-subscription websocket path (processAccountSubscriptionData) built the account PublicKey with solana.PublicKeyFromBytes([]byte(value.Pubkey)), but value.Pubkey is a base58-encoded string (the pubkey field of the accountSubscribe JSON notification). Casting the string to []byte reinterprets the base58 text as raw 32-byte key material, producing an incorrect PublicKey.
This key becomes the observation TxID on the account-based path, so the effect is a wrong/garbled TxID in emitted observations and logs. It does not affect the VAA digest (derived from emitter, sequence and payload), so this is a correctness/observability fix, not a consensus or security change.
Fix: decode the base58 string with solana.PublicKeyFromBase58 and surface any decode error, matching how pubkey strings are parsed elsewhere in the watcher (config.go). Adds a table-driven test using real base58 pubkeys that fails against the pre-fix code.