Inconsistent use of `VAULT_ACCOUNT_MIN_TIME` in vault implementation
The vault contract updates an account's last-update timestamp both when entering a position and when fees are assessed after maturity, so the minimum-time check behaves differently before and after settlement. A user could exit repeatedly before maturity once the minimum time has passed, but after maturity each exit restarts the wait, which is inconsistent and affects prime and non-prime vault users differently.
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-03-notional-judging/issues/179
Found by
xiaoming90 + 0xleastwood
Summary
There is a considerable difference in implementation behaviour when a vault has yet to mature compared to after vault settlement.
Vulnerability Detail
There is some questionable functionality with the following require statement:
File: VaultAccountAction.sol
242: require(vaultAccount.lastUpdateBlockTime + Constants.VAULT_ACCOUNT_MIN_TIME <= block.timestamp)
The lastUpdateBlockTime variable is updated in two cases:
- A user enters a vault position, updating the vault state; including
lastUpdateBlockTime. This is a proactive measure to prevent users from quickly entering and exiting the vault. - The vault has matured and as a result, each time vault fees are assessed for a given vault account,
lastUpdateBlockTimeis updated toblock.timestampafter calculating the pro-rated fee for the prime cash vault.
Therefore, before a vault has matured, it is not possible to quickly enter and exit a vault. But after Constants.VAULT_ACCOUNT_MIN_TIME has passed, the user can exit the vault as many times as they like. However, the same does not hold true once a vault has matured. Each time a user exits the vault, they must wait Constants.VAULT_ACCOUNT_MIN_TIME time again to re-exit. This seems like inconsistent behaviour.
Impact
The exitVault() function will ultimately affect prime and non-prime vault users differently. It makes sense for the codebase to be written in such a way that functions execute in-line with user expectations.
Code Snippet
Tool used
Manual Review
Recommendation
It might be worth adding an exception to VaultConfiguration.settleAccountOrAccruePrimeCashFees() so that when vault fees are calculated, lastUpdatedBlockTime is not updated to block.timestamp.
Discussion
jeffywu
Given how storage is structured, if we do not set lastUpdatedBlockTime then the prime vault account will end up paying fees on the same time portion twice. This is probably worse than not being able to exit the position twice in succession.
Although this issue is correct, the exit time is 1 minute. Will mark this as Won't Fix as the change will probably more complex than the benefit to UX.
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 fee-assessment path reuses the same last-update timestamp that the entry/exit cooldown check relies on, so fee accrual resets the cooldown after maturity.
Impact
The exit function behaves inconsistently for prime and non-prime vault users, though the maintainers note the wait is only one minute and declined to fix it.
What the attacker needed
A vault position; vault has matured for the inconsistent path
The fix
The recommendation was to stop updating the last-updated timestamp during fee settlement, but the maintainers said this would cause double fee charging and marked the issue as won't fix.
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 here is a smart contract where people deposit funds and later withdraw them. The code tries to stop people from jumping in and out too quickly by recording the last time they touched their position and requiring a minimum wait. The bug is that this recorded time is also refreshed when fees are calculated after the vault matures, so the waiting rule applies unevenly depending on whether the vault has matured.
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.