Since totalSupply is constantly increasing, Therefore, when the value of totalSupply is accumulated (many deposits in a short time) and _totalAssets in the pool is small, a user with balanceOf(msg.sender) greater than 0 May not be able to deposit.
The attacker can make totalSupply increase temporarily, or the attacker can donate the balance to the specified account so that his balance is greater than 0.
Lines of code
https://github.com/code-423n4/2024-05-bakerfi/blob/59b1f70cbf170871f9604e73e7fe70b70981ab43/contracts/core/Vault.sol#L212
Vulnerability details
Impact
DoS attacks make it impossible for others to deposit
Proof of Concept
maxDeposit
is set in thedeposit
function:_tokenPerETH = (totalSupply() * 1 ether) / _totalAssets;
Because _totalAssets = totalCollateralInEth - totalDebtInEth So the value of _totalAssets might be small.
Suppose _totalAssets = 1wei, afterDeposit = msg.value + balanceOf(msg.sender) * totalSupply()
Since
totalSupply
is constantly increasing, Therefore, when the value oftotalSupply
is accumulated (many deposits in a short time) and_totalAssets
in the pool is small, a user withbalanceOf(msg.sender)
greater than 0 May not be able to deposit.The attacker can make
totalSupply
increase temporarily, or the attacker can donate the balance to the specified account so that his balance is greater than 0.Tools Used
vscode, manual
Recommended Mitigation Steps
Change the calculation method of
maxDeposit
.Assessed type
DoS