Skip to content

Commit 8f1348e

Browse files
committed
solana: validate transceiver_message seed in redeem
1 parent 9a99fa3 commit 8f1348e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • solana/programs/example-native-token-transfers/src/instructions

solana/programs/example-native-token-transfers/src/instructions/redeem.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ pub struct Redeem<'info> {
4343
constraint = ValidatedTransceiverMessage::<NativeTokenTransfer<Payload>>::message(&transceiver_message.try_borrow_data()?[..])?.recipient_ntt_manager() == config.key().to_bytes() @ NTTError::InvalidRecipientNttManager,
4444
// NOTE: we don't replay protect VAAs. Instead, we replay protect
4545
// executing the messages themselves with the [`released`] flag.
46+
// Cryptographically bind this account to the instance: since
47+
// receive_message seeds transceiver_message with config.key(), a message
48+
// created for instance A cannot be passed here for instance B.
49+
seeds = [
50+
ValidatedTransceiverMessage::<NativeTokenTransfer<Payload>>::SEED_PREFIX,
51+
config.key().as_ref(),
52+
ValidatedTransceiverMessage::<NativeTokenTransfer<Payload>>::from_chain(&transceiver_message)?.id.to_be_bytes().as_ref(),
53+
ValidatedTransceiverMessage::<NativeTokenTransfer<Payload>>::message(&transceiver_message.try_borrow_data()?[..])?.ntt_manager_payload().id.as_ref(),
54+
],
55+
seeds::program = transceiver.transceiver_address,
56+
bump,
57+
// `owner` is implied by the seeds check above (a valid PDA of
58+
// `transceiver.transceiver_address` must be owned by it), but kept
59+
// here for clarity.
4660
owner = transceiver.transceiver_address
4761
)]
4862
/// CHECK: `transceiver_message` has to be manually deserialized as Anchor

0 commit comments

Comments
 (0)