Skip to content
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

A loan with some special parameters may never be able to doing a periodic partial repayments #1126

Closed
c4-bot-8 opened this issue Dec 28, 2023 · 5 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue duplicate-1182 grade-c QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax sufficient quality report This report is of sufficient quality unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@c4-bot-8
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/loan/LendingTerm.sol#L490-L559

Vulnerability details

Impact

A loan with some special parameters may never be able to doing a periodic partial repayments, and this loan will inevitably become bad debt for the system.

Proof of Concept

Suppose there is a lendingTerm in the system, which stipulates that the minimum amount a user can borrow in a single loan is 100 tokens, and the minimum partial repayment is 5%.(Assume that the impact of APR and openingFee is not considered for the time being)

  1. User A creates a loan: borrowAmount=100.
  2. When user A attempts to call the partialRepay function, he must repay at least 5 credit Tokens (100 * 5%). After repayment, user A's current loan amount is 95. Since 95 is less than 100, the minimum loan amount cannot be met, and user A's partial repayment operation fails.
  3. In the partialRepay function of LendingTerm.sol, we can see a contradiction that prevents the following two conditions from being met simultaneously:
require(
    debtToRepay >= (loanDebt * params.minPartialRepayPercent) / 1e18,
    "LendingTerm: repay below min"
);
require(
    borrowAmount - issuanceDecrease >
        ProfitManager(refs.profitManager).minBorrow(),
    "LendingTerm: below min borrow"
);

Tools Used

Manual audit

Recommended Mitigation Steps

Suggested optimization statement:

	require(
	    debtToRepay >= (loanDebt * params.minPartialRepayPercent) / 1e18,
	    "LendingTerm: repay below min"
	);
-	require(
-	    borrowAmount - issuanceDecrease >
-	        ProfitManager(refs.profitManager).minBorrow(),
-	    "LendingTerm: below min borrow"
-	);

Assessed type

Other

@c4-bot-8 c4-bot-8 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Dec 28, 2023
c4-bot-10 added a commit that referenced this issue Dec 28, 2023
@c4-pre-sort
Copy link

0xSorryNotSorry marked the issue as sufficient quality report

@c4-pre-sort c4-pre-sort added the sufficient quality report This report is of sufficient quality label Jan 1, 2024
@c4-pre-sort
Copy link

0xSorryNotSorry marked the issue as duplicate of #1182

@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Jan 28, 2024
@c4-judge
Copy link
Contributor

Trumpero changed the severity to QA (Quality Assurance)

@c4-judge c4-judge added the QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax label Jan 28, 2024
@c4-judge
Copy link
Contributor

Trumpero marked the issue as grade-b

@c4-judge c4-judge added grade-b grade-c unsatisfactory does not satisfy C4 submission criteria; not eligible for awards and removed grade-b labels Jan 28, 2024
@c4-judge
Copy link
Contributor

Trumpero marked the issue as grade-c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue duplicate-1182 grade-c QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax sufficient quality report This report is of sufficient quality unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

3 participants