-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LendingTerm._partialRepay
function can be called to frontrun LendingTerm._call
function call after maximum delay between partial repayments is reached for corresponding loan
#794
Comments
This could form even with the TX order, subject to MEV. |
0xSorryNotSorry marked the issue as insufficient quality report |
Non-issue. It's correct behavior for borrower to use |
Trumpero marked the issue as unsatisfactory: |
Hi @Trumpero, According to the Mechanism Detail section of https://code4rena.com/audits/2023-12-ethereum-credit-guild, For example, suppose 24 hours have been passed after a loan's maximum delay between partial repayments has been reached, the borrower has violated such loan's periodic payment requirement for 24 hours already, and such loan should be allowed to be called according to the Mechanism Detail section's specs; yet, such loan cannot be called if such frontrunning occurs even though the borrower has violated such loan's periodic payment requirement for 24 hours already. This scenario is unfair to the users, who should be allowed to call such loan and auction such loan's collateral but become unable to do so. Because the frontrunning issue described in this finding goes against the protocol's specs and intention, is unfair to the users who should be allowed to call such loan, and unfairly favors the borrower who has violated such loan's periodic payment requirement, such issue would possess a medium risk. Hence, would this finding be reconsidered as a medium risk finding? Thanks for your work! |
@rbserver "I still don't see any issue here. The delay of partial repayment counts from the last repayment to the time of liquidation, so it doesn't conflict with the protocol's specifications and intentions. Liquidation isn't forced but encouraged, and repayments with longer delays are allowed if liquidation isn't immediate. The sponsor also mentions that what matters for the protocol is that the loan is repaid/closed. |
Lines of code
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/e3d3e581e0e51a9ecf3a5a0c4e4bd4af32552fc0/src/loan/LendingTerm.sol#L237-L253
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/e3d3e581e0e51a9ecf3a5a0c4e4bd4af32552fc0/src/loan/LendingTerm.sol#L634-L675
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/e3d3e581e0e51a9ecf3a5a0c4e4bd4af32552fc0/src/loan/LendingTerm.sol#L490-L559
Vulnerability details
Impact
For a loan that requires partial repayments, the
LendingTerm.partialRepayDelayPassed
function would return true if the maximum delay between partial repayments has been reached.https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/e3d3e581e0e51a9ecf3a5a0c4e4bd4af32552fc0/src/loan/LendingTerm.sol#L237-L253
When the
LendingTerm.partialRepayDelayPassed
function returns true for the corresponding loan, a user can call theLendingTerm._call
function to call such loan.https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/e3d3e581e0e51a9ecf3a5a0c4e4bd4af32552fc0/src/loan/LendingTerm.sol#L634-L675
However, the borrower of such loan can frontrun the
LendingTerm._call
function call by calling theLendingTerm._partialRepay
function to make a partial repayment for such loan even after the maximum delay between partial repayments is reached. This can be done because theLendingTerm._partialRepay
function does not check if the maximum delay between partial repayments has been reached or not for the corresponding loan. After theLendingTerm._partialRepay
function call,lastPartialRepay[loanId]
is set toblock.timestamp
for such loan, which causes theLendingTerm._call
function call to revert becausepartialRepayDelayPassed(loanId)
returns false for such loan after the frontrunning. Users, who should be able to call such loan and auction such loan's collateral, become unable to do so.https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/e3d3e581e0e51a9ecf3a5a0c4e4bd4af32552fc0/src/loan/LendingTerm.sol#L490-L559
Proof of Concept
The following steps can occur.
LendingTerm._call
function.LendingTerm._call
function by calling theLendingTerm._partialRepay
function to make a partial repayment for her loan.lastPartialRepay[loanId]
is set toblock.timestamp
for Alice's loan, which causespartialRepayDelayPassed(loanId)
to return false when executing Bob'sLendingTerm._call
function call.LendingTerm._call
function call reverts, and he is not able to call Alice's loan when he should be allowed to.Tools Used
Manual Review
Recommended Mitigation Steps
The
LendingTerm._partialRepay
function can be updated to revert if the maximum delay between partial repayments has been reached for the corresponding loan.Assessed type
DoS
The text was updated successfully, but these errors were encountered: