Open hats-bug-reporter[bot] opened 1 year ago
uint256 private constant _securityDeposit = 1e9;
function __VaultEthStaking_init() internal onlyInitializing {
__ReentrancyGuard_init();
// see https://github.com/OpenZeppelin/openzeppelin-contracts/issues/3706
if (msg.value < _securityDeposit) revert Errors.InvalidSecurityDeposit();
_deposit(address(this), msg.value, address(0));
}
Github username: -- Submission hash (on-chain): 0xa70832e7435e348e7e4431d26361fb2196e5bd3161742ec983e40adc0aa48774 Severity: medium
Description: Title:\ Lack of validation to check whether or not the
msg.value
sent as the security deposit would be more than1 gwei
, which lead to the inflation attackSeverity:\ Medium
Description:\ Within the EthVaultFactory#
createVault()
, the EthVault#initialize()
would be called withmsg.value
to initialize a Vault like this: https://github.com/stakewise/v3-core/blob/5996ae760a7e4a24d42029e64c56f3df087053cd/contracts/vaults/ethereum/EthVaultFactory.sol#L58Within the EthVault#
initialize()
, the Vault would be initialized like this: https://github.com/stakewise/v3-core/blob/5996ae760a7e4a24d42029e64c56f3df087053cd/contracts/vaults/ethereum/EthVault.sol#L70-L76According to the "Parameters" part of creating a Vault in the documentation,
1 gwei
must be transferred as a security deposit when the EthVaultFactory#createVault()
would be called like this:However, within both the EthVaultFactory#
createVault()
and the EthVault#initialize()
above, there is no validation to check whether or not themsg.value
sent when the EthVaultFactory#createVault()
is called would be more than1 gwei
.As a result, the caller (
msg.sender
) can create a Vault without any security deposit.This lead to the inflation attack, which is mentioned in the "Parameters" part of creating a Vault in the documentation.
Recommendation:\ Within the EthVaultFactory#
createVault()
, consider adding a validation to check whether or not themsg.value
sent when the EthVaultFactory#createVault()
is called would be more than1 gwei
(1e9) like this: