Potential lock of rewards in the custody contracts
The custody contract's swap function only handles the reply when the last sub-message succeeds, so if that swap fails, the swapped rewards remain stuck in the contract. An attacker could not directly exploit this, but users may be unable to receive rewards during periods when the last swap consistently fails.
Submitted by broccoli
The swap_to_stable_denom function in the custody contracts swaps all other native tokens into a specific one. The function creates swap messages for all the other native tokens and adds them as sub-messages, and handles the reply only when the last sub-message succeeds. Upon receiving the reply, the contract sends the swapped tokens (i.e., rewards) to the overseer contract.
In cases where the last sub-message fails, the custody contract will not receive a reply, and therefore the rewards are left in the contract. The rewards are locked in the contract until someone triggers swap_to_stable_denom again, and the last swap succeeds. However, if the last swap consistently fails in some period for any reason, the total rewards will be locked in the contract during that period. As a result, users cannot get the rewards they are supposed to receive in that period.
Proof of Concept
Referenced code:
custody_beth/src/distribution.rs#L110-L115
custody_bluna/src/distribution.rs#L109-L114
Recommended Mitigation Steps
Consider handling the reply on either success or failure, i.e., using ReplyOn::Always, to avoid the failure of the swap to cause tokens to be locked.
bitn8 (Anchor) disagreed with severity
Alex the Entreprenerd (triage) commented:
Reliant on external conditions. Severity seems appropriate.
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 contract only handles the reply when the last sub-message succeeds, so a failure leaves the swapped tokens in the contract.
Impact
If the last swap consistently fails, rewards could be locked in the contract during that period, and users cannot get the rewards they are supposed to receive.
What the attacker needed
Last swap consistently fails
The fix
The reply should be handled on both success and failure, for example by using ReplyOn::Always, so that a failed swap does not lock tokens.
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.
A smart contract swaps several tokens and only checks the result of the final swap. If that final swap fails, the contract never sends the swapped tokens (rewards) to the overseer contract, so they stay stuck. This means users might not get their rewards until a later swap succeeds.
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.