A vault's first deposit can be frontrunned to grief deposits below a treshold #3
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-10
grade-b
insufficient quality report
This report is not of sufficient quality
Q-15
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
🤖_24_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2024-07-karak/blob/f5e52fdcb4c20c4318d532a9f08f7876e9afb321/src/Vault.sol#L94
Vulnerability details
[M-01] A vault's first deposit can be frontrunned to grief deposits below a treshold
Since the Solady's implementation of ERC-4626 uses the balance of
depositToken
as the base to price shares, if the contract is initially sent somedepositToken
via direct transfer, each deposit after that which is below the transfer amount (price of each share) will get zero shares in return. Also note that this will worsen as more users deposit values below this threshold, as each deposit increases the 1 share price. Moreover, using thevault::deposit
with expected share does not solve this issue either because thevault::convertToShares
suffers from the same problem.Impact
Deposits below a certain threshold will be lost and no share will be issued for them. This threshold will rise as more users fall for this, causing the vault to be unusable in the long term.
Proof of Concept
The proof is rather easy, just add the following test to the existing
vault.t.sol
file:Here are the steps to exploit:
vault::deposit
(initial deposit to this vault).Tools Used
Manual Review
Recommended Mitigation Steps
A quick fix would be adding an initial deposit to the
vault::initialize
function, or directly call deposit in thefactory/Core
contract. This will mint some initial shares for the operator and stop anyone from griefing the vaults.Assessed type
Other
The text was updated successfully, but these errors were encountered: