-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
addLiquidity() safeApprove() the second execution may revert #1782
Comments
bytes032 marked the issue as duplicate of #928 |
bytes032 marked the issue as low quality report |
bytes032 marked the issue as sufficient quality report |
bytes032 marked the issue as not a duplicate |
bytes032 marked the issue as duplicate of #1455 |
bytes032 marked the issue as not a duplicate |
bytes032 marked the issue as primary issue |
This issue and its duplicates contain all the occurrences of: Note: It's reported as L from the bot. |
psytama (sponsor) confirmed |
The finding is OOS |
GalloDaSballo marked the issue as unsatisfactory: |
Lines of code
https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/amo/UniV2LiquidityAmo.sol#L200
Vulnerability details
Impact
In
UniV2LiquidityAMO.addLiquidity()
useIERC20WithBurn(addresses.token).safeApprove()
The
safeApprove()
method must satisfy that all previous allowances must be used up or it will revertBut in
IUniswapV2Router.addLiquidity()
, not all of thetokenA/tokenB
allowances will be used up.This causes the second execution of
addLiquidity()
torevert
whensafeApprove()
doesn't use up all the allowances.Proof of Concept
safeApprove()
It must be ensured that previous allowances must be used upbut
addLiquidity()
It doesn't use up the entire allowance.https://github.com/Uniswap/v2-periphery/blob/0335e8f7e1bd1e8d8329fd300aea2ef2f36dd19f/contracts/UniswapV2Router02.sol#L71
So on the second execution,
UniV2LiquidityAMO.addLiquidity()
willrevert
test POC
The following code demonstrates that the second time
addLiquidity()
isrevert
withSafeERC20: approve from non-zero to non-zero allowance
add to Periphery.t.sol
Tools Used
Recommended Mitigation Steps
use
safeIncreaseAllowance()
instead ofsafeApprove()
Assessed type
ERC20
The text was updated successfully, but these errors were encountered: