exchangeRate is not up to date in case if vault that is off is changed to on
When a vault is switched off, its exchange rate is not updated; if later switched on, users deposit or withdraw using a stale, lower exchange rate, causing incorrect share calculations. Depositors may receive more shares and withdrawers may receive less than they should.
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-01-derby-judging/issues/126
Found by
rvierdiiev
Summary
exchangeRate is not up to date in case if vault that is off is changed to on. Depositors and withdrawers will use old exchangeRate that will be less than in reality.
Vulnerability Detail
In case if vault has no allocations, then it is switched off. That means that users can't deposit/withdraw from vault anymore. After it was detected that vault is off or on, then sendFeedbackToVault is called.
In case if vault is off, that means that actually it doesn't have underlying inside providers anymore, so there is no reason send exchangeRate to it.
exchangeRate is very important param as it is used in share calculations when user deposits/withdraws. That's why it's important that when vault is ON again after it was OFF, exchangeRate is up to date.
In case if vault is off, then exhange rate is not provided to it.
Then when after few rebalancing period, some allocation was provided for the vault and it was marked as ON again and sendFeedbackToVault is called, then users can deposit/withdraw again. But the problem is that exchangeRate is old there and is likely less than it should be, so depositors receive more shares and withdrawers receive less funds.
Example.
1.At cycle 10 exchangeRate is 1.1.
2.Vault has no more allocations and it's switched off.
3.At cycle 15 new allocations were send to vault. So it's switched on. Current exchangeRate is 1.2.
4.Depositors now can deposit, but exchangeRate inside this vault is not fresh, it's from 10th cycle.
5.So some depositors had chance to receive more shares and some withdrawers lost some funds.
I am not sure about severity here, think it's medium because switching on/off can not be often.
Impact
Incorrect shares calculation
Code Snippet
Provided above
Tool used
Manual Review
Recommendation
When you set vault to on state, you need to send current exchangeRate as well.
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 skips sending the current exchange rate when a vault is switched back on, so the vault keeps the last rate it received before being switched off.
Impact
Incorrect share calculations could let depositors receive more shares and withdrawers receive less funds, though the author notes switching on and off may not happen often.
What the attacker needed
Vault switched off due to no allocations; vault later switched on with new allocations; users deposit or withdraw after switch-on
The fix
When a vault is set to the on state, the current exchange rate should also be sent to it.
How it was found
- At cycle 10 the exchange rate is 1.1.
- The vault has no allocations and is switched off.
- At cycle 15 new allocations are sent and the vault is switched on; the current exchange rate is 1.2.
- Depositors can deposit, but the vault still uses the exchange rate from cycle 10.
- Some depositors receive more shares and some withdrawers lose funds.
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 tracks how much each share is worth using an exchange rate. If that rate is not refreshed when the vault is turned back on, people get the wrong number of shares or funds when they deposit or withdraw.
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.