Skip to content

Conversation

@0x-r4bbit
Copy link
Member

This commit fixes a bug that anyone can create StakeVault's for anyone, which enables DDOSing other users.

The fix is allowing registration of StakeVault's in StakeManager.registerVault() only from a trusted address/account, which in our case is going to be the VaultFactory.

Previously, we required that the sender needs a trusted codehash (which is any StakeVault source that we whitelist). While this ensures only correct StakeVaults are registered with the system, it doesn't prevent other users from creating vaults for other accounts, as setting the owner of a StakeVault is configurable in its initialization.

The VaultFactory ensures that the account that creates the vault is also the owner of the vault.

BREAKING CHANGES:

  • StakeVault.register() has been removed. Registration is now entirely done via VaultFactory.
  • StakeManager.registerVault() now takes the address of the vault to register as argument:
- stakeManager.registerVault();
+ stakeManager.registerVault(stakeVaultAddress);

Addresses https://github.com/Cyfrin/audit-2025-12-statusl2/issues/1

Closes #72

function registerVault() external onlyNotEmergencyMode whenNotPaused onlyTrustedCodehash {
address vault = msg.sender;
function registerVault(address vault) external onlyNotEmergencyMode whenNotPaused onlyVaultFactory {
_onlyTrustedCodehash(vault.codehash);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gravityblast as discussed, we could think about removing the onlyTrustedCodehash requirement now, but keeping it at least doesn't change the behaviour. We might introduce new bugs otherwise.

We probably want to be able to detect if an older vault is no longer trusted, which we can't if we only rely on onlyRegisteredVault.

@0x-r4bbit 0x-r4bbit force-pushed the fix/vault-owner-bug branch from 8e3447d to 44329b7 Compare December 4, 2025 19:28
… owners

This commit fixes a bug that anyone can create `StakeVault`'s for anyone,
which enables DDOSing other users.

The fix is allowing registration of `StakeVault`'s in `StakeManager.registerVault()`
only from a trusted address/account, which in our case is going to be the `VaultFactory`.

Previously, we required that the sender needs a trusted codehash (which is any `StakeVault`
source that we whitelist). While this ensures only correct `StakeVault`s are registered with
the system, it doesn't prevent other users from creating vaults for other accounts, as
setting the `owner` of a `StakeVault` is configurable in its initialization.

The `VaultFactory` ensures that the account that creates the vault is also the owner of the vault.

BREAKING CHANGES:

- `StakeVault.register()` has been removed. Registration is now entirely done via `VaultFactory`.
- `StakeManager.registerVault()` now takes the address of the vault to register as argument:

```diff
- stakeManager.registerVault();
+ stakeManager.registerVault(stakeVaultAddress);
```

Addresses Cyfrin/audit-2025-12-statusl2#1

Closes #72
@0x-r4bbit 0x-r4bbit force-pushed the fix/vault-owner-bug branch from 44329b7 to 81c7b3d Compare December 5, 2025 08:53
@0x-r4bbit 0x-r4bbit mentioned this pull request Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Status Network Contracts] Users can create vaults for other users, causing DDOS

2 participants