SwapAction's newly implemented Kyber swaps lack slippage protection #29
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
🤖_13_group
AI based duplicate group recommendation
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-10-loopfi/blob/d219f0132005b00a68f505edc22b34f9a8b49766/src/proxy/SwapAction.sol#L293-L305
Vulnerability details
Proof of Concept
Previously
SwapAction
only included 4 swap options, however with the current scope we now have five, see https://github.com/code-423n4/2024-10-loopfi/blob/d219f0132005b00a68f505edc22b34f9a8b49766/src/proxy/SwapAction.sol#L21-L28enum SwapProtocol { BALANCER, UNIV3, PENDLE_IN, PENDLE_OUT, + KYBER }
Now all these previous implementations of querying the swap protocol includes a slippage protection, for .eg if uniswap is to be used we enforce it by and :
https://github.com/code-423n4/2024-10-loopfi/blob/d219f0132005b00a68f505edc22b34f9a8b49766/src/proxy/SwapAction.sol#L319-L353
Similarly if it's a join via pendle, the minOut parameter is sued to protect users from unfair slippage, see https://github.com/code-423n4/2024-10-loopfi/blob/d219f0132005b00a68f505edc22b34f9a8b49766/src/proxy/SwapAction.sol#L374-L382
The above is the case for all other swap implementations in the swapAction.sol.
Issue however is that the new implementation of swaps via Kyber router do not include any slippage whatsoever, see https://github.com/code-423n4/2024-10-loopfi/blob/d219f0132005b00a68f505edc22b34f9a8b49766/src/proxy/SwapAction.sol#L293-L305
The above method is used to perform a swap using Kyber's
MetaAggregationRouterV2
, and the amount of tokens received from the swap is returned viaabi.decode(result, (uint256))
as hinted earlier on though, there is no check that this value is acceptable by the initiator of the swap just as with other swap implementations.Impact
Loss of funds for swap initiators considering even if an unacceptable amount of tokens is returned after the swap on Kyber no reverts happen.
Alternatively check the received tokens against the
limit
in the swapParams: https://github.com/code-423n4/2024-10-loopfi/blob/d219f0132005b00a68f505edc22b34f9a8b49766/src/proxy/SwapAction.sol#L36-L50Recommended Mitigation Steps
Accept a
minOut
param for Kyber swaps to and check the value fromabi.decode(result, (uint256))
to be above thisminOut
value.Assessed type
Other
The text was updated successfully, but these errors were encountered: