-
Notifications
You must be signed in to change notification settings - Fork 11
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
CreditMultiplier is not applied to creditAsked
when a bid for an active auction is placed. This can reduce the creditMultiplier and thus the value of creditToken holders.
#1069
Comments
Looks like the same root cause referred here: #1156 |
0xSorryNotSorry marked the issue as sufficient quality report |
0xSorryNotSorry marked the issue as primary issue |
Very clear, thanks for the quality of the report. Confirming |
eswak (sponsor) confirmed |
Trumpero marked the issue as satisfactory |
Trumpero marked the issue as selected for report |
Trumpero marked issue #476 as primary and marked this issue as a duplicate of 476 |
Lines of code
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/loan/LendingTerm.sol#L228-L230
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/loan/LendingTerm.sol#L751-L755
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/loan/LendingTerm.sol#L758-L767
Vulnerability details
Impact
Proof of Concept
In case of a late partial repayment or offboarding lendingTerm loans can be
call
ed.LendingTerm.getLoanDebt
is used to calculate the outstanding borrowed amount of a loan. It includes the principal, interest, openFee. AcreditMultiplier
correction is applied to reflect the updated loan value in case creditToken <-> underlyingToken ratio decreased after the loan was opened.loans
mapping is updated with up-to-dateloadDebt
amount.The auction is started.
auctions[loanId]
store same up-to-dataloanDebt
(named callDebt now).Now auction is active and anyone can
bid
on it.AuctionHouse.getBidDetail
is used to get thecollateralReceived
(by bidder) forcreditAsked
.As we can see updated
callDebt
(updated at the moment the auction started) is returned forcreditAsked
. (we ignore the fact less Credit is asked in second phase of the auction).creditAsked
is passed down toonBid
callback.principal
is calculated by applying theborrowCreditMultiplier / creditMultiplier
correction:creditFromBidder
is thecreditAsked
==callDebt
==loanDebt
updated at the moment auction started. No new correction is applied.Let me explain what I mean by that and why it matters.
The auction can last many blocks, up to 30 minutes based on in the scope deployment script.
creditMultiplier
can have a correction down (due to bad debt accumulation) between (1) the loan was called (auction started) and (2) the auction was bid on.On the time axis we have 3 creditMultiplier values of interest :
borrowCreditMultiplier
>=auctionStartedCreditMultiplier
>=bidOnAuctionCreditMultiplier
==creditMultiplier
Going back on
onBid
callback :->
principal
=borrowAmount * borrowCreditMultiplier/ bidOnAuctionCreditMultiplier
->
creditFromBidder
=borrowAmountPlusInterests * borrowCreditMultiplier / auctionStartedCreditMultiplier
In the first phase of auction more and more collateral is offered for the same amount of CREDIT to pay.
Let's suppose a bidder bids in this phase, offering
creditFromBidder
for a x% ( x < 100%) of collateral.But, in case
creditMultiplier
decreased betweenstartAuction
andbid
moment,principal
can be bigger thancreditFromBidder
amount, forcing the code to enter else branch:Because
collateralToBorrower
must be 0 even if auction is in first half (and collateral is split between bidder and borrower), the bid transaction reverts:Tools Used
Manual review
Recommended Mitigation Steps`
Consider applying same correction to both
principal
andcreditFromBidder
:LendingTerm._call : loans[loanId].callDebt => save rawLoanDebt (principal +interest + openFee) (but do not apply creditMultiplier correction)
AuctionHouse.getBidDetail : getBidDetail => apply creditM correction to rawLoanDebt to calculate creditAsked:
creditAsked
=rawLoanDebt * borrowCreditMultiplier/ bidOnAuctionCreditMultiplier
when
onBid
callback is called thecreditAsked
updated amount is passed and compared withprincipal
which has same correction applied.Assessed type
Error
The text was updated successfully, but these errors were encountered: