Pools.removeLiquidity does not check that reserves.reserve1 >= PoolUtils.DUST at the end.
Vulnerability Details
Pools.removeLiquidity contains the following line:
require((reserves.reserve0 >= PoolUtils.DUST) && (reserves.reserve0 >= PoolUtils.DUST), "Insufficient reserves after liquidity removal");
It should be reserve1 instead of the second reserve0 after &&.
Impact
One of the invariants is broken, which may lead to different errors.
Proof of Concept
Place this in src/pools/tests/InflationAttack.t.sol and run COVERAGE="yes" forge test -f wss://ethereum-sepolia.publicnode.com -vvv --mc InflationAttack
Use reserve1 instead of the second reserve0 after &&.
Replace the line with require((reserves.reserve0 >= PoolUtils.DUST) && (reserves.reserve1 >= PoolUtils.DUST), "Insufficient reserves after liquidity removal");.
Lines of code
https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/pools/Pools.sol#L187
Vulnerability details
Summary
Pools.removeLiquidity
does not check thatreserves.reserve1 >= PoolUtils.DUST
at the end.Vulnerability Details
Pools.removeLiquidity
contains the following line:require((reserves.reserve0 >= PoolUtils.DUST) && (reserves.reserve0 >= PoolUtils.DUST), "Insufficient reserves after liquidity removal");
It should bereserve1
instead of the secondreserve0
after&&
.Impact
One of the invariants is broken, which may lead to different errors.
Proof of Concept
Place this in
src/pools/tests/InflationAttack.t.sol
and runCOVERAGE="yes" forge test -f wss://ethereum-sepolia.publicnode.com -vvv --mc InflationAttack
Tools Used
Manual review.
Recommended Mitigation Steps
Use
reserve1
instead of the secondreserve0
after&&
. Replace the line withrequire((reserves.reserve0 >= PoolUtils.DUST) && (reserves.reserve1 >= PoolUtils.DUST), "Insufficient reserves after liquidity removal");
.Assessed type
Invalid Validation