20,000 USDC
View results
Submission Details
Severity: medium
Valid

Frontrunning of refinance and borrow function

Summary

Frontrunning of refinance and borrow function can make the borrower to pay a higher interest rate.

Vulnerability Details

Alice refinance her loan in Bob's pool. Bob monitors the mempool and sees that Alice will refinance loan in its pool and frontruns it by calling updateInterestRate function to significantly increase the interest rate of the pool. After Alice's refinance is executed, Bob's manipulated interest rate is used to update the interest rate of Alice's loan.

Lines of code

https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Lender.sol#L591-L710
https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Lender.sol#L232C1-L287
https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Lender.sol#L221-L226

Tools Used

Manual Review

Recommendations

Add interestRate in Borrow and Refinance structs and if check in the functions
if (pool.interestRate >= borrows[i].interestRate) revert Error();
if( pool.interestRate >= refinances[i].interestRate) revert Error();

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.