rebalance and rebalanceLite can be called by any user. Assets are taken from a user specified account address which has approved PerpDepository. If an address has a non-zero approval for PerpDepository, a frontrunner can use rebalance to transfer funds and profit by sandwiching the Uniswap pool swap.
Vulnerability Detail
When mint or redeem is called in UXDController, msg.sender is where the value is coming from. But rebalance allows for the caller to specify the account where funds are coming from. This means msg.sender can be any address. This allows for different scenarios where a frontrunner can profit with these steps.
a frontrunner detects a call of rebalance transaction in the mempool for a certain account address
the frontrunner duplicates the transaction but increases the gas amount (to allow frontrunning the original transaction) and changes the amountOutMinimum value to zero
the frontrunner can profit by sandwiching the Uniswap swap which now has no slippage setting
The user will lose value
Impact
An account that is used in rebalance can lose value
keccak123
high
User specified slippage allows frontrunning
Summary
rebalance
andrebalanceLite
can be called by any user. Assets are taken from a user specifiedaccount
address which has approved PerpDepository. If an address has a non-zero approval for PerpDepository, a frontrunner can userebalance
to transfer funds and profit by sandwiching the Uniswap pool swap.Vulnerability Detail
When
mint
orredeem
is called in UXDController,msg.sender
is where the value is coming from. Butrebalance
allows for the caller to specify theaccount
where funds are coming from. This meansmsg.sender
can be any address. This allows for different scenarios where a frontrunner can profit with these steps.rebalance
transaction in the mempool for a certain account addressamountOutMinimum
value to zeroImpact
An account that is used in
rebalance
can lose valueCode Snippet
rebalance
can be frontrun https://github.com/sherlock-audit/2023-01-uxd/blob/main/contracts/integrations/perp/PerpDepository.sol#L446Tool used
Manual Review
Recommendation
rebalance
andrebalanceLite
should usemsg.sender
to replace the function argument account address.