fix: sync message signing — bind accounts, vault index, split discriminators#32
Open
0xLeo-sqds wants to merge 2 commits intofeat/resolved-signerfrom
Open
fix: sync message signing — bind accounts, vault index, split discriminators#320xLeo-sqds wants to merge 2 commits intofeat/resolved-signerfrom
0xLeo-sqds wants to merge 2 commits intofeat/resolved-signerfrom
Conversation
…nique discriminators Addresses three sync-path vulnerabilities: 1. remaining_accounts now included in signed hash (prevents account swap) 2. account_index now included in signed hash (prevents vault swap) 3. Split 'squads-sync' into 'sync_transaction_v2', 'sync_transaction_legacy', and 'sync_settings_tx_v2' (prevents cross-instruction replay)
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
Fixes three vulnerabilities in the sync transaction message signing path identified during audit review.
1. Remaining accounts not committed in signed message
External signers sign a hash that includes the instruction payload but not the account table those instructions operate on. A relayer who obtains valid signatures could swap
remaining_accounts(e.g. replace a destination token account) while reusing the same signatures, redirecting funds.Fix: hash each remaining account's pubkey and
is_writableflag into the signed message.2.
account_indexnot committed in signed messageaccount_indexdetermines which vault PDA gets signer authority for CPIs. It was passed as an instruction arg but never entered the signed hash. A relayer could change it to make a different vault sign.Fix: include
account_indexas a byte in the signed message.3. Shared discriminator between sync_transaction and sync_settings_transaction
Both used
"squads-sync"as the message prefix. A signature for one could theoretically replay against the other if the payload bytes happen to deserialize under both interpretations.Fix: split into three distinct slugs:
"sync_transaction_v2"— forsync_transaction_v2"sync_transaction_legacy"— for legacy sync transactions"sync_settings_tx_v2"— for sync settings transactionsScope
All three fixes are sync-path only. Async transactions store accounts on-chain and go through proposal/vote governance, so they're not affected.
Also removed dead code: the unused
create_signature_messagefunction.Files changed
Program:
messages.rs— replacedcreate_sync_consensus_messagewith 3 new functions, deleted deadcreate_signature_messagetransaction_execute_sync.rs— passesaccount_index+ execution accounts to new message fntransaction_execute_sync_legacy.rs— same, with sysvar offset computationsettings_transaction_sync.rs— uses new settings-specific message fnTests:
externalSignerSecurity.ts— updated sync message builderexternalSignerNoncePersistence.ts— updated sync message buildermixedSignerSync.ts— updated inline message constructionTest plan