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

The getMaxTranches check can be bypassed #66

Closed
c4-bot-5 opened this issue Apr 16, 2024 · 2 comments
Closed

The getMaxTranches check can be bypassed #66

c4-bot-5 opened this issue Apr 16, 2024 · 2 comments
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

Comments

@c4-bot-5
Copy link
Contributor

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 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().

Proof of Concept

function addNewTranche(
    RenegotiationOffer calldata _renegotiationOffer,
    Loan memory _loan,
    bytes calldata _renegotiationOfferSignature
) external nonReentrant returns (uint256, Loan memory) {
    ...
    if (_loan.tranche.length == getMaxTranches) {
        revert TooManyTranchesError();
    }
    ...
}

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();
}

Assessed type

Other

@c4-bot-5 c4-bot-5 added 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 labels Apr 16, 2024
c4-bot-7 added a commit that referenced this issue Apr 16, 2024
@c4-bot-13 c4-bot-13 added the 🤖_31_group AI based duplicate group recommendation label Apr 17, 2024
@c4-judge
Copy link
Contributor

0xA5DF marked the issue as duplicate of #80

@c4-judge c4-judge added duplicate-80 satisfactory satisfies C4 submission criteria; eligible for awards labels Apr 17, 2024
@c4-judge
Copy link
Contributor

0xA5DF marked the issue as satisfactory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants