Skip to content
Business logic Audit finding Advanced

User can redeem more tokens by artificially increasing the chi accrual

The chi oracle derives its exchange rate from Compound's stored exchange rate, which depends on total borrows and can be pushed up within a single transaction by a large borrow. An attacker could therefore redeem matured fyTokens for more underlying tokens than a normal redemption, paying only gas.

Yield Witch v2 contest

Originally disclosed on Code4rena

A user can artificially increase the chi accrual (after maturity) by flash borrow on Compound, which affects the exchange rate used by the chi oracle. As a result, the user redeems more underlying tokens with the same amount of fyTokens since the accrual is larger than before.

The exchangeRateStored used by chi oracle is calculated based on the totalBorrows of CToken, which can be artificially increased by a large amount of borrow operated on Compound. Consider a user performing the following steps in a single transaction (assuming that the fyToken is matured):

  1. Deposits a large amount of collateral (whether from flash loans or not) and borrow from Compound
  2. Burns his fyToken by calling redeem.
  3. Repays the borrow to Compound

The user only needs to pay for the gas fees of borrowing and repaying (since they happen in the same transaction) but can redeem more underlying tokens than a regular redeem.

Referenced code: CompoundMultiOracle.sol#L46 FYToken.sol#L125 FYToken.sol#L132-L143

Recommend making the chi accrual time-weighted to mitigate the manipulation caused by flash borrow and repay.

albertocuestacanada (Yield) acknowledged:

If this is true, that means that we don’t understand how exchangeRateStored works (quite likely).

Our understanding was that exchangeRateStored is an increasing accumulator, same as chi in MakerDAO, which is both an exchange rate and an accumulator.

If exchangeRateStored can go down in value, as well as up, we might have to revisit how we source it.

The original report as published on Code4rena. 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 chi oracle reads Compound's exchange rate, which moves with total borrows, so a large borrow inside one transaction can inflate the accrual used at redemption.

Impact

A user could redeem more underlying tokens than a regular redeem with the same fyTokens, paying only gas, though the project maintainer questioned whether the exchange rate can actually move downward as assumed.

What the attacker needed

Matured fyTokens held by attacker; ability to borrow large amounts on Compound; single transaction execution

The fix

The chi accrual should be made time-weighted to mitigate manipulation caused by flash borrow and repay.

How it was found

  1. Deposit a large amount of collateral and borrow from Compound.
  2. Burn the fyToken by calling redeem.
  3. Repay the borrow to Compound.

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.

Some tokens are redeemed at a rate that comes from an outside lending market. If someone can briefly borrow a huge amount there, that rate can be nudged upward for a moment. Doing the borrow, the redemption and the repayment all in one transaction means the attacker gets a better payout while only paying transaction fees.

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 from Yield Witch v2 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.