TimeswapConvenience.sol#borrowGivenDebt() Attacker can increase state.y to an extremely large value with a dust amount of assetOut
The borrowGivenDebt function in TimeswapConvenience.sol allows an attacker to set the pool's state.y to an extremely large value with a dust amount of assetOut. This can cause arithmetic overflows in core functions and let the attacker steal funds from lenders and liquidity providers.
Submitted by WatchPug
This issue is similar to the two previous issues related to state.y manipulation. Unlike the other two issues, this function is not on TimeswapPair.sol but on TimeswapConvenience.sol, therefore this can not be solved by adding onlyConvenience modifier.
Actually, we believe that it does not make sense for the caller to specify the interest they want to pay, we recommend removing this function.
Impact
- When
pool.state.yis extremely large, many core features of the protocol will malfunction, as the arithmetic related tostate.ycan overflow. For example:
LendMath.check(): https://github.com/code-423n4/2022-01-timeswap/blob/bf50d2a8bb93a5571f35f96bd74af54d9c92a210/Timeswap/Timeswap-V1-Core/contracts/libraries/LendMath.sol#L28-L28
BorrowMath.check(): https://github.com/code-423n4/2022-01-timeswap/blob/bf50d2a8bb93a5571f35f96bd74af54d9c92a210/Timeswap/Timeswap-V1-Core/contracts/libraries/BorrowMath.sol#L31-L31
- An attacker can set
state.yto a near overflow value, thenlend()to get a large amount of extra interest (as Bond tokens) with a small amount of asset tokens. This way, the attacker can steal funds from other lenders and liquidity providers.
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 borrowGivenDebt function allows the caller to specify the interest to pay without proper validation, enabling manipulation of state.y.
What the attacker needed
Access to borrowGivenDebt function; dust amount of assetOut
The fix
The function should be removed, as recommended by the reporter.
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.
In this smart contract, a value called state.y tracks something like the pool's debt or interest. The borrowGivenDebt function lets the caller choose how much interest to pay, and an attacker can abuse this to make state.y huge with very little cost. That breaks other parts of the protocol and lets the attacker take more interest than they should, stealing from others.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.