uniswap addLiquidity and swap may be permanent DOS #506
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#L200-L207
Vulnerability details
Impact
When invoke
addLiquidity
in uniswap amo contract, tokens will not necessarily be spent out, and the remaining tokens will cause allowance to be non-zero.When invoke
addLiquidity
orswap
again,safeApprove
will revert, resulting in DOS. and DOS is permanent sinceapproveContractToSpend
cannot reset allowance to zero.The owner can only withdraw funds through
emergencyWithdraw
and redeploy the contract.Proof of Concept
Apply the following patch, which contains fixes for POC and import issues.
Note that the effective attack point here is not that the owner entered the wrong token amount proportion when calling addLiquidity, but that the malicious attacker can directly manipulate the uniswap pool and carry out operations such as swap to disrupt the token amount proportion.
Tools Used
Foundry
Recommended Mitigation Steps
allowance should be reset before or after each call to addLiquidity
Assessed type
DoS
The text was updated successfully, but these errors were encountered: