addLiquidity does not reset approval if not all tokens were added to liquidity pool #1618
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-1782
edited-by-warden
sufficient quality report
This report is of sufficient quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/amo/UniV2LiquidityAmo.sol#L189-L250
https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/amo/UniV3LiquidityAmo.sol#L155-L211
Vulnerability details
Impact
Unused approval amounts can accrue over time, leading to large Uniswap approval.
Proof of Concept
In
addLiquidity()
, UniV2LiquidityAmo contract approve UniswapV2 AMM router to spend amont of tokenA and tokenB:Then call AMM router to add liqiudity:
But when
tokenAUsed < tokenAAmount
ortokenBUsed < tokenBAmount
, unused approval still exists and contract doesn't reset to zero.For UniV3LiquidityAmo.sol is same way as UniV2LiquidityAmo.sol
Recommended Mitigation Steps
If
tokenAUsed < tokenAAmount
ortokenBUsed < tokenBAmount
reset AMM router approval to zero.Similar Issues:
Malt Finance contest (M-23)
Assessed type
Other
The text was updated successfully, but these errors were encountered: