Submitted by 0xAsen, also found by attentioniayn, DanielArmstrong, jkk812812, kutugu, Rampage, t0x1c, tallo, Walodja1987, and zraxx
https://github.com/code-423n4/2025-01-iq-ai/blob/main/src/LiquidityManager.sol#L116-L117
https://github.com/code-423n4/2025-01-iq-ai/blob/main/src/LiquidityManager.sol#L141
The LiquidityManagers liquidity migration function, moveLiquidity() is susceptible to a DOS attack that any malicious attacker can perform. 
The reason for this is that moveLiquidity() relies on the raw ERC20 balance of the currency token held by the contract to determine the amount of agent token liquidity to add. In particular, the function calculates the currency token balance via:
This design assumes that the only currency tokens held by the LiquidityManager are those coming from the controlled bootstrap pool. However, an attacker can directly transfer extra currency tokens (e.g., IQ tokens) into the LiquidityManager.
This injection increases the raw balance reported by balanceOf(address(this)), causing the computed liquidityAmount  which represents the amount of agent tokens required for migration to be artificially inflated.
When the LiquidityManager then attempts to transfer agent tokens to add liquidity (via a subsequent call to addLiquidityToFraxswap()), the computed amount exceeds the actual agent token balance held by the contract. This results in a failure (an ERC20InsufficientBalance revert) during the migration process, effectively causing a denial-of-service (DoS) that blocks liquidity migration and disrupts normal protocol operations.
Impact:
Impact: High
Likelihood: Medium as it requires an attacker to spend funds. How well-funded he must be depends on the exact amount of tokens that will be used in a real environment and how willing he is to cause damage to the protocol and its users (a competitor or someone else with malicious intent). 
Lets look at the relevant parts of the source code. A coded POC is supplied after.
LiquidityManager.sol, moveLiquidity():
We can see that the function relies on the raw currency tokens balance of the contract and uses that to calculate liquidityAmount - the amount of agent tokens to add as liquidity to Fraxswap.
addLiquidityToFraxswap():
Now, if the liquidityAmount has been inflated by performing the attack, this line will fail if the contract doesnt have enough balance:
To demonstrate this vulnerability, heres a coded POC that you can add to MoveLiquidityTest.sol.
Run it via forge test --match-test test_MoveLiquidity_TokenInjection -vvv.
With that implementation, the test fails because the manager contract doesnt have enough agent token balance:
[FAIL. Reason: ERC20InsufficientBalance(0x20518cf72FF021e972F704d5B56Ab73FC163713d, 62348026684955421160920257 [6.234e25], 62348026684955421403284271 [6.234e25])] test_MoveLiquidity_TokenInjection() (gas: 48955838)
To verify that this test works otherwise, change this line:
deal(address(currencyToken), attacker, 10_000_000e18); 
to
deal(address(currencyToken), attacker, 9_000_000e18);
by decreasing the amount of currency tokens the attacker adds, the test and the migration will be successful.
Summary:
In our testing environment, when the attacker transfers 9,000,000 IQ tokens to the LiquidityManager, the migration process succeeds (albeit with an artificially manipulated price). However, when the attacker increases the injection to 10,000,000 IQ tokens, the computed liquidity amount exceeds the actual agent token balance held by the LiquidityManager. This results in an ERC20InsufficientBalance error during the liquidity migration step, effectively causing the process to revert.
(Note: The detailed logs and the failing transaction trace confirm that the agent token transfer reverts because the required amount is slightly higher than available.)
Calculate the liquidity amount based on the currency amount that was received by the bootstrap pool. Proposed fix:
That way the attack wouldnt work, and theres also no risk of tokens getting left in the manager contract as you transfer them to the agent either way:
Denett (IQ AI) commented:
tom2o17 (IQ AI) commented:
0xnev (judge) decreased severity to Medium and commented:
tom2o17 (IQ AI) mitigated:
Status: Mitigation confirmed.
