Skip to content
Business logic Audit finding Intermediate

`DineroWithdrawRequestManager` vulnerable to token overwithdrawal via batch ID overlap

The DineroWithdrawRequestManager contract does not track upxETH token balances per withdrawal request, so when batch IDs overlap between requests, a user can redeem tokens that belong to another user's request. An attacker can front-run another user's withdrawal to cause an overlap and withdraw more tokens than intended, causing financial loss to the victim.

0xc0ffEE Follow with Atharv, Ledger_Patrol and 7 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-06-notional-exponent-judging/issues/297

Found by

0xc0ffEE, Atharv, Ledger_Patrol, Ragnarok, Schnilch, X0sauce, aman, hgrano, seeques, xiaoming90

Summary

Some users may profit while others incur losses because the DineroWithdrawRequestManager contract does not track the balance of each upxETH token per withdrawal request, even though a single upxETH token may be associated with multiple requests.

Root Cause

When a user initiates a withdrawal request through DineroWithdrawRequestManager, the contract executes the _initiateWithdrawImpl() function. This function captures PirexETH.batchId() before and after calling PirexETH::initiateRedemption():

DineroWithdrawRequestManager::_initiateWithdrawImpl() function:

Solidity
function _initiateWithdrawImpl(
    address /* account */,
    uint256 amountToWithdraw,
    bytes calldata /* data */
) override internal returns (uint256 requestId) {
      ...
=>    uint256 initialBatchId = PirexETH.batchId();
      pxETH.approve(address(PirexETH), amountToWithdraw);
      PirexETH.initiateRedemption(amountToWithdraw, address(this), false);
=>    uint256 finalBatchId = PirexETH.batchId();
      uint256 nonce = ++s_batchNonce;

=>    return nonce << 240 | initialBatchId << 120 | finalBatchId;
  }

When the user later finalizes the withdrawal via _finalizeWithdrawImpl(), the contract attempts to redeem all upxETH tokens within the range [initialBatchId, finalBatchId]:

Solidity
function _finalizeWithdrawImpl(
    address /* account */,
    uint256 requestId
) internal override returns (uint256 tokensClaimed, bool finalized) {
    finalized = canFinalizeWithdrawRequest(requestId);

    if (finalized) {
        (uint256 initialBatchId, uint256 finalBatchId) = _decodeBatchIds(requestId);

=>      for (uint256 i = initialBatchId; i <= finalBatchId; i++) {
=>          uint256 assets = upxETH.balanceOf(address(this), i);
            if (assets == 0) continue;
            PirexETH.redeemWithUpxEth(i, assets, address(this));
            tokensClaimed += assets;
        }
    }

    WETH.deposit{value: tokensClaimed}();
}

After this, upxETH.balanceOf(address(this), i) for all i in the range [initialBatchId, finalBatchId] becomes 0.

On the other hand, initialBatchId and finalBatchId may overlap across multiple withdrawal requests due to the logic inside PirexETH::initiateRedemption(), which internally calls PirexEthValidators::_initiateRedemption():

Solidity
function _initiateRedemption(
    uint256 _pxEthAmount,
    address _receiver,
    bool _shouldTriggerValidatorExit
) internal {
    pendingWithdrawal += _pxEthAmount;

    while (pendingWithdrawal / DEPOSIT_SIZE != 0) {
        uint256 _allocationPossible = DEPOSIT_SIZE + _pxEthAmount - pendingWithdrawal;

=>      upxEth.mint(_receiver, batchId, _allocationPossible, "");
        ...
        batchIdToValidator[batchId++] = _pubKey;
        status[_pubKey] = DataTypes.ValidatorStatus.Withdrawable;
    }
    ...
    if (_pxEthAmount > 0) {
=>      upxEth.mint(_receiver, batchId, _pxEthAmount, "");
    }
}

This can lead to some users benefiting at the expense of others. Consider the following scenario:

  1. User A initiates a withdrawal request, associated with upxETH token IDs 1 and 2.
  2. User B then initiates a withdrawal request, associated with token IDs 2 and 3.
  3. User A finalizes their request and redeems all ETH from token IDs 1 and 2, even though ID 2 is also tied to User B's request. User A withdraws more than intended.
  4. When User B finalizes their request, the balance of token ID 2 is already 0. Thus, they only receive the ETH from token ID 3.

A malicious user can exploit this behavior by front-running another user’s withdrawal request, intentionally causing batch ID overlaps and withdrawing more tokens than intended.

Impact

A malicious user can:

  • Withdraw more tokens than they should by front-running others.
  • Cause financial loss to other users.

Mitigation

Update the DineroWithdrawRequestManager contract to track upxETH balances per withdrawal request:

Add state variables:

Solidity
mapping(uint256 requestId => mapping(uint256 batchId => uint256 balance)) upxETHBalanceOfRequest;
mapping(uint256 batchId => uint256 balance) latestUpxETHBalance;

Modify _initiateWithdrawImpl:

Diff
function _initiateWithdrawImpl(
    address /* account */,
    uint256 amountToWithdraw,
    bytes calldata /* data */
) override internal returns (uint256 requestId) {
    ...
    // Initial and final batch ids may overlap between requests so the nonce is used to ensure uniqueness
-   return nonce << 240 | initialBatchId << 120 | finalBatchId;
+   requestId = nonce << 240 | initialBatchId << 120 | finalBatchId;

+   for (uint256 i = initialBatchId; i <= finalBatchId; i += 1) {
+       uint256 currentBalance = upxETH.balanceOf(address(this), i);
+       upxETHBalanceOfRequest[requestId][i] =  currentBalance - latestUpxETHBalance[i];
+       latestUpxETHBalance[i] = currentBalance;
+   }
    
}

Modify _finalizeWithdrawImpl:

Diff
function _finalizeWithdrawImpl(
    address /* account */,
    uint256 requestId
) internal override returns (uint256 tokensClaimed, bool finalized) {
    finalized = canFinalizeWithdrawRequest(requestId);

    if (finalized) {
        (uint256 initialBatchId, uint256 finalBatchId) = _decodeBatchIds(requestId);

        for (uint256 i = initialBatchId; i <= finalBatchId; i++) {
-           uint256 assets = upxETH.balanceOf(address(this), i);
+           uint256 assets = upxETHBalanceOfRequest[requestId][i];
            if (assets == 0) continue;
            PirexETH.redeemWithUpxEth(i, assets, address(this));
            tokensClaimed += assets;
+           latestUpxETHBalance[i] -= assets;
        }
    }

    WETH.deposit{value: tokensClaimed}();
}

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/notional-finance/notional-v4/pull/20

The original report as published on Sherlock, by 0xc0ffEE. 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 contract does not track upxETH balances per withdrawal request, so overlapping batch ID ranges allow one request to redeem tokens belonging to another.

Impact

A malicious user could withdraw more tokens than they should by front-running others and cause financial loss to other users.

What the attacker needed

Attacker can front-run victim's withdrawal; batch IDs overlap between requests

The fix

The protocol team fixed this issue by updating the contract to track upxETH balances per withdrawal request.

How it was found

  1. User A initiates a withdrawal request, which is associated with upxETH token IDs 1 and 2.
  2. User B then initiates a withdrawal request, which is associated with token IDs 2 and 3.
  3. User A finalizes their request and redeems all ETH from token IDs 1 and 2, including ID 2 which is also tied to User B's request.
  4. When User B finalizes their request, the balance of token ID 2 is already zero, so they only receive ETH from token ID 3.

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 request a withdrawal, the system gives you a receipt that covers a range of batch numbers. If two people's ranges overlap, the first person to finish can accidentally (or deliberately) take tokens that belong to the second person. This happens because the contract doesn't remember exactly how many tokens each person's request should get.

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 0xc0ffEE

View all

27 more disclosed reports, best first.

More from Notional Exponent

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.