Platform: Code4rena
Start Date: 03/11/2022
Pot Size: $115,500 USDC
Total HM: 17
Participants: 120
Period: 7 days
Judge: LSDan
Total Solo HM: 1
Id: 174
League: ETH
Rank: 14/120
Findings: 4
Award: $1,938.11
π Selected for report: 0
π Solo Findings: 0
1468.9791 USDC - $1,468.98
One way for this to work, a borrower becomes his own lender and borrows from himself before he borrows from another lender.
This makes him the first lender so he has to be repaid before the other lenders.
The whileBorrowing
modifier allows a given function to run when only when count != 0 || credits[ids[0]].principal != 0
.
A borrower is able to take out a loan from himself and then repay it, satisfying this requirement, credits[ids[0]].principal == 0
, in the whileBorrowing
modifier.
A borrower can prevent an arbiter
from calling declareInsolvent
by becoming his own lender before borrowing from other lenders. Then the borrower repays himself but doesn't call the close
function. The borrower doesn't repay the other lenders. The arbiter tries to call declareInsolvent
but will be unable to since the whileBorrowing
modifier will revert the transaction. It reverts the transaction because credits[ids[0]].principal == 0
since the borrower is the first lender.
borrower
becomes his own lender by calling the addCredit
function and passing in an address he controls as a lender.
borrower
borrows from himself first then the other lenders.
borrower
repays himself but doesn't call the close
function.
borrower
doesn't repay the other lenders
Arbiter
gets involved and calls the declareInsolvent
function but the function will revert due to the whileBorrowing
modifier.
When the first lender is made whole the loan for that lender should automatically close.
#0 - c4-judge
2022-11-17T10:50:24Z
dmvt marked the issue as primary issue
#1 - c4-judge
2022-11-17T21:49:13Z
dmvt marked the issue as duplicate of #69
#2 - c4-judge
2022-12-06T17:19:14Z
dmvt marked the issue as satisfactory
π Selected for report: 0xdeadbeef0x
Also found by: 8olidity, Ch_301, HE1M, Koolex, Lambda, Nyx, RedOneN, Ruhum, Tomo, Trust, adriro, aphak5010, ayeslick, berndartmueller, brgltd, carlitox477, cccz, codexploder, d3e4, eierina, eighty, immeas, joestakey, lotux, minhquanym, perseverancesuccess, rbserver, rvierdiiev
4.0405 USDC - $4.04
If a lender or borrower sends in more ETH than the amount they specified, that ETH is not refunded to them.
Borrower calls the depositAndRepay
function
Borrower specifies 1 ETH in the amount but sends 1.5 ETH
The 1 ETH is used to repay his loan while 0.5 ETH isn't accounted for
require(amount == msg.value) for ETH transfers
#0 - c4-judge
2022-11-17T11:50:37Z
dmvt marked the issue as duplicate of #25
#1 - c4-judge
2022-12-06T16:27:45Z
dmvt marked the issue as partial-50
#2 - C4-Staff
2022-12-20T06:44:54Z
liveactionllama marked the issue as duplicate of #39
π Selected for report: __141345__
Also found by: Bnke0x0, Ch_301, Jeiwan, Lambda, Ruhum, aphak5010, ayeslick, cccz, codexploder, everyanykey, hansfriese, ladboy233, minhquanym, pashov, rbserver, rvierdiiev
24.4049 USDC - $24.40
If a lender and borrower agree to use a fee-on-transfer token, the recorded in the contract will be different than the amount received.
lender
transfers tokens via the addCredit
function.
lender
specifies 1000 Tokens
The contract receives 950 tokens but records 1000 tokens received
Check the balance of the contract before and after a transfer using the difference.
#0 - c4-judge
2022-11-17T11:11:13Z
dmvt marked the issue as duplicate of #26
#1 - c4-judge
2022-12-06T16:47:03Z
dmvt marked the issue as partial-50
#2 - C4-Staff
2022-12-20T06:01:34Z
liveactionllama marked the issue as duplicate of #367
π Selected for report: berndartmueller
Also found by: 0xdeadbeef0x, Jeiwan, R2, ayeslick, minhquanym
440.6937 USDC - $440.69
If a lender rejects the ETH transfer when a borrower calls the close
function, the borrower will be unable to close their loan with that lender which could lead to liquidation. It also prevents other lenders who provided loans after the lender from being repaid since repayments are on a FIFO basis.
borrower
borrows from malicious lender
borrower
borrows from other lenders
borrower
repays malicious lender
borrower
calls close
function
ETH is sent to the malicious lenders` contract which rejects the ETH causing the transaction to revert
If an ETH transfer fails wrap it to WETH then send it to the lender.
#0 - c4-judge
2022-11-17T11:10:46Z
dmvt marked the issue as duplicate of #85
#1 - c4-judge
2022-12-06T17:35:22Z
dmvt marked the issue as satisfactory
#2 - C4-Staff
2022-12-20T05:44:12Z
liveactionllama marked the issue as duplicate of #467