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.
- 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
- Report ID: #52573
- Report Type: Smart Contract
- Report severity: High
- Target: https://github.com/immunefi-team/attackathon-plume-network/blob/main/plume/src/facets/StakingFacet.sol
- Impacts: Unbounded gas consumption
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 loopsuserValidators[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 loopsuserValidators[user]to move matured cooldown balances.restakeRewards(): also triggers_processMaturedCooldowns(user).amountWithdrawable(): uses_calculateTotalWithdrawableAmount()which loopsuserValidators[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 increaseuserValidators[]. 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 exactlyminStakeAmount. - Confirm
validators.getUserValidators(victim).lengthincreased 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
- Target file: https://github.com/immunefi-team/attackathon-plume-network/blob/main/plume/src/facets/StakingFacet.sol
- PoC gist: https://gist.github.com/wylis-hodor/a183e7d1b051c1a2cd30b89178f88fee
{% 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 %}
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
- Deploy and initialise the contracts with 15 validators and 1 reward token, then record the baseline gas for claimAll.
- Attacker enumerates validator IDs using getValidatorsList.
- For each validator ID, attacker calls stakeOnBehalf with the victim's address and exactly minStakeAmount.
- Confirm that the victim's userValidators array length increased to the number of validators.
- 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.