Skip to content
DoS Audit finding Intermediate

A malicious strategy can permanently DoS all currently pending withdrawals that contain it

A withdrawal queued with multiple strategies can be permanently blocked if one strategy always reverts, because the completion function calls each strategy's withdraw and reverts on failure. An attacker could create a malicious strategy that always reverts, causing any pending withdrawal containing it to fail, though a workaround exists that requires re-queuing and waiting.

ABA Follow with juancito, ToonVH and 7 others

Originally disclosed on Code4rena

Submitted by ABA, also found by juancito, ToonVH, 0xWaitress, ABA, MiloTruck, rvierdiiev, 8olidity, bughunter007, and bytes032.

In order to withdraw funds from the project a user has to:

  1. queue a withdrawal (via queueWithdrawal).
  2. complete a withdrawal (via completeQueuedWithdrawal(s)).

Queuing a withdrawal, via queueWithdrawal modifies all internal accounting to reflect this:

https://github.com/code-423n4/2023-04-eigenlayer/blob/main/src/contracts/core/StrategyManager.sol#L345-L346

        // modify delegated shares accordingly, if applicable
        delegation.decreaseDelegatedShares(msg.sender, strategies, shares);

https://github.com/code-423n4/2023-04-eigenlayer/blob/main/src/contracts/core/StrategyManager.sol#L370

    if (_removeShares(msg.sender, strategyIndexes[strategyIndexIndex], strategies[i], shares[i])) {

and saves the withdrawal hash in order to be used in completeQueuedWithdrawal(s).

https://github.com/code-423n4/2023-04-eigenlayer/blob/main/src/contracts/core/StrategyManager.sol#L400-L415

            queuedWithdrawal = QueuedWithdrawal({
                strategies: strategies,
                shares: shares,
                depositor: msg.sender,
                withdrawerAndNonce: withdrawerAndNonce,
                withdrawalStartBlock: uint32(block.number),
                delegatedAddress: delegatedAddress
            });

        }

        // calculate the withdrawal root
        bytes32 withdrawalRoot = calculateWithdrawalRoot(queuedWithdrawal);

        // mark withdrawal as pending
        withdrawalRootPending[withdrawalRoot] = true;

In other words, it is final (as there is no cancelWithdrawl mechanism implemented). When executing completeQueuedWithdrawal(s), the withdraw function of the strategy is called (if receiveAsTokens is set to true).

https://github.com/code-423n4/2023-04-eigenlayer/blob/main/src/contracts/core/StrategyManager.sol#L786-L789

    // tell the strategy to send the appropriate amount of funds to the depositor
    queuedWithdrawal.strategies[i].withdraw(
        msg.sender, tokens[i], queuedWithdrawal.shares[i]
    );

In this case, a malicious strategy can always revert, blocking the user from retrieving his tokens. If a user sets receiveAsTokens to false, the other case, then the tokens will be added as shares to the delegation contract

https://github.com/code-423n4/2023-04-eigenlayer/blob/main/src/contracts/core/StrategyManager.sol#L797-L800

    for (uint256 i = 0; i < strategiesLength;) {
        _addShares(msg.sender, queuedWithdrawal.strategies[i], queuedWithdrawal.shares[i]);
        unchecked {
            ++i;

https://github.com/code-423n4/2023-04-eigenlayer/blob/main/src/contracts/core/StrategyManager.sol#L646-L647

        // if applicable, increase delegated shares accordingly
        delegation.increaseDelegatedShares(depositor, strategy, shares);

This still poses a problem because the increaseDelegatedShares function’s counterpart, decreaseDelegatedShares, is only callable by the strategy manager (for users to indirectly get their rewards worth back, via this workaround).

https://github.com/code-423n4/2023-04-eigenlayer/blob/main/src/contracts/core/DelegationManager.sol#L168-L179

    /**
     * @notice Decreases the `staker`'s delegated shares in each entry of `strategies` by its respective `shares[i]`, typically called when the staker withdraws from EigenLayer
     * @dev Callable only by the StrategyManager
     */
    function decreaseDelegatedShares(
        address staker,
        IStrategy[] calldata strategies,
        uint256[] calldata shares
    )
        external
        onlyStrategyManager
    {

But in StrategyManager, there are only 3 cases where this is called, none of which is beneficial for the user:

In other words, the workaround (of setting receiveAsTokens to false in completeQueuedWithdrawal(s)) just leaves the funds accounted and stuck in DelegationManager.

In both cases, all shares/tokens associated with other strategies in the pending withdrawal are permanently blocked.

Proof of Concept

https://github.com/code-423n4/2023-04-eigenlayer/blob/main/src/contracts/core/StrategyManager.sol#L786-L789

Recommended Mitigation Steps

Add a cancelQueuedWithdrawl function that will undo the accounting and cancel out any dependency on the malicious strategy. Although this solution may create a front-running opportunity for when their withdrawal will be slashed via slashQueuedWithdrawal, there may exist workarounds to this.

Another possibility is to implement a similar mechanism to how slashQueuedWithdrawal treats malicious strategies: adding a list of strategy indices to skip.

https://github.com/code-423n4/2023-04-eigenlayer/blob/main/src/contracts/core/StrategyManager.sol#L532-L535 https://github.com/code-423n4/2023-04-eigenlayer/blob/main/src/contracts/core/StrategyManager.sol#L560-L566

     * @param indicesToSkip Optional input parameter -- indices in the `strategies` array to skip (i.e. not call the 'withdraw' function on). This input exists
     * so that, e.g., if the slashed QueuedWithdrawal contains a malicious strategy in the `strategies` array which always reverts on calls to its 'withdraw' function,
     * then the malicious strategy can be skipped (with the shares in effect "burned"), while the non-malicious strategies are still called as normal.
     */

     ...

        for (uint256 i = 0; i < strategiesLength;) {
            // check if the index i matches one of the indices specified in the `indicesToSkip` array
            if (indicesToSkipIndex < indicesToSkip.length && indicesToSkip[indicesToSkipIndex] == i) {
                unchecked {
                    ++indicesToSkipIndex;
                }
            } else {

Assessed type

DoS

Sidu28 (EigenLayer) disagreed with severity and commented:

The description of lack of check here is accurate. There is zero actual impact; we think this is informational severity.

Alex the Entreprenerd (judge) commented:

@Sidu28 - if we assumed the Strategy not to be malicious, but to revert for some reason (e.g. lack of liquidity, smart contract bug, etc…)

Would you consider the finding as valid since the user cannot withdrawal from all others due to having one withdraw, or is there some other reason why you believe the finding to be Informational?

Alex the Entreprenerd (judge) decreased severity to Medium and commented:

The Warden has shown how, any revert in a strategy (for example it being paused), will make queued withdrawals revert, even if the withdrawal should work for other strategies.

This falls into the category of DOS and I believe is more appropriately judged as Medium.

ChaoticWalrus (EigenLayer) commented:

@Alex the Entreprenerd - Even if a malicious strategy exists, there is no permanent delay here.

Users can mark the receiveAsTokens input to completeQueuedWithdrawal as false here and then the shares will be transferred to the ‘withdrawing’ user here who can then queue a new withdrawal not containing the malicious strategy.

The description provided by the warden of the DelegationManager’s behavior is inaccurate — the funds do not end up ‘stuck in the DelegationManager’ — they will be withdrawable as part of a new queued withdrawal, which excludes the malicious strategy.

ABA (warden) commented:

Hey, https://github.com/code-423n4/2023-04-eigenlayer/blob/main/src/contracts/core/StrategyManager.sol#L795-L803 does not do:

shares will be transferred to the ‘withdrawing’ user

It simply increments internal accounting and delegated shares associated to the user in the delegation contract. But these are not withdrawn without a queueWithdrawal call.

https://github.com/code-423n4/2023-04-eigenlayer/blob/main/src/contracts/core/StrategyManager.sol#L647

queue a new withdrawal not containing the malicious strategy.

A new queue can not reuse the already used balance, as it was already accounted for here.

Maybe I am missing something of course. Regardless, awaiting judge feedback.

ChaoticWalrus (EigenLayer) commented:

It simply increments internal accounting and delegated shares associated to the user in the delegation contract. But these are not withdrawn without a queueWithdrawal call

Yes, this is what I would describe as transferring the shares, similar to how the ‘transfer in’ portion of an ERC20 transfer works. But this is a semantic argument; I agree with the substance of your description.

A new queue can not reuse the already used balance as it was already accounted for here

Maybe I am missing something of course. Regardless, awaiting judge feedback.

I think perhaps you are missing that the internal _addShares function calls the DelegationManager as well. See here

If the user marks receiveAsTokens as false, then this line will be triggered, which calls into the internal _addShares function and ‘re-adds’ these delegated shares, so they can indeed be queued in a new withdrawal.

I can provide an example if it will help.

ChaoticWalrus (EigenLayer) commented:

Basically, the ‘re-adding’ reverses the accounting taken in the initial queueWithdrawal action, to clarify. This then allows the accounting done in the queueWithdrawal action to be performed once again when a new withdrawal is queued.

Alex the Entreprenerd (judge) commented:

@ChaoticWalrus - It seems like the worst case scenario would be having to re-queue without the missing strategy, which would require waiting for the withdrawal to unlock.

So the question left to answer is whether an additional wait period is acceptable.

NOTE: I edited this comment because as you pointed out, the shares accounting is internal and doesn’t trigger an interaction with the strategy.

ChaoticWalrus (EigenLayer) commented:

It seems like the worst case scenario would be having to re-queue without the missing strategy which would require waiting for the withdrawal to unlock

Yes, agreed this is the impact + worst-case scenario. The existing functionality was designed, in part at least, to address concerns about malicious Strategies.

So the question left to answer is whether an additional wait period is acceptable

I suppose so, yes. We have deemed this acceptable ourselves, but I could see it being viewed differently. Regardless, the impact here is orders of magnitude less than the original claimed impact.

Alex the Entreprenerd (judge) commented:

The Warden has shown how, due to the possibility of queueing a withdrawal with multiple strategies, in the case in which one of the strategies stops working (reverts, paused, malicious), the withdrawal would be denied.

As the sponsor said, in those scenarios, the withdrawer would have to perform a second withdrawal, which would have to be re-queued.

Intuitively, a withdrawer that always withdraws a separate strategy would also never see their withdrawal denied (except for the malicious strategy).

As we can see, there are plenty of side steps to the risk shown. However, the functionality of the function is denied, even if temporarily, leading to it not working as intended, and for this reason I believe Medium Severity to be the most appropriate.

As shown above, the finding could be fixed. However, it seems to me like most users would want to plan around the scenarios described in this finding and its duplicates.


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

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

Impact

A malicious strategy can permanently block all pending withdrawals that include it, preventing users from retrieving their tokens from other strategies, though a workaround exists that requires re-queuing and waiting.

What the attacker needed

A malicious strategy is created; user queues a withdrawal including it

The fix

Add a cancelQueuedWithdrawal function to undo accounting and remove dependency on the malicious strategy, or implement a skip mechanism similar to slashQueuedWithdrawal.

How it was found

  1. Queue a withdrawal that includes a malicious strategy.
  2. Attempt to complete the withdrawal with receiveAsTokens set to true.
  3. The malicious strategy's withdraw function reverts, causing the entire withdrawal to fail.

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 withdraw from EigenLayer, you can include several strategies (investment pools) in one withdrawal request. If one of those strategies is malicious and always fails when called, the whole withdrawal fails, so you cannot get your funds from the other strategies either. You could try a workaround, but it still leaves your funds stuck until you queue a new withdrawal without the bad strategy, which means waiting again.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by ABA

View all

3 more disclosed reports, best first.

More from EigenLayer Contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.