Debt DAO contest - cryptphi's results

A cryptonative credit marketplace for fully anon and trustless loans to DAOs.

General Information

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

Debt DAO

Findings Distribution

Researcher Performance

Rank: 15/120

Findings: 1

Award: $1,909.67

🌟 Selected for report: 1

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: cryptphi

Also found by: Ch_301, PaludoX0, adriro, ayeslick, perseverancesuccess

Labels

bug
3 (High Risk)
primary issue
satisfactory
sponsor confirmed
upgraded by judge
selected for report
edited-by-warden
H-01

Awards

1909.6728 USDC - $1,909.67

External Links

Lines of code

https://github.com/debtdao/Line-of-Credit/blob/audit/code4rena-2022-11-03/contracts/modules/credit/LineOfCredit.sol#L143 https://github.com/debtdao/Line-of-Credit/blob/audit/code4rena-2022-11-03/contracts/modules/credit/LineOfCredit.sol#L83-L86

Vulnerability details

Impact

The modifier whileBorrowing() is used along in the call to LineOfCredit.declareInsolvent(). However this check reverts when count == 0 or credits[ids[0]].principal == 0 . Within the contract, any lender can add credit which adds an entry in credits array, credits[ids].

Assume, when borrower chooses lender positions including credits[ids[0]] to draw on, and repays back the loan fully for credits[ids[1]], then the call to declareInsolvent() by the arbiter would revert since it does not pass the whileBorrowing() modifier check due to the ids array index shift in the call to stepQ(), which would shift ids[1] to ids[0], thereby making the condition for credits[ids[0]].principal == 0 be true causing the revert.

Proof of Concept

  1. LineOfCredit contract is set up and 5 lenders have deposited into the contract.
  2. Alice, the borrower borrows credit from these 5 credit positions including by calling LineOfCredit.borrow() for the position ids.
  3. Later Alice pays back the loan for credit position id 1 just before the contract gets liquidated
  4. At the point where ids.stepQ() is called in _repay(), position 1 is moved to ids[0]
  5. When contract status is LIQUIDATABLE, no loan drawn on credit position 0 and arbiter calls declareInsolvent() , the call would revert since credits[ids[0]].principal == 0

Tools Used

Manual review

The modifier whileBorrowing() would need to be reviewed and amended.

#0 - c4-judge

2022-11-15T19:04:16Z

dmvt marked the issue as primary issue

#1 - c4-judge

2022-11-17T20:10:08Z

dmvt marked the issue as selected for report

#2 - c4-judge

2022-11-17T20:10:16Z

dmvt changed the severity to 3 (High Risk)

#3 - c4-sponsor

2022-11-30T15:25:08Z

kibagateaux marked the issue as sponsor confirmed

#4 - c4-judge

2022-12-06T17:17:50Z

dmvt marked the issue as satisfactory

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter