SUI TSS drained due to lack of refund when the `withdraw/withdraw_and_call()` PTB fails
The SUI gateway's withdraw_and_call mechanism bundles a gas refund withdrawal with a user callback in one atomic transaction block. If the callback reverts, the whole block fails and the gateway loses the gas it paid without being refunded, which can drain TSS funds.
0x73696d616f Follow with BrothersInCode
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-04-zetachain-cross-chain-judging/issues/80
This issue has been acknowledged by the team but won't be fixed at this time.
Found by
0x73696d616f, BrothersInCode
Summary
Firstly, SUI PTBs or 'Programmable Transaction Blocks' are atomic, that is, whenever a transaction in the bundle reverts, the whole bundle fails
If one transaction command fails, the entire block fails and no effects from the commands are applied.
The withdraw_and_call() mechanism on SUI, relies on a PTB consisting of a withdrawal and a on_call() function bundled together, link
a withdrawAndCall is a PTB transaction that contains a withdraw_impl call and a on_call call
The withdraw() function, used to refund the gas paid to the gateway, directly transfers it as the first tx of the PTB:
entry fun withdraw<T>(
gateway: &mut Gateway,
amount: u64,
nonce: u64,
receiver: address,
gas_budget: u64,
cap: &WithdrawCap,
ctx: &mut TxContext,
) {
let (coins, coins_gas_budget) = withdraw_impl<T>(gateway, amount, nonce, gas_budget, cap, ctx);
transfer::public_transfer(coins, receiver);
transfer::public_transfer(coins_gas_budget, tx_context::sender(ctx));
// Emit event
event::emit(WithdrawEvent {
coin_type: coin_name<T>(),
amount: amount,
sender: tx_context::sender(ctx),
receiver: receiver,
nonce: nonce,
});
}
Given these statements, it becomes clear that whenever the PTB fails on the on_call() step, the first withdraw() tx will also fail, and the gateway (TSS signer) doesn't get refunded, while having paid for the gas fees. This may happen without the failure on the node being caught when simulating the tx because on chain conditions on simulation and when it settles may be different (and can forcibly be different by an attacker frontrunning).
Root Cause
In node/zetaclient/chains/sui/signer/signer_tx.go, withdraw_and_call PTB will make the gateway run out of funds.
Internal Pre-conditions
None.
External Pre-conditions
None.
Attack Path
- User sends a cross chain withdrawal to SUI, triggering the
on_call()tx that reverts. - The node signs and sends the PTB, and at this point the tx in 1 doesn't revert (diff on chain conditions).
- The withdraw() tx goes through, but
on_call()reverts, so the whole PTB is aborted and the gateway loses gas fees without getting refunded.
Impact
TSS funds leak leading to insolvency and DoSed nodes.
PoC
See above.
Mitigation
Gas refund should be performed in a separate PTB so the TSS signer in the node always gets their gas refund.
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 gas refund withdrawal is included in the same atomic transaction block as the user callback, so a callback failure also rolls back the refund.
Impact
TSS funds could leak, potentially leading to insolvency and denial of service for nodes.
What the attacker needed
None
The fix
The gas refund should be performed in a separate transaction block so the TSS signer always receives it.
How it was found
- A user sends a cross-chain withdrawal to SUI that triggers an on_call transaction which reverts.
- The node signs and sends the PTB, and at that point the transaction does not revert due to different on-chain conditions.
- The withdraw transaction goes through, but on_call reverts, so the whole PTB is aborted and the gateway loses gas fees without getting refunded.
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.
On SUI, a group of transactions can be bundled so that either all succeed or none do. Here the refund of gas costs was bundled with a user action; if the user action fails, the refund is cancelled too, so the system that pays gas loses money each time.
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.