_partialRepay function is not respecting the minBorrow #461
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
Lines of code
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/loan/LendingTerm.sol#L528
Vulnerability details
Terms include a minBorrow, representing the minimum loan amount a user can open:
[Link]
The contract permits maintaining a minimum borrowed amount including the borrow amount.
When we inspect the _partialRepay function we notice that this is no the case in _partialRepay:
[Link]
In this scenario, the partialRepay function does not permit the maintenance of a minimum borrow, presenting a discrepancy that may lead to various issues.
Impact
A discrepancy in logic operators can pose several problems, particularly in contracts that may be utilized by other contracts as well.
In these instances, if a user want to let his loan with the minimum borrow amount after a repayment, they can´t and they are required to recalculate and execute the transaction again with a reduced payment. In the context of contracts, this behavior introduces a potential risk, as contract executions may fail depending on the design and implementation.
Proof of Concept
Run the next foundry test in
file:2023-12-ethereumcreditguild/test/unit/loan /LendingTerm.t.sol
Tools Used
Manual. foundry
Recommended Mitigation Steps
Make the partial repay >= to minBorrow:
Assessed type
Error
The text was updated successfully, but these errors were encountered: