Skip to content
Business logic Audit finding Advanced

`CDSLib::calculateCumulativeRate()` incorrectly only increment the local option fees when there are cds deposits

The function that tracks cumulative option fees only adds them to the local total when there are local CDS deposits, even though borrowers can exist on a chain with zero local CDS depositors. As a result, option fees generated on such a chain are never recorded and become permanently stuck when another chain tries to fetch them.

0x73696d616f Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-11-autonomint-judging/issues/946

Found by

0x73696d616f

Summary

CDSLib::calculateCumulativeRate() adds option fees to _totalCdsDepositedAmountWithOptionFees if _totalCdsDepositedAmount is not null, skipping if it is null.

The problem is that the 20% ratio of cds pool depositors to borrowers is calculated on the global cds depositors, not the local, so a chain can have 0 cds depositors but still have borrowers depositing and adding option fees. However, these option fees will not be tracked locally and will not be redeemable, underflowing when the other chain tries to fetch the option fees from the local chain.

Root Cause

In CDSLib.sol:174, _totalCdsDepositedAmountWithOptionFees is skipped summing option fees if total cds depositors in the chain is null.

Internal pre-conditions

None.

External pre-conditions

None.

Attack Path

  1. Cds depositors deposit USDa on chain B.
  2. Borrower borrows on chain A, which is possible because the ratio is calculated on the global variables. Option fees are not added to _totalCdsDepositedAmountWithOptionFees, which remains 0.
  3. chain B fetches option fees from chain A when cds depositors on chain B withdraw.
  4. option fees are never sent back from chain A to chain B as it underflows in cds.updateTotalCdsDepositedAmountWithOptionFees(). As such, these option fees will be stuck. Even if users deposit more in chain A, these option fees will always be stuck.

Impact

Stuck option fees.

PoC

None.

Mitigation

Always add the option fees.

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

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 code conditionally skips adding option fees to the local total when the local CDS deposited amount is zero, even though option fees can be generated without local CDS deposits.

Impact

Option fees generated on a chain with no local CDS depositors become permanently stuck and cannot be redeemed.

What the attacker needed

A chain with zero local CDS depositors; borrowers on that chain generating option fees; CDS depositors on another chain withdrawing

The fix

The code should always add the option fees to the local total, regardless of whether there are local CDS deposits.

How it was found

  1. CDS depositors deposit USDa on chain B.
  2. A borrower borrows on chain A, which is allowed because the ratio uses global variables, and option fees are not added to the local total.
  3. Chain B fetches option fees from chain A when CDS depositors on chain B withdraw.
  4. Option fees are never sent back from chain A to chain B because the update underflows, leaving the fees stuck.

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.

This is a smart contract bug in a cross-chain lending system. Option fees are like extra charges paid by borrowers, and they should be saved so they can later be paid out to depositors. But the code only saves these fees on a chain if that same chain already has depositors, so fees earned on a chain with no depositors are lost forever.

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 0x73696d616f

View all

172 more disclosed reports, best first.

More from Autonomint Colored Dollar V1

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.