Skip to content
Business logic Audit finding Advanced

earn results in decreasing share price

The vault and controller contracts valued a vault's holdings differently: the vault summed the balances of all tokens it held, while the controller counted only the strategy's want token. Because of this mismatch, each call to earn() reduced the share price, so depositors lost roughly 2% of their value instead of earning yield.

jonah1005 Follow

Originally disclosed on Code4rena

Submitted by jonah1005

Impact

For a dai vault that pairs with NativeStrategyCurve3Crv, every time earn() is called, shareholders would lose money. (about 2%)

There are two issues involved. The Vault contract and the controller contract doesn’t handle the price difference between the want token and other tokens.

At Vault.sol L293, when a vault calculates its value, it sums up all tokens balance. However, when the controller calculates vaults’ value (at Controller.sol L410-L436), it only adds the amount of strategy.want it received. (in this case, it’s t3crv).

Under the current design, users who deposit dai to the vault would not get yield. Instead, they would keep losing money. I consider this a high-risk issue

Proof of Concept

I trigger the bug with the following web3.py script:

previous_price = vault.functions.getPricePerFullShare().call()
vault.functions.available(dai.address).call()
vault.functions.earn(dai.address, strategy.address).transact()
current_price = vault.functions.getPricePerFullShare().call()
print(previous_price)
print(current_price)

Tools Used

Hardhat

Recommended Mitigation Steps

The protocol should decide what the balance sheet in each contract stands for and make it consistent in all cases. Take, for example, if _vaultDetails[_vault].balance; stands for the amount of ‘want’ token the vault owns, there shouldn’t exist two different want in all the strategies the vault has. Also, when the vault queries controllers function balanceOf(), they should always multiply it by the price.

transferAndCall (yAxis) acknowledged

gpersoon commented:

I think this is also related to the underlying problem that all coins are assumed to have the same value. See also #2, #8 and #158

GalloDaSballo (judge) commented:

Agree with wardens finding and acknowledge it’s similitude with other issues

Personally this is a different vulnerability that can be solved by solving the same underlying problem

Marking this as unique finding as it’s a specific exploit the protocol could face

BobbyYaxis (yAxis) noted:

We have mitigated by deploying vaults that only accept the Curve LP token itself used in the strategy. There is no longer an array of tokens accepted. E.g Instead of a wBTC vault, we have a renCrv vault. Or instead of 3CRV vault, we have a mimCrv vault. The strategy want token = the vault token.

The original report as published on Code4rena, by jonah1005. 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 vault and controller used inconsistent definitions of a vault's balance, summing all token balances in one place but counting only the strategy's want token in the other, without converting between token prices.

Impact

Each earn() call could cut the share price by about 2%, so depositors would steadily lose money rather than earn yield; the protocol later mitigated this by deploying vaults that accept only the strategy's own LP token.

What the attacker needed

A dai vault paired with NativeStrategyCurve3Crv; a user deposits dai into the vault

The fix

The protocol mitigated the issue by deploying vaults that accept only the Curve LP token used in the strategy, so the vault token and the strategy want token are the same.

How it was found

  1. Read the vault's price per full share before the call.
  2. Call earn() on the vault for the dai strategy.
  3. Read the price per full share again and compare the two values.

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.

A vault is a shared pot of money, and each depositor holds shares that represent a slice of that pot. The price of one share is meant to rise as the pot earns yield. Here the two contracts that report the pot's value disagreed about what to count, so the reported value dropped after each earn() call and every depositor's share was worth less.

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 jonah1005

View all

39 more disclosed reports, best first.

More from yAxis 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.