Open c4-bot-9 opened 8 months ago
0xEVom marked the issue as primary issue
0xEVom marked the issue as high quality report
kalinbas (sponsor) confirmed
Aha, although the debate over such issues continues, according to the current C4 rules, it's valid M.
jhsagd76 marked the issue as satisfactory
jhsagd76 marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/transformers/AutoCompound.sol#L159-L172 https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/V3Vault.sol#L1032-L1074
Vulnerability details
The protocol is using
block.timestamp
as thedeadline
argument while interacting with the Uniswap NFT Position Manager, which completely defeats the purpose of using a deadline.Actions in the Uniswap NonfungiblePositionManager contract are protected by a deadline parameter to limit the execution of pending transactions. Functions that modify the liquidity of the pool check this parameter against the current block timestamp in order to discard expired actions.
These interactions with the Uniswap position are present throughout the code base, in particular and not only in the functions
V3Utils::_swapAndMint
,Automator::_decreaseFullLiquidityAndCollect
,LeverageTransformer::leverageUp
.. Those functions call their corresponding functions in the Uniswap Position Manager, providing thedeadline
argument with their owndealine
argument.In the other hand,
AutoCompound::execute
andV3Vault::_sendPositionValue
functions provide block.timestamp as the argument for thedeadline
parameter in their call to the corresponding underlying Uniswap NonfungiblePositionManager contract.Using
block.timestamp
as the deadline is effectively a no-operation that has no effect nor protection. Sinceblock.timestamp
will take the timestamp value when the transaction gets mined, the check will end up comparingblock.timestamp
against the same value (see https://github.com/Uniswap/v3-periphery/blob/697c2474757ea89fec12a4e6db16a574fe259610/contracts/base/PeripheryValidation.sol#L7).Impact
Failure to provide a proper deadline value enables pending transactions to be maliciously executed at a later point. Transactions that provide an insufficient amount of gas such that they are not mined within a reasonable amount of time, can be picked by malicious actors or MEV bots and executed later in detriment of the submitter.
See this issue for an excellent reference on the topic (the author runs a MEV bot).
Tools Used
Manual review
Recommended Mitigation Steps
As done in the
LeverageTransformer::leverageUp
andV3Utils::_swapAndIncrease
functions, add a deadline parameter to theAutoCompound::execute
andV3Vault::_sendPositionValue
functions and forward this parameter to the corresponding underlying call to the Uniswap NonfungiblePositionManager contract.Assessed type
Other