Closed sherlock-admin3 closed 2 months ago
1 comment(s) were left on this issue during the judging contest.
infect3d commented:
user input error are invalid
Invalid, user is not expected to interact with liquidation pair directly, but instead go through the router, so this would be user input error since the necessary safety checks is present in the router.
ydlee
medium
TpdaLiquidationPair.swapExactAmountOut
does not refund excess inTokens if not called fromTpdaLiquidationRouter
.Summary
If
TpdaLiquidationPair.swapExactAmountOut
is not called fromTpdaLiquidationRouter
, the amount of tokens being swapped in must be sent to the target before calling this function. The amount of tokens sent in advance may exceed the actual amount needed for the swapping, but the excess tokens are not returned to user, causing the user to suffer a loss of tokens.Vulnerability Detail
If
TpdaLiquidationPair.swapExactAmountOut
is called from liquidation router, the_flashSwapData
parameter will hold user's address, and the right amount of in tokens needed for the swapping will be transfered to the target in theflashSwapCallback
(L154). This calling path is fine.If
TpdaLiquidationPair.swapExactAmountOut
is NOT called from liquidation router, the user should transfer some amount of in tokens to the target in advance, and that amount (possibly_amountInMax
) usually exceeds the actual amount needed to ensure a successful swap (L134). However, the excess in tokens are not refunded to user after the swapping, causing the user to suffer a loss of tokens.https://github.com/sherlock-audit/2024-05-pooltogether/blob/main/pt-v5-tpda-liquidator/src/TpdaLiquidationPair.sol#L122-L167
Impact
Users may suffer a loss of tokens if
TpdaLiquidationPair.swapExactAmountOut
is not called from liquidation router.Code Snippet
https://github.com/sherlock-audit/2024-05-pooltogether/blob/main/pt-v5-tpda-liquidator/src/TpdaLiquidationPair.sol#L122-L167
Tool used
Manual Review
Recommendation
Refund the excess in tokens if
TpdaLiquidationPair.swapExactAmountOut
is not called from liquidation router.