UniStaker Infrastructure - BAHOZ's results

Staking infrastructure to empower Uniswap Governance.

General Information

Platform: Code4rena

Start Date: 23/02/2024

Pot Size: $92,000 USDC

Total HM: 0

Participants: 47

Period: 10 days

Judge: 0xTheC0der

Id: 336

League: ETH

Uniswap Foundation

Findings Distribution

Researcher Performance

Rank: 18/47

Findings: 1

Award: $694.30

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

694.2987 USDC - $694.30

Labels

bug
grade-b
QA (Quality Assurance)
satisfactory
:robot:_34_group
duplicate-45
Q-24

External Links

Lines of code

https://github.com/code-423n4/2024-02-uniswap-foundation/blob/5a2761c8277541a24bc551fbd624413b384bea94/src/V3FactoryOwner.sol#L181-L205

Vulnerability details

Impact

Fee claimers can get a suboptimal payout, or claims can be reverted

Description

Users can call claimFees() on factory owner for a specific pool by passing the requested amounts and paying the payout amount.

Manually passing the requested token amounts may lead suboptimal results causing the fee claimer to get less then they should get or reverting the tx altogether if they ask for the actual maximum amount because of the gas savings on the pool contract.

Proof of Concept

protocolFees.token0 = 1e18 protocolFees.token1 = 2e18

Scenario 1: User calls claimFees with following params because of a calculation mistake _amount0Requested = 1e17 _amount1Requested = 2e17 User receives less than they should get and looses value

Scenario 2: User calls claimFees with max of the fee amount collected _amount0Requested = 1e18 _amount1Requested = 2e18 Because of the gas savings here: https://github.com/Uniswap/v3-core/blob/d8b1c635c275d2a9450bd6a78f3fa2484fef73eb/contracts/UniswapV3Pool.sol#L857 Although the call was valid, claim reverts with V3FactoryOwner__InsufficientFeesCollected

Scenario 3: User calls claimFees with max of the fee amount collected - 1 _amount0Requested = 1e18 - 1 _amount1Requested = 2e18 - 1 And if some large swap happens while the claim was in the mempool, the user will leave some fees in the pool

Tools Used

Manual review

  • Change claimFees() to accept _minAmount0 and _minAmount1 instead of requested amounts.
  • claimFees() makes a call to the pool to get the current fee amounts accrued in the pool
  • claimFees calls collectProtocol() with feeAmounts - 1
  • require returned fees from the pool is GTE to min amounts

Assessed type

Math

#0 - c4-judge

2024-03-07T12:42:39Z

MarioPoneder marked the issue as duplicate of #34

#1 - c4-judge

2024-03-14T01:38:37Z

MarioPoneder marked the issue as satisfactory

#2 - c4-judge

2024-03-26T23:00:07Z

MarioPoneder marked the issue as grade-b

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter