Tx ordering vulnerability allows a lender to frontrun a borrow tx in their pool and set the interest rate to 1000%.
In Lender.sol setPool() allows a pool lender can use to update pool parameters at will, including the interest rate for future loans in their pool, which they can set to a maximum of 1000% APR. The same can be accomplished with the specialized setter, updateInterestRate().
There is no current mechanism to protect against interest rate changes immediately before a borrow.
High.
Lenders can trick entice borrowers with a low interest rate. They can listen for incoming borrow transactions in the mempool and sandwich them using a bundling service such as Flashbots. An example attack flow is:
Lender observes an incoming victim tx that performs a borrow in their pool.
Lender creates the frontrun tx which calls updateInterestRate(poolId, 10000) or setPool(p) where p.interestRate = 10000
Lender submits a Flashbots Bundle that puts the frontrun tx before the victim tx.
Lender calls updateInterestRate(poolId, 10000). The lender's tx will only be broadcasted if included in the bundle.
(Optional) Lender creates a backrun tx which which calls updateInterestRate(poolId, initital) to conceal their tracks to the unsophisticated eye.
Paste this in a new file in the test/ folder.
Run forge test --match-test test_PoC -vv
Manual Review
One way to prevent this is to allow borrowers to set expectations when borrowing. We can update the Borrow struct like this:
Then update the borrow() function to check the expected interest rate against the actual interest rate:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.