User may get less tokens than expected when collateral list order changes
The order of the collateral list can change when a collateral is revoked, but the redeem function expects the user's minimum output amounts to be in that same order. This can cause a user's redemption to succeed even if they receive less of a token than they intended.
Submitted by Lambda
https://github.com/AngleProtocol/angle-transmuter/blob/8a2c3aaf4bd054581b06d33049370a6f01b56d44/contracts/transmuter/libraries/LibSetters.sol#L123 https://github.com/AngleProtocol/angle-transmuter/blob/8a2c3aaf4bd054581b06d33049370a6f01b56d44/contracts/transmuter/facets/Redeemer.sol#L64
The order of ts.collateralList is not stable: Whenever LibSetters.revokeCollateral is used to revoke a collateral, it may change because of the swap that is performed. However, the function Redeemer.redeem relies on this order, as the user has to provide the minAmountsOut in the order of ts.collateralList. This can lead to situations where the user has crafted the minAmountsOut array when the order was still different, leading to unintended results (and potentially redemptions that the user did not want to accept). It also means that revoking a collateral can be challenging for the team / governance because it should never be done when a user has already prepared a redemption (either via the frontend which he had open or some other way to interact with the contract). But there is of course no way to know this.
Proof of Concept
Let’s say the system contains the collateral [tokenA, tokenB, tokenC]. normalizedStables for tokenA is 0. The user therefore does not want to receive tokenA (and will not receive anything for it). However, it is extremely important to him that he receives 100,000 of tokenC. He therefore crafts a minAmountsOut of [0, 10000, 100000]. Just before he submits the call, tokenA is removed from the system, resulting in the collateral array [tokenC, tokenB]. Even if the user only receives 50,000 tokens of tokenC, the call will therefore succeed.
Recommended Mitigation Steps
The problem could be alleviated a bit by checking the length of minAmountsOut (making sure it is not longer than ts.collateralList). However, that would not help if a collateral is revoked and a new one is added. Another solution would be to provide pairs of token addresses and amounts, which would solve the problem completely.
Picodes (Angle) confirmed and commented:
The mitigation doesn’t cost much and we will implement it. It’s really an edge case though.
PR: https://github.com/AngleProtocol/angle-transmuter/commit/f8d0bf7c4009586f7022d5929359041db3990175 Applies the suggested fix.
Status: Not fully mitigated. Full details in reports from Lambda and auditor0517.
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 uses a mutable list order to match user-supplied minimum amounts, without binding those amounts to specific token addresses.
Impact
A user could receive less of a desired token than their stated minimum, and revoking a collateral becomes risky while redemptions are pending.
What the attacker needed
User prepares a redemption; collateral list order changes before submission
The fix
The project applied a mitigation that checks the length of minAmountsOut, but the report notes this does not fully solve the problem; a complete fix would pair token addresses with amounts.
How it was found
- The system has collaterals tokenA, tokenB, tokenC; tokenA has zero normalized stables so the user expects nothing from it.
- The user prepares a minAmountsOut array in the order [tokenA, tokenB, tokenC] with a high minimum for tokenC.
- Before the user submits, tokenA is revoked, changing the collateral list to [tokenC, tokenB].
- The user's call still succeeds, but the minimum meant for tokenC is now applied to tokenB, so the user may receive less tokenC than intended.
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 lets users swap one token for a mix of others. The user says the least amount of each token they will accept, but they list these amounts in the same order as the contract's internal list of tokens. If that list gets reordered, the user's limits get applied to the wrong tokens, so they might accept a bad deal without realising.
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.