-
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
Loans with a minimum borrowing amount can not be partially repaid #1182
Comments
The issue is well demonstrated, properly formatted, contains a coded POC. |
0xSorryNotSorry marked the issue as high quality report |
0xSorryNotSorry marked the issue as primary issue |
Acknowledging this, this is fine IMO because at worst, the loan will miss a partial payment and will be called, it can't be decreased below minBorrow size and should be safe to send into liquidation. We could add a warning on the front-end but this seems like a pretty rare edge case. Disagree with severity because no user funds are at risk and it doesn't prevent the protocol from functioning properly, should be informational imo. |
eswak (sponsor) acknowledged |
eswak marked the issue as disagree with severity |
Agree with sponsor that this issue should be a QA/info |
Trumpero changed the severity to QA (Quality Assurance) |
Trumpero marked the issue as grade-b |
Trumpero marked the issue as grade-c |
Hey @Trumpero, I want to understand the difference between this issue and #756 . In both cases the functionality of the protocol is impacted as borrower won't be able to partialy repay his loan, so the impact is the same while the root cause is different. So the question is why this deemed unsatisfactory while #756 is of medium severity? Thanks you! |
@kazantseff |
Lines of code
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/main/src/loan/LendingTerm.sol#L527-L531
Vulnerability details
Impact
Loans with a minimum borrowing amount can not be partially repaid.
The main reason a borrower wants to partially repay his loan is to prevent his position from going underwater due to accruing interest. The lending terms require a minimum percentage to cover the debt during partial repayment. Also, when a borrower creates a new loan, there is a restriction on the minimum credit amount that can be borrowed. The restriction for the minimum borrow amount is to ensure that the gas costs of liquidation do not outsize the minimum overcollateralization.
When a borrower creates a loan with
borrowAmount == ProfitManager(refs.profitManager).minBorrow()
, it is not possible for him to partially repay his debt. The problem arises from this require statement:In this scenario
borrowAmount == ProfitManager(refs.profitManager).minBorrow()
and the require statement will never be true. Additionally, loans with a borrow amount close tominBorrow
can not be partially repaid becauseuint256 issuanceDecrease = (borrowAmount * percentRepaid) / 1e18;
, wherepercentRepaid = (debtToRepay * 1e18) / loanDebt
. In the best-case scenario for the borrower, he will repay the minimum partial repayment percentage from the borrowed amount.Every newly created loan with a
borrowAmount
close to theminBorrowAmount
can not be partially repaid. Lenders can not prevent their position from going underwater because they can not partially repay their loans as expected at the beginning of the loan creation.Proof of Concept
Paste the test in
LendingTerm.t.sol
Tools Used
Mannual Review
Recommended Mitigation Steps
Pre-calculate the minimum borrow amount. It should be bigger than
ProfitManager(refs.profit Manager).minBorrow()
.Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: