Overflow in the mint function of IndexPool causes LPs’ funds to be stolen
The mint function in IndexPool allowed an attacker to overflow the balance check by supplying a very large amountIn, letting them mint a huge number of LP tokens without providing liquidity. The attacker could then burn those tokens to steal other liquidity providers' funds.
Submitted by broccoli, also found by WatchPug
Impact
It is possible to overflow the addition in the balance check (i.e., _balance(tokenIn) >= amountIn + reserve) in the mint function by setting the amountIn to a large amount. As a result, the attacker could gain a large number of LP tokens by not even providing any liquidity. The attacker’s liquidity would be much greater than any other LPs, causing him could effectively steal others’ funds by burning his liquidity (since the funds he receives are proportional to his liquidity).
Proof of Concept
Referenced code:
Recommended Mitigation Steps
Consider removing the uncheck statement to prevent integer overflows from happening.
FWIW The problem here isn’t that we used unchecked but that we didn’t cast amountIn to uint256. It’s possible to overflow uint120 but not uint256.
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
Root cause
Likely the addition in the balance check was performed in an unchecked block without casting amountIn to uint256, allowing an integer overflow.
Impact
An attacker could gain a large number of LP tokens without providing liquidity and then steal other LPs' funds by burning those tokens.
What the attacker needed
Ability to call mint with a large amountIn
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.
A smart contract lets people add funds (liquidity) and get tokens representing their share. A check that was supposed to ensure the person added enough funds could be tricked by giving a huge number, causing the check to pass incorrectly. The attacker then got a huge share and could take other people's money.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.