Open c4-bot-7 opened 2 months ago
alex-ppg marked the issue as selected for report
alex-ppg marked the issue as satisfactory
The Warden has identified that the slippage protections of the swap-out functions are incorrect and thus ineffective due to validating an incorrect amount, resulting in either incorrect successful executions or incorrect failed executions depending on the price relation between the two assets.
A medium-risk severity rating is appropriate given that a subset of the system's functionality is affected with slippage being the component affected.
After revisiting this submission in light of the comments shared in https://github.com/code-423n4/2024-08-superposition-findings/issues/53#issuecomment-2374785547, I am inclined to upgrade it to a high-risk severity rating as user funds are directly impacted.
alex-ppg changed the severity to 3 (High Risk)
Lines of code
https://github.com/code-423n4/2024-08-superposition/blob/4528c9d2dbe1550d2660dac903a8246076044905/pkg/sol/SeawaterAMM.sol#L317 https://github.com/code-423n4/2024-08-superposition/blob/4528c9d2dbe1550d2660dac903a8246076044905/pkg/sol/SeawaterAMM.sol#L339
Vulnerability details
Impact
swapOut functions have an invalid slippage check, causing user loss of funds.
Proof of Concept
In SeawaterAMM.sol,
swapOut5E08A399
andswapOutPermit23273373B
are intended to allow usdc(token1) -> pool(token0) swap with slippage check. See ISeawaterAMM's doc.However, both functions have incorrect slippage checks. (1) We see in
swapOut5E08A399
swapAmountOut
is used to check withminOut
. ButswapAmountOut
is actually usdc(token1), Not the output token(token0). This uses an incorrect variable to check slippage.(https://github.com/code-423n4/2024-08-superposition/blob/4528c9d2dbe1550d2660dac903a8246076044905/pkg/sol/SeawaterAMM.sol#L317)
For reference, in the swap facet,
swap_internal
called in the flow returnsOk((amount_0, amount_1))
. This meansswapAmountOut
refers to token1, the input token amount.(https://github.com/code-423n4/2024-08-superposition/blob/4528c9d2dbe1550d2660dac903a8246076044905/pkg/seawater/src/lib.rs#L194)
(2)
swapOutPermit23273373B
has the same erroneous slippage check.(https://github.com/code-423n4/2024-08-superposition/blob/4528c9d2dbe1550d2660dac903a8246076044905/pkg/sol/SeawaterAMM.sol#L339)
Invalid slippage checks will cause users to lose funds during swaps.
Tools Used
Manual
Recommended Mitigation Steps
Consider changing into:
Assessed type
Error