The getMaxTranches
check can be bypassed
#66
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-80
🤖_31_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
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
The text was updated successfully, but these errors were encountered: