For those unfamiliar with the deposit process, here’s a technical overview: When a deposit is made, a user submits a transaction to the beacon deposit contract that includes critical data such as the validator’s public key (48 bytes), withdrawal credentials (32 bytes), deposit signature (96 bytes), and the deposit amount in ETH. The contract verifies the signature and incorporates the deposit into a Merkle tree structure, updating the deposit_root and incrementing the deposit_count, thus creating a tamper-evident on-chain record.
Two specific points should be emphasized:
- Multiple deposits can be made to a single validator, with each deposit combined into a cumulative balance actively staked.
- When funds are withdrawn from staking, the destination address is specified by the withdrawal credentials provided at the time of deposit.
A critical question arises when multiple deposits with different withdrawal credentials, potentially belonging to different users, are sent to the same validator. This scenario creates a situation where deposits associated with different withdrawal credentials, along with their staking rewards, become pooled together under a single validator. The pressing question is: whose withdrawal credentials will ultimately receive the withdrawn funds?
While one might assume different mechanisms to control withdrawal access—such as a share-based pool or a policy enforced directly at the beacon deposit contract—the current Ethereum implementation simply uses the withdrawal credentials from the first-ever deposit, disregarding all subsequent ones.
The implications can be troubling. An attacker, anticipating someone else’s upcoming deposit to a specific validator, can front-run by initiating a minimal deposit with their own withdrawal credentials. Consequently, the attacker gains control over all subsequent deposits made to that validator, effectively stealing the user’s funds by later withdrawing them to an address the attacker controls, leaving the original depositor with nothing.
To exploit this vulnerability, the attacker must be able to sign validator-related data. If the attacker is also the validator’s creator, meeting this requirement is straightforward and poses no challenge.
Even if the attacker isn’t the original creator of the validator, the attack cannot be entirely ruled out and should still be considered when evaluating risks. For instance, the validator might be operated by a service providing an API that allows authorized users to request validator signatures for deposit and withdrawal operations.