Open code423n4 opened 2 years ago
This is absolutely correct, but unfortunately there is no apparent viable on-chain solution. If we revert because slippage is too high, behavior would be inconsistent and UX would be bad, to say the least. If we instead choose to not sponsor because the slippage is too high, then sponsorship could be griefed severely (i.e. 'if we can't get at least X, then give the user nothing' is not a valid sponsorship policy).
Some things that make a sandwich attack less feasible however:
This is a good entrypoint for a future feature that gives sponsors better options, such as only sponsoring transfers for specific assets that they supply (i.e. so no swap is required).
cc @LayneHaber for thoughts. Because this essentially boils down to a feature request on behalf of sponsors - not a bug - going to close.
Reopening and leaving this as acknowledged.
Seeing as I can't verify if tokenExchange.swapExactIn
is indeed vulnerable to slippage, I will just side with the sponsor/warden on this one.
Lines of code
https://github.com/code-423n4/2022-06-connext/blob/b4532655071566b33c41eac46e75be29b4a381ed/contracts/contracts/core/connext/helpers/SponsorVault.sol#L187-L220
Vulnerability details
Impact
when code swaps tokens it should specify slippage but in
reimburseLiquidityFees()
code contract callstokenExchange.swapExactIn()
without slippage and it's possible to perform sandwich attack and make contract to swap on bad exchange rates and there is MEV.Proof of Concept
This is
reimburseLiquidityFees()
code inSponserVault
:As you can see there is no slippage defined when calling
swapExactIn()
can that swap could happen in any exchange rate. it's possible to perform sandwich attack and do large swap before and after the transaction and make users lose funds. and it's also MEV opportunity.Tools Used
VIM
Recommended Mitigation Steps
specify slippage when calling swap tokens.