Skip to content
DoS Audit finding Intermediate

Unconsented stakeOnBehalf enables **unbounded gas consumption** via userValidators[] growth, causing DoS at scale in claimAll() / withdraw()

The stakeOnBehalf function lets anyone add a validator to a victim's userValidators array without consent, and core functions like claimAll and withdraw loop over this array. An attacker can repeatedly call stakeOnBehalf to bloat the array, raising the victim's gas costs and potentially causing a denial of service at high validator counts.

wylis Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

52573 sc high unconsented stakeonbehalf enables unbounded gas consumption via uservalidators growth causing dos at scale in claimall withdraw

Submitted on Aug 11th 2025 at 17:55:42 UTC by @wylis for Attackathon | Plume Network

Description

Inro

Anyone can call stakeOnBehalf() with ≥ minStakeAmount, which forcibly appends validatorId to userValidators[] without the user’s consent. Core user flows iterate this array, so the attacker can arbitrarily increase a victim’s gas costs. In our test, pushing a user from 1 → 15 validators raised claimAll() gas from 68,613 to 395,829 (~5.77×). At higher validator counts the same paths can hit block gas limits, turning this from a cost-imposition into a functional DoS.

Vulnerability Details

Root cause: stakeOnBehalf records stake for an arbitrary user and adds that validator to userValidators[user] with no beneficiary approval. Gas-critical code paths iterate that array:

  • RewardsFacet
    • claimAll(): for each reward token, calls an internal that loops userValidators[msg.sender] to settle rewards across all validators.
    • claim(): Single-token version, but still loops over validators for that token.
  • StakingFacet
    • withdraw(): calls _processMaturedCooldowns() which loops userValidators[user] to move matured cooldown balances.
    • restakeRewards(): also triggers _processMaturedCooldowns(user).
    • amountWithdrawable(): uses _calculateTotalWithdrawableAmount() which loops userValidators[user] to sum matured cooldowns.

Complexity:

  • claimAll() ≈ O(#rewardTokens × #userValidators)
  • Other API ≈ O(#userValidators)

Attacker control:
Attacker repeats stakeOnBehalf() for each validator ID (enumerated via getValidatorsList()), paying only minStakeAmount each time. This permanently bloats userValidators[] until the victim performs gas-heavy clean-up.

Economics:
Grief cost upper bound = minStakeAmount × validatorCount (attacker capital stays staked as the victim’s balance). With low minStakeAmount or many validators, this is practical.

Impact Details

  • Primary (defensible): High — Unbounded gas consumption
    The attacker can arbitrarily increase userValidators[]. Gas scales linearly across multiple core functions.
  • Potential escalation (evidence-dependent): High — Temporary freezing of funds (≥ 24h)
    APIs (e.g. claimAll()) could exceed block gas limits at high parameters (e.g., 50–100 validators). The victim could not complete normal flows.
  • Not claimed (impact tied to slashing): Though it does not expose attacker-controlled loss of a victim’s existing funds, it should be noted that victim's gifted funds are exposed to slashing and not necessarily available to them.

Link to Proof of Concept

https://gist.github.com/wylis-hodor/a183e7d1b051c1a2cd30b89178f88fee

Proof of Concept

{% stepper %} {% step %}

Setup

  • Deploy/initialize as in project tests (e.g. 15 validators; 1 reward token).
  • Record baseline gas for the victim calling claimAll() once (~68,613). {% endstep %}

{% step %}

Attack

  • Attacker enumerates validators with getValidatorsList().
  • For each ID, attacker calls stakeOnBehalf(vid, victim) sending exactly minStakeAmount.
  • Confirm validators.getUserValidators(victim).length increased to the validator count. {% endstep %}

{% step %}

Impact

  • Victim calls claimAll().
  • Observe gas increase with e.g. 15 validators (5.8×). Gas increased to ~395,829.

Note: Attack scales with validator count toward approaching/exceeding block gas limits. {% endstep %} {% endstepper %}

References

{% hint style="warning" %} Mitigation should require beneficiary approval before adding validators to a user's userValidators[], or ensure duplicate/forced entries cannot be appended by third parties. Also consider making gas-critical loops bounded or paginated, and adding gas/cost protections when iterating user arrays. {% endhint %}

The original report as published on Immunefi, by wylis. 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 adds validators to a user's userValidators array without the user's approval, and critical functions iterate over this unbounded array.

Impact

The attacker can arbitrarily increase the victim's gas costs for claimAll and withdraw, and at high validator counts these functions could exceed block gas limits, causing a temporary denial of service.

What the attacker needed

Attacker has minStakeAmount per validator; Victim has a staking account; Validator list is enumerable

The fix

The contract should require beneficiary approval before adding validators to a user's userValidators array, or prevent third parties from appending duplicate or forced entries, and consider bounding or paginating gas-critical loops.

How it was found

  1. Deploy and initialise the contracts with 15 validators and 1 reward token, then record the baseline gas for claimAll.
  2. Attacker enumerates validator IDs using getValidatorsList.
  3. For each validator ID, attacker calls stakeOnBehalf with the victim's address and exactly minStakeAmount.
  4. Confirm that the victim's userValidators array length increased to the number of validators.
  5. Victim calls claimAll and the gas usage is observed to increase significantly.

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 function lets anyone stake tokens on behalf of another user, and this adds an entry to a list tied to that user. Several important actions, such as claiming rewards or withdrawing, go through that list one by one, so a longer list means more work and higher fees. An attacker can make the list very long, making those actions expensive or even impossible for the victim.

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 wylis

View all

4 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.