Submitted by Rhynorater, also found by harleythedog, hyh, and WatchPug
Due to lack of constraints on user input in the TimeswapPair.sol#mint function, an attacker can arbitrarily modify the interest rate while only paying a minimal amount of Asset Token and Collateral Token.
Disclosure: This is my first time attempting Ethereum hacking, so I might have made some mistakes here since the math is quite complex, but Im going to give it a go.
The attack scenario is this: A malicious actor is able to hyper-inflate the interest rate on a pool by triggering a malicious mint function. The malicious actor does this to attack the LP and other members of the pool.
Consider the following HardHat script:
First, the LP deploys their pool and contributes their desired amount of tokens with the below contract:
Here are the initialization values:
With this configuration, Ive calculated the interest rate to borrow on this pool using the functions defined here: https://timeswap.gitbook.io/timeswap/deep-dive/borrowing
to  be:
Around 1% to 15%.
Then, the attacker comes along (see line containing let atakcontrak and after). The attacker deploys the following contract:
Which contains the following settings for a mint:
According to my logs in hardhat:
The attacker is only required to pay 3 wei of Asset Token and 6 wei of Collateral token. However, after the attackers malicious mint is up, the interest rate becomes:
Between 40 and 646 percent.
xyz values before and after:
This result in destruction of the pool.
Mathepreneur (Timeswap) confirmed
CloudEllie (C4) commented:
