In MultiSourceLoan, each loan has a limited number of tranches. This limit is held in the getMaxTranches variable. When users want to add a new tranche, this limit is checked to ensure a loan cannot have more tranches than the getMaxTranches limit. The check is presented in addNewTranche() function.
However, this check is absent in the emitLoan() function, making it easy to bypass the other check in function addNewTranche().
As shown above, the check uses the equal comparator. So, users could create a loan with getMaxTranches + 1 tranches through the emitLoan() function, then they can always add more tranches. This is because the length of _loan.tranche.length is already larger than getMaxTranches and continues to grow after calling addNewTranche().
Tools Used
Manual Review
Recommended Mitigation Steps
Include a getMaxTranches check in the emitLoan() function and modify the check to
if (_loan.tranche.length >= getMaxTranches) {
revert TooManyTranchesError();
}
Lines of code
https://github.com/code-423n4/2024-04-gondi/blob/b9863d73c08fcdd2337dc80a8b5e0917e18b036c/src/lib/loans/MultiSourceLoan.sol#L377
Vulnerability details
Impact
In MultiSourceLoan, each loan has a limited number of tranches. This limit is held in the
getMaxTranches
variable. When users want to add a new tranche, this limit is checked to ensure a loan cannot have more tranches than thegetMaxTranches
limit. The check is presented inaddNewTranche()
function.However, this check is absent in the
emitLoan()
function, making it easy to bypass the other check in functionaddNewTranche()
.Proof of Concept
As shown above, the check uses the equal comparator. So, users could create a loan with
getMaxTranches + 1
tranches through theemitLoan()
function, then they can always add more tranches. This is because the length of_loan.tranche.length
is already larger thangetMaxTranches
and continues to grow after callingaddNewTranche()
.Tools Used
Manual Review
Recommended Mitigation Steps
Include a
getMaxTranches
check in theemitLoan()
function and modify the check toAssessed type
Other