Skip to content
Business logic Audit finding Advanced

Deposits may be front-run by malicious operator to steal ETH

A malicious operator could front-run a deposit to the Beacon chain deposit contract with the same validator keys but different withdrawal credentials, causing the protocol's ETH to be controlled by the operator. This could lead to theft of all deposited funds.

giraffe Follow with hash and zzykxx

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-02-rio-network-core-protocol-judging/issues/55

Found by

giraffe, hash, zzykxx

Summary

Delegated staking protocols may be exposed to a known vulnerability, where a malicious operator front-runs a staker’s deposit call to the Beacon chain deposit contract and provides a different withdrawal credentials. This issue impacts Rio Network as well.

Vulnerability Detail

In Rio Network, approved operators are added to the operator registry. Thereafter, the operator adds validator details (public keys, signatures) to the same registry and awaits a confirmation period to pass (keys which are invalid may be removed by a security daemon) before the validators are active and ready to receive ETH.

When ETH is deposited and ready to be staked, RioLRTOperatorDelegator:stakeETH() is called which in turns calls eigenPodManager.stake{value: ETH_DEPOSIT_SIZE}(publicKey, signature, depositDataRoot); The withdrawal credentials point to the OperatorDelegator's Eigenpod.

A malicious operator may however front-run this transaction, by depositing 1 ETH into the Beacon chain deposit contract with the same validator keys but with a different, operator-controlled withdrawal credentials. Rio's OperatorDelegator's transaction would be successfully processed but the withdrawal credentials provided by the operator will not be overwritten.

The end state is a validator managing 1 ETH of node operator’s funds and 32 ETH of Rio users’ funds, fully controlled and withdrawable by the node operator.

Impact

While operators are trusted by the DAO, incoming ETH deposits could be as large as ETH_DEPOSIT_SOFT_CAP which is 3200 ETH, a sizeable incentive for an operator to turn malicious and easily carry out the attack (cost of attack = 1 ETH per validator). In fact, incoming deposits could exceed the soft cap (i.e. multiples of 3200 ETH), as several rebalance could be called without delay to deposit all the ETH over a few blocks.

All deposited funds would be lost in such an attack.

This vulnerability also affected several LST/LRT protocols, see Lido and EtherFi reports.

Code Snippet

https://github.com/sherlock-audit/2024-02-rio-network-core-protocol/blob/main/rio-sherlock-audit/contracts/restaking/RioLRTOperatorDelegator.sol#L204

Tool used

Manual Review

Recommendation

The Lido discussion extensively discusses possible solutions. My recommendations would be:

  1. In order for validator key entries submitted by a node operator to be approved by the DAO, require the operator to pre-deposit 1 ETH with the correct protocol-controlled WC for each public key used in these deposit data entries. And upon approval of the validator keys, refund the operator the pre-deposited 1 ETH.

or, 2) Adopt what Lido did which was to establish a committee of guardians who will be tasked to watch for the deposit contract and publish a signed message off-chain to allow deposit.

Rio should also consider reducing the incentives for an operator to act maliciously by 1) reducing the maximum amount of ETH which can be deposited in a single tx, and 2) implement a short delay between rebalances, even if the soft cap was hit (to prevent chaining rebalances to deposit a large amount of ETH).

Discussion

nevillehuang

Since operators are not trusted in the context of rio-protocol, I believe high severity to be appropriate since this allows direct stealing of material amount of funds

sherlock-admin4

The protocol team fixed this issue in the following PRs/commits: https://github.com/rio-org/rio-sherlock-audit/pull/12

10xhash

Fixed A guardian signature is now required to perform validator deposits. To prevent misuse of this using incorrect withdrawal credentials, now confirmed validators can also be removed

sherlock-admin4

The Lead Senior Watson signed off on the fix.

The original report as published on Sherlock, by giraffe. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The deposit contract does not overwrite existing withdrawal credentials for a validator, allowing a front-runner to set them first.

Impact

All deposited funds could be stolen by the operator, with the attack costing only 1 ETH per validator and potential deposits up to 3200 ETH or more.

What the attacker needed

Operator is approved in the registry; operator can front-run the deposit transaction

The fix

The protocol was fixed by requiring a guardian signature for validator deposits and allowing removal of confirmed validators with incorrect withdrawal credentials.

How it was found

  1. Operator adds validator details to the registry and waits for confirmation.
  2. Protocol calls stakeETH() to deposit ETH to the Beacon chain deposit contract.
  3. Malicious operator front-runs by depositing 1 ETH with the same validator keys but different withdrawal credentials.
  4. Protocol's deposit is processed but withdrawal credentials remain operator-controlled.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When you deposit ETH to become a validator, you specify withdrawal credentials that control who can take the ETH out later. If someone else deposits first with the same validator key but their own withdrawal credentials, your later deposit is added to that validator but the withdrawal credentials stay theirs. So the attacker can take both their small deposit and your large deposit.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More from Rio Network

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.