Skip to content
Business logic Audit finding Intermediate

The PufferVaultgetPendingLidoETHAmount will ret

The vault tracks ETH locked in Lido's withdrawal queue in a state variable that is increased by the requested amount and decreased by the amount actually received on claim. Because stETH rebases and can be slashed, the requested and claimed amounts can differ, so the pending-amount getter can report a value that does not reflect reality.

aman Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

28796 - [SC - Low] The PufferVaultgetPendingLidoETHAmount will ret...

Submitted on Feb 27th 2024 at 16:52:00 UTC by @aman for Boost | Puffer Finance

Report ID: #28796

Report type: Smart Contract

Report severity: Low

Target: https://etherscan.io/address/0xd9a442856c234a39a81a089c06451ebaa4306a72

Impacts:

  • Contract fails to deliver promised returns, but doesn't lose value

Description

Brief/Intro

The Contract PufferVault:: $.lidoLockedETH does not store correct value in case of deposit and withdrawal will leads to return wrong value PufferVault::getPendingLidoETHAmount.

Vulnerability Details

Offer a detailed explanation of the vulnerability itself. Do not leave out any relevant information. Code snippets should be supplied whenever helpful, as long as they don’t overcrowd the report with unnecessary details. This section should make it obvious that you understand exactly what you’re talking about, and more importantly, it should be clear by this point that the vulnerability does exist.

The Protocols integrate Lido staking for earning staking rewards on depositing user ETH at Lido. Here I assume that the assets are staked at Lido correctly. For withdrawal Lido uses Withdrawal queue. The users must initiate Withdrawal request from Lido withdrawal queue. The request code : it stored the requested amount in $.lidoLockedETH state varaible.

JavaScript
function initiateETHWithdrawalsFromLido(uint256[] calldata amounts)
        [...]
    {
        VaultStorage storage $ = _getPufferVaultStorage();

        uint256 lockedAmount;
        for (uint256 i = 0; i < amounts.length; ++i) {
            lockedAmount += amounts[i];
        }
 @:263       $.lidoLockedETH += lockedAmount;

        SafeERC20.safeIncreaseAllowance(_ST_ETH, address(_LIDO_WITHDRAWAL_QUEUE), lockedAmount);
        requestIds = _LIDO_WITHDRAWAL_QUEUE.requestWithdrawals(amounts, address(this));
   [...]
    }

when user claim request from Lido The contract checks if $.isLidoWithdrawal is true. than in default receive() it decrease the $.lidoLockedETH by msg.value received. following are the relevant code snippet:

JavaScript
  receive() external payable virtual {
        // If we don't use this pattern, somebody can create a Lido withdrawal, claim it to this contract
        // Making `$.lidoLockedETH -= msg.value` revert
        VaultStorage storage $ = _getPufferVaultStorage();
        if ($.isLidoWithdrawal) {
            $.lidoLockedETH -= msg.value;
        }
    }

....

function claimWithdrawalsFromLido(uint256[] calldata requestIds) external virtual {
        VaultStorage storage $ = _getPufferVaultStorage();

        // Tell our receive() that we are doing a Lido claim
        $.isLidoWithdrawal = true;

        for (uint256 i = 0; i < requestIds.length; ++i) {
            bool isValidWithdrawal = $.lidoWithdrawals.remove(requestIds[i]);
            if (!isValidWithdrawal) {
                revert InvalidWithdrawal();
            }

            // slither-disable-next-line calls-loop
            _LIDO_WITHDRAWAL_QUEUE.claimWithdrawal(requestIds[i]);
        }

        // Reset back the value
        $.isLidoWithdrawal = false;
        emit ClaimedWithdrawals(requestIds);
    }

Impact Details

The issue is That STETH is Re-basing token, due to which the the amount requested and amount claimed will not be the same if slashing occurs at Lido. Due to which the lidoLockedETH will report a value which in reality is not present or locked.

References

https://github.com/PufferFinance/pufETH/blob/main/src/PufferVault.sol#L83 https://github.com/PufferFinance/pufETH/blob/main/src/PufferVault.sol#L262

Proof of Concept

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

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

Likely the pending amount is tracked by adding the requested amount and subtracting the received amount, which diverge when the rebasing stETH balance changes between request and claim.

Impact

The getPendingLidoETHAmount getter could return an inaccurate pending figure, so the contract fails to deliver promised returns, though no funds are lost.

What the attacker needed

Lido slashing or rebase between request and claim

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.

The vault sends ETH to Lido, a staking service, and records how much it asked to withdraw. When the money comes back, it subtracts whatever actually arrived. Lido's balance can shrink (slashing) or change over time, so the two numbers may not match and the vault's record of 'still pending' becomes wrong.

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 by aman

View all

16 more disclosed reports, best first.

More from Puffer Finance

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.