User forfeits accumulated, unclaimed UniV3 fees upon staking with UniswapV3Staker
#579
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
grade-c
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-05-maia/blob/main/src/uni-v3-staker/UniswapV3Staker.sol#L376-L390
Vulnerability details
As is stated in the Maia docs, staked positions in
UniswapV3Staker
"will give up any fees until they unstake". However, the docs do not mention that any accumulated fees earned by the position prior to staking are also forfeited toUniswapV3Staker
. This results in a direct loss of user funds. Given the misleading statement in the docs, I would argue that this is not a simple case of user error.Impact
When calling
UniswapV3Staker#unstake
, the contract callsNonFungiblePositionManager#collect
, which collects the fees earned up to a maximum amount, and sends them to the recipient (Uniswap docs).In this case,
type(uint128).max
is passed meaning that all available fees will be collected and sent tobribeAddress
. This indeed includes any fees that were earned but not collected prior to staking.Due to this issue, users who interact with the
UniswapV3Staker
will give up more Uniswap fees than they expect, which will accumulate in thebribeAddress
at the time of unstaking. This can either be a small amount, if the user mints the position NFT usingNonFungiblePositionManager
and then quickly sends it toUniswapV3Staker
, or a large amount, if the user held the position for a long time before sending it toUniswapV3Staker
. This value leak will affect every user who wishes to initiate a stake.Proof of Concept
Consider the following scenario:
NonFungiblePositionManager
UniswapV3Staker
to stake itbribeAddress
, rather than just the fees earned during the stakebribeAddress
Tools Used
Manual review
Recommended Mitigation Steps
Either communicate clearly to the user that they ought to call
NonFungiblePositionManager#collect
on their NFT before staking it, or add a call to collect inUniswapV3Staker#onERC721Received
and refund the fees collected to the caller before staking the NFT. Note that the latter approach would likely be gas intensive, so the tradeoff should be evaluated accordingly.Assessed type
Uniswap
The text was updated successfully, but these errors were encountered: