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

Loan calls can be DoS'd by borrower if collateral is an ERC777 #1088

Closed
c4-bot-5 opened this issue Dec 28, 2023 · 9 comments
Closed

Loan calls can be DoS'd by borrower if collateral is an ERC777 #1088

c4-bot-5 opened this issue Dec 28, 2023 · 9 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-184 sufficient quality report This report is of sufficient quality unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@c4-bot-5
Copy link
Contributor

Lines of code

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

Vulnerability details

If a loan has not been repaid/partially repaid before the maxDelayBetweenPartialRepay, or when the gauge's term has been deprecated, anyone can call the loan in order to make it liquidatable.

This is done through an auction, where users can bid on the loan for a debt to repay, and a collateral to get.

The closing of the loan is done through LendingTerm::onBid where the assets are sent/taken from the different actors.

The issue is, as far as the collateral to send to the borrower is non-zero, the borrower can DoS the call by setting a callback that will make the transfer revert, making it impossible for other user to call its loan.

Impact

Loan are un-callable during the auction phase where collateral sent to borrower is non-zero, thus preventing the normal use of the protocol.

Proof of Concept

See

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

File: src\loan\LendingTerm.sol
725:     function onBid(
726:         bytes32 loanId,
727:         address bidder,
728:         uint256 collateralToBorrower,
729:         uint256 collateralToBidder,
730:         uint256 creditFromBidder
731:     ) external {
...:
...:		//[removed first part of the function]
...:
803:         // send collateral to borrower
804:         if (collateralToBorrower != 0) {
805: @>          IERC20(params.collateralToken).safeTransfer(		//@audit-issue if collateral token with callback, borrower can make onBid revert whenever he wants
806:                 loans[loanId].borrower,							//making his loan un-callable
807:                 collateralToBorrower
808:             );
809:         }
810: 
811:         // send collateral to bidder
812:         if (collateralToBidder != 0) {
813:             IERC20(params.collateralToken).safeTransfer(
814:                 bidder,
815:                 collateralToBidder
816:             );
817:         }
818: 
819:         emit LoanClose(
820:             block.timestamp,
821:             loanId,
822:             LoanCloseType.Call,
823:             creditFromBidder
824:         );
825:     }

Tools Used

Manual audit

Recommended Mitigation Steps

Do not use a push pattern here, but rather a pull pattern for the borrower.
This mean to have a specific function for borrower to get the collateral once the call has been completed.
This way, he cannot interfer with the calling process.

Assessed type

Math

@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 Dec 28, 2023
c4-bot-5 added a commit that referenced this issue Dec 28, 2023
@c4-pre-sort c4-pre-sort added the sufficient quality report This report is of sufficient quality label Jan 3, 2024
@c4-pre-sort
Copy link

0xSorryNotSorry marked the issue as sufficient quality report

@c4-pre-sort
Copy link

0xSorryNotSorry marked the issue as duplicate of #685

@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Jan 27, 2024
@c4-judge
Copy link
Contributor

Trumpero changed the severity to QA (Quality Assurance)

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

Trumpero marked the issue as grade-b

@c4-judge c4-judge reopened this Jan 31, 2024
@c4-judge c4-judge added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value and removed downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax labels Jan 31, 2024
@c4-judge
Copy link
Contributor

This previously downgraded issue has been upgraded by Trumpero

@c4-judge
Copy link
Contributor

Trumpero marked the issue as not a duplicate

@c4-judge
Copy link
Contributor

Trumpero marked the issue as duplicate of #184

@c4-judge c4-judge added duplicate-184 satisfactory satisfies C4 submission criteria; eligible for awards labels Jan 31, 2024
@c4-judge
Copy link
Contributor

Trumpero marked the issue as satisfactory

@c4-judge c4-judge added unsatisfactory does not satisfy C4 submission criteria; not eligible for awards and removed satisfactory satisfies C4 submission criteria; eligible for awards labels Feb 3, 2024
@c4-judge
Copy link
Contributor

c4-judge commented Feb 3, 2024

Trumpero marked the issue as unsatisfactory:
Out of scope

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-184 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

4 participants