Missing slippage parameter on Uniswap addLiquidity() function
The reLP function calls Uniswap's addLiquidity with zero minimum amounts, so the contract accepts any amount of tokens when providing liquidity. An attacker could exploit this to cause the contract to receive fewer LP tokens than fair market value.
juancito Follow with KrisApostolov, nemveer and 11 others
Originally disclosed on Code4rena
Submitted by juancito, also found by KrisApostolov, nemveer, RED-LOTUS-REACH, 0xmuxyz, ciphermarco, ladboy233, Bauchibred, Viktor_Cortess, 0xnev, ArmedGoose, 0x3b, ginlee, and mitko1111
The Uniswap addLiquidity() function expects the slippage params amountAMin, and amountBMin to be passed.
The reLP() sets those values as 0, which in other terms, means that the contract is ok with receiveing less amount of tokens than the fair market price when providing liquidity.
Impact
Less LP tokens will be received during the reLP() call, as it will accept any amount of tokens while adding liquidity to Uniswap.
Proof of Concept
The reLP() is used by the bond functions, and uses 0 for the amountAMin, and amountBMin values passed to the addLiquidity() function on the Uniswap router:
(, , uint256 lp) = IUniswapV2Router(addresses.ammRouter).addLiquidity(
addresses.tokenA,
addresses.tokenB,
tokenAAmountOut,
amountB / 2,
0, // @audit
0, // @audit
address(this),
block.timestamp + 10
);
This will make the function return less lp tokens than expected, while rebalancing.
Recommended Mitigation Steps
Set the amountAMin and amountBMin parameters to the expected minimum values.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
The contract could receive fewer LP tokens than expected during rebalancing, potentially allowing value extraction.
What the attacker needed
Attacker can influence Uniswap pool price
The fix
Set the amountAMin and amountBMin parameters to the expected minimum values.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you add liquidity to a decentralised exchange, you can set a minimum amount of tokens you are willing to accept to protect against price changes. Here, the code sets that minimum to zero, meaning it will accept any amount, even a very bad deal. This could let someone manipulate the price and make the contract lose value.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.