Skip to content
Business logic Audit finding Intermediate

Mutual consent cannot be revoked and stays valid forever

The MutualConsent contract allows one party to give consent for a function call that cannot be revoked, so the other party can later execute that function without fresh consent. This lets a borrower set interest rates without the lender's ongoing approval.

aphak5010 Follow with minhquanym, SmartSek and 4 others

Originally disclosed on Code4rena

Submitted by aphak5010, also found by minhquanym, SmartSek, hansfriese, Jeiwan, rvierdiiev, and HE1M

https://github.com/debtdao/Line-of-Credit/blob/e8aa08b44f6132a5ed901f8daa231700c5afeb3a/contracts/utils/MutualConsent.sol#L11-L68

https://github.com/debtdao/Line-of-Credit/blob/e8aa08b44f6132a5ed901f8daa231700c5afeb3a/contracts/modules/credit/LineOfCredit.sol#L247-L262

Impact

Contracts that inherit from the MutualConsent contract, have access to a mutualConsent modifier.

Functions that use this modifier need consent from two parties to be called successfully.

Once one party has given consent for a function call, it cannot revoke consent.

This means that the other party can call this function at any time now.

This opens the door for several exploitation paths.

Most notably though the functions LineOfCredit.setRates(), LineOfCredit.addCredit() and LineOfCredit.increaseCredit() can cause problems.

One party can use Social Engineering to make the other party consent to multiple function calls and exploit the multiple consents.

Proof of Concept

  1. A borrower and lender want to change the rates for a credit. The borrower wants to create the possibility for himself to change the rates in the future without the lender’s consent.
  2. The borrower and lender agree to set dRate and fRate to 5%.
  3. The lender calls the LineOfCredit.setRates() function to give his consent.
  4. The borrower might now say to the lender “Let’s put the rate to 5.1% instead, I will give an extra 0.1%”
  5. The borrower and lender now both call the LineOfCredit.setRates() function to set the rates to 5.1%.
  6. The borrower can now set the rates to 5% at any time. E.g. they might increase the rates further in the future (the borrower playing by the rules) and at some point the borrower can decide to set the rates to 5%.

Links:

MutualConsent contract: https://github.com/debtdao/Line-of-Credit/blob/audit/code4rena-2022-11-03/contracts/utils/MutualConsent.sol

LineOfCredit.setRates() function: https://github.com/debtdao/Line-of-Credit/blob/e8aa08b44f6132a5ed901f8daa231700c5afeb3a/contracts/modules/credit/LineOfCredit.sol#L247-L262

Tools Used

VSCode

Recommended Mitigation Steps

There are several options to fix this issue:

  1. Add a function to the MutualConsent contract to revoke consent for a function call.
  2. Make consent valid only for a certain amount of time.
  3. Invalidate existing consents for a function when function is called with different arguments.

Option 3 requires a lot of additional bookkeeping but is probably the cleanest solution.

kibagateaux (Debt DAO) confirmed


The original report as published on Code4rena, by aphak5010. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the consent mechanism stores approvals permanently without expiry or revocation, so a single approval can be reused for future calls with different parameters.

Impact

A borrower could unilaterally change interest rates on a credit line without the lender's consent, potentially causing financial loss to the lender.

What the attacker needed

Borrower and lender interact; borrower uses social engineering

The fix

The consent mechanism should be fixed by allowing revocation, adding an expiry, or invalidating consents when function arguments change.

How it was found

  1. Borrower and lender agree to set rates to 5%.
  2. Lender calls setRates to give consent.
  3. Borrower suggests changing to 5.1% and both call setRates again.
  4. Borrower can now set rates back to 5% at any time without lender's consent.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

In some smart contracts, two people must both agree before an action happens. This report shows that once one person agrees, they cannot take back their agreement, so the other person can use that old agreement later without asking again. That could let someone change loan terms unfairly.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by aphak5010

View all

6 more disclosed reports, best first.

More from Debt DAO contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.