Comparing the before and after balance of the swap call for the swapped amount can be exploited to escape the exchangeFee by wrapping the actual swap inside a fake swap.
Vulnerability Detail
The attacker can reenter with another CardTopupPermit() -> _processTopup() -> IExchangeProxy#executeSwapDirect() at L174 to claw back the fee:
Swap minAmount with 1inch, inside the 1inch swap at ExchangeProxy.sol#L174, reenter and HardenedTopupProxy.sol#CardTopupPermit();
The inner swap is the actual amount: $1M, which should pay for $1000exchangeFee;
After the inner swap, amountReceived includes the $1000exchangeFee, which will be sent back to the user.
As a result, the user successfully escaped most of the exchangeFee.
WATCHPUG
medium
exchangeFee
can be escapedSummary
Comparing the before and after balance of the swap call for the swapped amount can be exploited to escape the
exchangeFee
by wrapping the actual swap inside a fake swap.Vulnerability Detail
The attacker can reenter with another
CardTopupPermit() -> _processTopup() -> IExchangeProxy#executeSwapDirect()
at L174 to claw back the fee:ExchangeProxy.sol#L174
, reenter andHardenedTopupProxy.sol#CardTopupPermit()
;$1M
, which should pay for$1000
exchangeFee
;amountReceived
includes the$1000
exchangeFee
, which will be sent back to the user.As a result, the user successfully escaped most of the
exchangeFee
.Impact
User can escape the
exchangeFee
.Code Snippet
https://github.com/sherlock-audit/2022-10-mover/blob/main/cardtopup_contract/contracts/HardenedTopupProxy.sol#L336-L343
https://github.com/sherlock-audit/2022-10-mover/blob/main/cardtopup_contract/contracts/ExchangeProxy.sol#L160-L185
Tool used
Manual Review
Recommendation
Consider adding
nonReentrant()
modifier to all the 3 non-view methods in theHardenedTopupProxy
: