IndexPool pow overflows when weightRatio > 10.
The IndexPool contract's price calculation uses a pow function that overflows when the weight ratio between tokens is large (e.g., 10). This causes all swap transactions to revert, making the pool unusable for trading even though liquidity can still be provided.
Submitted by broccoli
Impact
In the IndexPool contract, pow is used in calculating price. (IndexPool.sol L255-L266). However, Pow is easy to cause overflow. If the weightRatio is large (e.g. 10), there’s always overflow.
Lp providers can still provide liquidity to the pool where no one can swap. All pools need to redeploy. I consider this a high-risk issue.
Proof of concept
It’s easy to trigger this bug by deploying a 1:10 IndexPool.
deployed_code = encode_abi(["address[]","uint136[]","uint256"], [
(link.address, dai.address),
(10**18, 10 * 10**18),
10**13
])
tx_hash = master_deployer.functions.deployPool(index_pool_factory.address, deployed_code).transact()
Transactions would be reverted when buying link with dai.
Recommended Mitigation Steps
The weightRatio is an 18 decimals number. It should be divided by (BASE)^exp. The scale in the contract is not consistent. Recommend the dev to check all the scales/ decimals.
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 pow function's exponentiation overflows because the weight ratio is not scaled consistently with the base used in the calculation.
Impact
All swap transactions revert, so the pool is unusable for trading and must be redeployed, though liquidity providers can still add funds.
What the attacker needed
Deploy an IndexPool with weight ratio > 10
The fix
The weight ratio should be divided by the base raised to the exponent to keep scales consistent, and all scales and decimals should be checked.
How it was found
- Deploy an IndexPool with a 1:10 weight ratio between two tokens.
- Attempt to swap one token for the other.
- The transaction reverts due to overflow in the pow calculation.
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 pool lets people trade between two tokens. The code that sets the price uses a maths operation that breaks when the ratio between the two tokens is big, so every trade fails. People can still put money in, but no one can take it out by trading.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.