Skip to content
Business logic Audit finding Beginner

Gas inefficiency due to redundant _validateValidatorExists() modifier in requestCommissionClaim()

The requestCommissionClaim function applies two modifiers that both check whether the validator exists, so the same storage slot is read twice. This wastes roughly 2,100 gas per commission claim call for validator operators.

Plume Network

Originally disclosed on Immunefi

Informational View original

51707 sc insight gas inefficiency due to redundant validatevalidatorexists modifier in requestcommissionclaim

Description

Brief/Intro

The requestCommissionClaim() function in ValidatorFacet.sol applies two validators that both check the same validatorExists[validatorId] condition: the modifier onlyValidatorAdmin(validatorId) and the modifier _validateValidatorExists(validatorId). Because the same storage read and conditional are performed twice, this results in unnecessary gas consumption for every commission claim request.

Vulnerability Details

The function declares modifiers as follows:

Solidity
function requestCommissionClaim(
    uint16 validatorId,
    address token
)
    external
    onlyValidatorAdmin(validatorId)        // First validation
    nonReentrant
    _validateValidatorExists(validatorId)   // Redundant validation
    _validateIsToken(token)
{
    // Function implementation
}

onlyValidatorAdmin already performs a validator existence check:

Solidity
modifier onlyValidatorAdmin(uint16 validatorId) {
    if (!PlumeStakingStorage.layout().validatorExists[validatorId]) {
        revert ValidatorDoesNotExist(validatorId);
    }
    if (msg.sender != PlumeStakingStorage.layout().validators[validatorId].l2AdminAddress) {
        revert NotValidatorAdmin(msg.sender);
    }
    _;
}

_validateValidatorExists performs the identical existence check:

Solidity
modifier _validateValidatorExists(uint16 validatorId) {
    if (!PlumeStakingStorage.layout().validatorExists[validatorId]) {
        revert ValidatorDoesNotExist(validatorId);
    }
    _;
}

Because both modifiers execute, the same storage read PlumeStakingStorage.layout().validatorExists[validatorId] is performed twice.

Impact Details

Gas inefficiency impact:

  • Each redundant validation costs roughly one additional SLOAD and conditional logic (~2,100+ gas).
  • For frequent commission claim operations, this produces cumulative and avoidable gas waste for validator operators.

References

Proof of Concept

Scenario: Validator wastes gas when requesting for commission

  • Setup: Validator is active, not slashed, has accrued rewards and commissions
  • Assume: validator ID is 1
  • Action: Validator admin calls requestCommissionClaim(1, 0x123...)

{% stepper %} {% step %}

Modifier Execution: onlyValidatorAdmin(1)

  • Storage Read #1: validatorExists[1] → Returns true (~2,100 gas)
  • Conditional Check: !validatorExists[1] → false, continues
  • Storage Read #2: validators[1].l2AdminAddress → Returns 0x123...
  • Authorization Check: msg.sender == 0x123.. → true, continues {% endstep %}

{% step %}

Modifier Execution: _validateValidatorExists(1) (redundant)

  • Storage Read #3: validatorExists[1] → Returns true (~2,100 gas) — redundant {% endstep %} {% endstepper %}

Redundant Gas Consumption: approximately 2,100 gas for the extra SLOAD and associated logic.

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

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 3 min read.

Context

Plume Network is a staking system whose validator-facing logic lives in a set of Solidity facets. The target of this report is ValidatorFacet.sol, specifically the requestCommissionClaim() function, which a validator admin calls to request a claim of accrued commission for a given validator and token.

The function is guarded by several modifiers: an admin check, a reentrancy guard, a validator existence check and a token check. The report argues that two of those modifiers perform the same existence check, so every call pays for the same storage read twice.

Setup

The report does not describe any tooling, test harness, fork or deployment. The only preconditions it states are in the proof of concept scenario:

  • The validator is active, not slashed, and has accrued rewards and commissions.
  • The caller is the validator admin.
  • The validator ID used in the example is 1.

No versions, compiler settings or gas measurements from a live run are given; the gas figure is an estimate.

Finding it

The researcher looked at the modifier list on requestCommissionClaim() and noticed that two of the modifiers test the same condition. The function is declared as follows:

Solidity
function requestCommissionClaim(
    uint16 validatorId,
    address token
)
    external
    onlyValidatorAdmin(validatorId)        // First validation
    nonReentrant
    _validateValidatorExists(validatorId)   // Redundant validation
    _validateIsToken(token)
{
    // Function implementation
}

onlyValidatorAdmin already checks that the validator exists before checking that the caller is its admin:

Solidity
modifier onlyValidatorAdmin(uint16 validatorId) {
    if (!PlumeStakingStorage.layout().validatorExists[validatorId]) {
        revert ValidatorDoesNotExist(validatorId);
    }
    if (msg.sender != PlumeStakingStorage.layout().validators[validatorId].l2AdminAddress) {
        revert NotValidatorAdmin(msg.sender);
    }
    _;
}

_validateValidatorExists performs the identical existence check:

Solidity
modifier _validateValidatorExists(uint16 validatorId) {
    if (!PlumeStakingStorage.layout().validatorExists[validatorId]) {
        revert ValidatorDoesNotExist(validatorId);
    }
    _;
}

Because both modifiers execute on every call, the same storage read, PlumeStakingStorage.layout().validatorExists[validatorId], is performed twice. The second one can never fail if the first one passed, so it adds cost without adding a check.

Exploitation

The report frames this as a gas inefficiency rather than an attack. The proof of concept walks through a single call and counts the storage reads.

Step 1: onlyValidatorAdmin(1) runs

  • Storage read #1: validatorExists[1] returns true (about 2,100 gas).
  • Conditional check: !validatorExists[1] is false, so execution continues.
  • Storage read #2: validators[1].l2AdminAddress returns 0x123....
  • Authorization check: msg.sender == 0x123.. is true, so execution continues.

Step 2: _validateValidatorExists(1) runs

  • Storage read #3: validatorExists[1] returns true again (about 2,100 gas), and this read is redundant.

The action in the scenario is a validator admin calling requestCommissionClaim(1, 0x123...). The report does not show a transaction hash, a trace or a measured gas delta; the redundant cost is stated as approximately 2,100 gas for the extra SLOAD and the associated logic.

Root cause

The function applies both onlyValidatorAdmin(validatorId) and _validateValidatorExists(validatorId), and both begin with the same check against validatorExists[validatorId]. Since onlyValidatorAdmin already reverts with ValidatorDoesNotExist(validatorId) when the validator is missing, the later modifier is unreachable in its failure path and only repeats a storage read that has just been performed. The function applies both modifiers, so the same storage read is performed twice.

Impact

The impact is limited to gas. Each redundant validation costs roughly one additional SLOAD and conditional logic, estimated at about 2,100+ gas. For frequent commission claim operations this produces cumulative, avoidable gas waste for validator operators. The report does not claim any loss of funds, denial of service, incorrect state or privilege escalation, and it was filed as an Insight severity.

Fix

The obvious change would be to remove the redundant _validateValidatorExists(validatorId) modifier from requestCommissionClaim(), since onlyValidatorAdmin(validatorId) already enforces the same existence check, leaving nonReentrant and _validateIsToken(token) in place.

  • Audit other functions in the same facet for modifier lists that combine onlyValidatorAdmin with _validateValidatorExists. A positive result is a function where both modifiers appear and the existence check therefore runs twice.
  • Look for any other pair of modifiers that read the same storage slot or mapping entry. A positive result is two modifiers whose first statement is the same PlumeStakingStorage.layout() read.
  • Check functions that call an internal helper performing an existence check after a modifier has already done so. A positive result is a duplicated validatorExists[...] read on the same execution path.
  • Compare gas usage of a call before and after removing the suspected duplicate modifier. A positive result is a measurable reduction with no change in revert behaviour.

Hunting notes

During review, list every modifier on a function and expand each one to its body; duplicated storage reads stand out quickly.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

What happened, in plain words

A security researcher looked at a smart contract called ValidatorFacet.sol on Plume Network. Plume Network is a system where people lock up cryptocurrency (this is called staking) and earn rewards for it. Validators are the operators who run this system, and they earn a cut called a commission.

The contract has a function called requestCommissionClaim(). A validator admin (the person in charge of a validator) calls it to ask for their earned commission to be paid out. Before the function does its real work, it runs a series of safety checks called modifiers. A modifier is a small piece of code that runs before (or after) a function, usually to check something and stop the call if the check fails. Think of it like a bouncer at a door who checks your ticket before letting you in.

The researcher noticed that two of these checks do exactly the same thing: they both look up whether the validator exists. So every time someone calls the function, the contract reads the same piece of stored data twice. Reading stored data on a blockchain costs gas, and gas costs money. The second read adds nothing, because if the first check passed, the second one can never fail. The result is a small, avoidable waste of money for every commission claim.

This is not a break-in. Nobody can steal funds, freeze the system or gain extra privileges with it. The report was filed as an Insight, which is the lowest kind of finding: a note about efficiency rather than a vulnerability.

Context

Plume Network's validator logic is split into several files called facets. A facet is a way of organising a large smart contract into smaller pieces, each handling one area of behaviour. The target here is one facet, ValidatorFacet.sol, and inside it one function, requestCommissionClaim().

That function is what a validator admin calls to request a claim of commission that has built up for a particular validator and a particular token. A token here is a digital asset on the blockchain, identified by an address (a long string of characters that works like an account number).

The function is protected by several modifiers, one after another:

  1. An admin check, which confirms the caller is allowed to act for this validator.
  2. A reentrancy guard, which prevents a known class of attack where a contract is re-entered while it is still running (imagine someone sneaking back through the door before it has closed).
  3. A validator existence check, which confirms the validator is known to the system.
  4. A token check, which confirms the token argument is acceptable.

The report's argument is simple: two of those modifiers perform the same existence check, so every call pays for the same storage read twice.

Setup

The report does not describe any tools, test environment, copy of the blockchain or deployment. The only preconditions it gives are in the proof of concept scenario:

  • The validator is active, not slashed, and has accrued rewards and commissions. "Slashed" means punished by having some staked funds taken away for misbehaviour; an active, un-slashed validator is one in good standing.
  • The caller is the validator admin.
  • The validator ID used in the example is 1. A validator ID is a number that identifies a validator in the system.

No versions, compiler settings or gas measurements from a real run are given. The gas figure in the report is an estimate.

Finding it

The researcher read the list of modifiers attached to requestCommissionClaim() and noticed that two of them test the same condition. Here is how the function is declared:

Solidity
function requestCommissionClaim(
    uint16 validatorId,
    address token
)
    external
    onlyValidatorAdmin(validatorId)        // First validation
    nonReentrant
    _validateValidatorExists(validatorId)   // Redundant validation
    _validateIsToken(token)
{
    // Function implementation
}

Line by line:

  • function requestCommissionClaim( starts the declaration of a function named requestCommissionClaim.
  • uint16 validatorId, is the first input: a whole number (uint16 means an unsigned 16-bit integer, so a number from 0 to 65,535) identifying the validator.
  • address token is the second input: a blockchain address identifying the token whose commission is being claimed.
  • external means the function can be called from outside the contract, for example by a user or another contract.
  • onlyValidatorAdmin(validatorId) is the first modifier. It receives the validator ID and checks that the caller is that validator's admin.
  • nonReentrant is the reentrancy guard. It marks the function as "in progress" so it cannot be entered again before it finishes.
  • _validateValidatorExists(validatorId) is the modifier the report calls redundant. It checks that the validator exists.
  • _validateIsToken(token) checks the token argument.
  • The braces hold the actual body of the function, which the report does not show.

Modifiers run in the order they are listed, before the function body. So the admin check runs first, then the reentrancy guard, then the existence check, then the token check.

Next, the report shows what onlyValidatorAdmin does internally:

Solidity
modifier onlyValidatorAdmin(uint16 validatorId) {
    if (!PlumeStakingStorage.layout().validatorExists[validatorId]) {
        revert ValidatorDoesNotExist(validatorId);
    }
    if (msg.sender != PlumeStakingStorage.layout().validators[validatorId].l2AdminAddress) {
        revert NotValidatorAdmin(msg.sender);
    }
    _;
}

Line by line:

  • modifier onlyValidatorAdmin(uint16 validatorId) { declares a modifier that takes a validator ID.
  • if (!PlumeStakingStorage.layout().validatorExists[validatorId]) { reads a stored record called validatorExists for this validator ID and checks whether it is false. PlumeStakingStorage.layout() is a helper that returns the contract's stored data; validatorExists is a lookup table (a mapping) from validator ID to true or false. The ! means "not".
  • revert ValidatorDoesNotExist(validatorId); stops the whole call and reports the error ValidatorDoesNotExist with the offending ID. revert means cancel everything and undo any changes.
  • if (msg.sender != PlumeStakingStorage.layout().validators[validatorId].l2AdminAddress) { checks whether the caller (msg.sender, the address that invoked the function) is different from the admin address recorded for this validator. l2AdminAddress is the field holding that admin address.
  • revert NotValidatorAdmin(msg.sender); stops the call with the error NotValidatorAdmin if the caller is not the admin.
  • _; is a placeholder that means "now run the function body (or the next modifier)".
  • The closing brace ends the modifier.

So onlyValidatorAdmin already checks that the validator exists, before it checks that the caller is the admin. That ordering makes sense: you cannot look up a validator's admin if the validator is not there.

Then the report shows the second modifier:

Solidity
modifier _validateValidatorExists(uint16 validatorId) {
    if (!PlumeStakingStorage.layout().validatorExists[validatorId]) {
        revert ValidatorDoesNotExist(validatorId);
    }
    _;
}

Line by line:

  • modifier _validateValidatorExists(uint16 validatorId) { declares a modifier that takes a validator ID.
  • if (!PlumeStakingStorage.layout().validatorExists[validatorId]) { performs exactly the same read and test as the first modifier: is this validator missing?
  • revert ValidatorDoesNotExist(validatorId); stops the call with the same error if it is missing.
  • _; continues to the next modifier or the function body.
  • The closing brace ends the modifier.

Because both modifiers run on every call, the same storage read, PlumeStakingStorage.layout().validatorExists[validatorId], happens twice. The second one can never fail if the first one passed, so it adds cost without adding a check.

Exploitation

It describes wasted gas. Gas is the unit that measures computational work on a blockchain; every operation costs a certain amount of gas, and the caller pays for it. Reading from storage (an SLOAD, short for "storage load") is one of the more expensive operations.

The proof of concept walks through a single call and counts the storage reads.

Step 1: onlyValidatorAdmin(1) runs

  • Storage read #1: validatorExists[1] returns true (about 2,100 gas).
  • Conditional check: !validatorExists[1] is false, so execution continues.
  • Storage read #2: validators[1].l2AdminAddress returns 0x123....
  • Authorization check: msg.sender == 0x123.. is true, so execution continues.

In plain words: the contract first looks up whether validator 1 exists. It does, so the check passes. Then it looks up who the admin of validator 1 is, and compares that with the caller. They match, so this modifier lets the call continue.

Step 2: _validateValidatorExists(1) runs

  • Storage read #3: validatorExists[1] returns true again (about 2,100 gas), and this read is redundant.

In plain words: the contract looks up whether validator 1 exists a second time. It gets the same answer as before, because nothing has changed in between. This read is the waste.

The action in the scenario is a validator admin calling requestCommissionClaim(1, 0x123...). It states the redundant cost as approximately 2,100 gas for the extra SLOAD and the associated logic.

Root cause

The function applies both onlyValidatorAdmin(validatorId) and _validateValidatorExists(validatorId), and both begin with the same check against validatorExists[validatorId]. Since onlyValidatorAdmin already reverts with ValidatorDoesNotExist(validatorId) when the validator is missing, the later modifier can never be the one that catches a missing validator. It only repeats a storage read that has just been performed.

The function applies both modifiers, so the same storage read is performed twice. In everyday terms: two guards are posted at the same door, and the second one asks for the same ticket the first one has already checked.

Impact

The impact is limited to gas. Each redundant validation costs roughly one additional SLOAD and conditional logic, estimated at about 2,100+ gas. For frequent commission claim operations this produces cumulative, avoidable gas waste for validator operators.

The report does not claim any loss of funds, denial of service, incorrect state or privilege escalation. It was filed as an Insight severity, the lowest level, which fits a finding that only concerns efficiency.

Fix

The obvious change would be to remove the redundant _validateValidatorExists(validatorId) modifier from requestCommissionClaim(), since onlyValidatorAdmin(validatorId) already enforces the same existence check. That would leave nonReentrant and _validateIsToken(token) in place, so the reentrancy guard and the token check still run.

Variants to test

  • Audit other functions in the same facet for modifier lists that combine onlyValidatorAdmin with _validateValidatorExists. A positive result is a function where both modifiers appear and the existence check therefore runs twice.
  • Look for any other pair of modifiers that read the same storage slot or mapping entry. A positive result is two modifiers whose first statement is the same PlumeStakingStorage.layout() read.
  • Check functions that call an internal helper performing an existence check after a modifier has already done so. A positive result is a duplicated validatorExists[...] read on the same execution path.
  • Compare gas usage of a call before and after removing the suspected duplicate modifier. A positive result is a measurable reduction with no change in revert behaviour.

Hunting notes

During review, list every modifier on a function and expand each one to its body; duplicated storage reads stand out quickly.

Glossary

  • Smart contract: a program that lives on a blockchain and runs automatically when called.
  • Blockchain: a shared, append-only record of transactions that many computers keep in sync.
  • Solidity: the programming language used to write smart contracts on Ethereum-style blockchains.
  • Plume Network: the staking system this report targets.
  • Staking: locking up cryptocurrency to support a network and earn rewards.
  • Validator: an operator in the staking system that runs the infrastructure and earns rewards and commission.
  • Commission: the cut of rewards that a validator earns for its work.
  • Validator admin: the address authorised to act on behalf of a validator.
  • Facet: one file or module of a larger smart contract, grouping related functions.
  • Function: a named block of code that can be called with inputs and may return outputs.
  • Modifier: a piece of code attached to a function that runs before or after it, usually to enforce a check.
  • Reentrancy guard: a modifier that stops a function being entered again while it is still running.
  • revert: cancel the current call and undo its changes, returning an error.
  • msg.sender: the address that called the current function.
  • Address: a blockchain identifier, written as a hexadecimal string such as 0x123....
  • Token: a digital asset on the blockchain, identified by an address.
  • Mapping: a lookup table in Solidity that maps keys to values, here validator IDs to true or false.
  • Storage: the permanent data a contract keeps on the blockchain.
  • SLOAD: a storage load, the operation that reads a value from contract storage; it costs gas.
  • Gas: the unit that measures computational work on a blockchain; the caller pays for it.
  • Gas inefficiency: code that spends more gas than necessary to achieve the same result.
  • Insight: the lowest severity level for a finding, used for notes about efficiency or code quality rather than exploitable flaws.
  • Proof of concept (PoC): a walkthrough or demonstration showing that a finding is real.
  • Slashed: punished by having some staked funds taken away for misbehaviour.
  • Privilege escalation: gaining permissions or powers a user should not have.
  • Denial of service: making a system or function unusable for legitimate users.

More from Plume Network

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.