Due to the gas saving mechanism of the uniswap pool’s collectProtocol method, the auctions may often revert griefly. #372
Labels
bug
Something isn't working
duplicate-45
grade-b
Q-12
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2024-02-uniswap-foundation/blob/491c7f63e5799d95a181be4a978b2f074dc219a5/src/V3FactoryOwner.sol#L189-L195
https://github.com/Uniswap/v3-core/blob/d8b1c635c275d2a9450bd6a78f3fa2484fef73eb/contracts/UniswapV3Pool.sol#L857
https://github.com/Uniswap/v3-core/blob/d8b1c635c275d2a9450bd6a78f3fa2484fef73eb/contracts/UniswapV3Pool.sol#L862
Vulnerability details
Impact
When the user collects the fees collected by the current protocol, the
pool.collectProtocol
method will automatically reduce the fee amount by one instead of clearing the fee storage in order to save gas, which causes the verification ofV3FactoryOwner.claimFees
to fail and triggers theV3FactoryOwner__InsufficientFeesCollected
error.This results in auctions that may often revert griefly, affecting the interests of the auctioneer.
Proof of Concept
This is an interactive combination error involving two points:
UniswapV3Pool.collectProtocol
will automatically reduce the fee amount by one instead of clearing the storage.V3FactoryOwner.claimFees
will verify the collect fee amount, and the reduced amount will cause the transaction to be reverted.Why does this error often trigger griefly and affect the interests of the auctioneer? Let‘s take a look at the execution process:
UniswapV3Pool.protocolFees
, but is not aware of the existence of this issue. When the fee value exceedspayoutAmount
, the auctioneer passes the amount of fees obtained.The above process violates the principle of auction. A's tx is executed first but lose, while B's tx is executed after the fee is increased and wins the auction.
This is a specific example that affects the interests of the auctioneer. Due to the timing of transaction execution, the error is implicit and will not be discovered for a period of time, affecting the revenue of the auctioneer.
The following is the specific POC:
Tools Used
Foundry
Recommended Mitigation Steps
The verification of
V3FactoryOwner.claimFees
should take into account the gas saving mechanism ofUniswapV3Pool.collectProtocol
and be consistent with it to eliminate interactive combination errors.Assessed type
Context
The text was updated successfully, but these errors were encountered: