Incorrect Formate for transaction building, and transaction executions In Solana will lead to revert all execute Operations
The Solana signer code marks the destination program account as writable and the destination program PDA as non-writable, which is the reverse of what the on-chain Execute context expects. This causes all execute transactions to revert when the program tries to write to the PDA.
Source: https://github.com/sherlock-audit/2025-04-zetachain-cross-chain-judging/issues/113
This issue has been acknowledged by the team but won't be fixed at this time.
Found by
Al-Qa-qa
Affected Code
Description
When creating Execute Function in Solana, The Account structure us making destination_program with no mut flag (non-writable), and destination_program_pda with mut flag (writable)
programs/gateway/src/contexts.rs#Execute
pub struct Execute<'info> {
...
pub signer: Signer<'info>,
...
pub pda: Account<'info, Pda>,
/// The destination program.
/// CHECK: This is arbitrary program.
>> pub destination_program: AccountInfo<'info>,
...
#[account(
>> mut,
....
)]
>> pub destination_program_pda: UncheckedAccount<'info>,
}
But when constructing the tx by Solana Nodes, they are doing the reverse, by making the destination_program as writable and destination_program_pda as non-writable
node/zetaclient/chains/solana/signer/execute.go#createExecuteInstruction
predefinedAccounts := []*solana.AccountMeta{
solana.Meta(signer.relayerKey.PublicKey()).WRITE().SIGNER(),
solana.Meta(signer.pda).WRITE(),
solana.Meta(msg.To()).WRITE(), <<---------
solana.Meta(destinationProgramPda), <<---------
}
This will result in All transactions gets reverted, as the pda account is the account designed to be changed in the execution of on_call and this can be seen cealy in example folders
programs/examples/connected/src/lib.rs#on_call
pub fn on_call( ... ) -> Result<()> {
>> let pda = &mut ctx.accounts.pda;
// Store the sender's public key
>> pda.last_sender = sender;
// Convert data to a string and store it
let message = String::from_utf8(data).map_err(|_| ErrorCode::InvalidDataFormat)?;
>> pda.last_message = message;
// Transfer some portion of lamports transferred from gateway to another account
>> pda.sub_lamports(amount / 2)?;
}
Destination_PDA is the trusted account, that Cross Chain Apps depend on changing it. But as all Relayer txs are signed either in execute function, do not make it as writable, most of execute signed txs by the Node Relayers will get reverted as it will try to write on unwritable account leading to revert in execution
Recommendations
- in
execute.goremove WRITE frommsg.To, which is thedestination_program, and it it todestinationProgramPda
diff --git a/node/zetaclient/chains/solana/signer/execute.go b/node/zetaclient/chains/solana/signer/execute.go
index daf4009..5fa0b31 100644
--- a/node/zetaclient/chains/solana/signer/execute.go
+++ b/node/zetaclient/chains/solana/signer/execute.go
@@ -85,8 +85,8 @@ func (signer *Signer) createExecuteInstruction(msg contracts.MsgExecute) (*solan
predefinedAccounts := []*solana.AccountMeta{
solana.Meta(signer.relayerKey.PublicKey()).WRITE().SIGNER(),
solana.Meta(signer.pda).WRITE(),
- solana.Meta(msg.To()).WRITE(),
- solana.Meta(destinationProgramPda),
+ solana.Meta(msg.To()),
+ solana.Meta(destinationProgramPda).WRITE(),
}
allAccounts := append(predefinedAccounts, msg.RemainingAccounts()...)
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The client-side account metadata marks the destination program as writable and the destination program PDA as read-only, opposite to the on-chain Execute struct which requires the PDA to be writable.
Impact
All execute transactions signed by node relayers will revert, preventing cross-chain calls from completing.
What the attacker needed
Node relayer signs execute tx
The fix
The signer code should be changed to remove the writable flag from the destination program and add it to the destination program PDA, but the team has acknowledged the issue and will not fix it at this time.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In Solana, each account in a transaction has flags saying whether it can be written to. The client code that builds the transaction set these flags backwards for two accounts. When the program then tries to save data into the account it thinks is writable, the transaction fails and is reverted.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.