Skip to content
Access control Audit finding Beginner

Operators are unable to perform any actions due to incorrect modifier implementation

The onlyOperator modifier in the LiquidRon contract uses incorrect boolean logic, causing it to always revert for any caller other than the owner, even if the caller is a valid operator. As a result, operators are completely unable to perform their intended actions such as harvest, delegateAmount, and harvestAndDelegateRewards.

zanderbyte Follow with 056Security, 0rpse and 48 others

Originally disclosed on Code4rena

Submitted by zanderbyte, also found by 056Security, 0rpse, 0x0107, 0x0bserver, 0x0dd, 0x11singh99, 0x23r0, 0xAadi, 0xAkira, 0xAlipede, 0xAsen, 0xastronatey, 0xauditagent, 0xaudron, 0xAura, 0xfocusNode, 0xhuh2005, 0xiehnnkta, 0xLeveler, 0xMosh, 0xmujahid002, 0xnolo, 0xodus, 0xRajkumar, 0xrex, 0xterrah, 0xvd, 13u9, 4rdiii, Aamir, aariiif, Adotsam, Afriauditor, Agontuk, air_0x, Albort, anonymousjoe, arman, aua_oo7, AvantGard, axelot, backboard9654, Banditx0x, bani, Bauchibred, Bbash, Bluedragon101, brevis, BRONZEDISC, BroRUok, Bz, ccvascocc, ChainSentry, Cli7max, CrazyMoose, crmx_lom, csanuragjain, cylzxje, CyXq, d4r3d3v1l, Daniel_eth, Daniel526, dd0x7e8, debo, Dec3mber, DemoreX, den-sosnowsky, dexcripter, DharkArtz, DoD4uFN, dreamcoder, edwardmintel, ElCid, elolpuer, eLSeR17, EPSec, erictee, eternal1328, ewwrekt, Falendar, federodes, Flare, francoHacker, fromeo_016, gesha17, gregom, gxh191, HardlyDifficult, harry_cryptodev, HChang26, holydevoti0n, honey-k12, hrmneffdii, hyuunn, IceBear, ilchovski, importDev, Incogknito, inh3l, interestingTimes, itsabinashb, JakeFromStateFarm, JCN, jesusrod15, jkk812812, Josh4324, ka14ar, Kalogerone, Kek, King_9aimon, klau5, KupiaSec, kutugu, Lamsy, levi_104, linemi, LLakterian, LonelyWolfDemon, Maglov, mahdifa, Mahi_Vasisth, marwen, miaowu, mtberi, muellerberndt, MukulKolpe, muncentu, mxteem, N0nce, newspacexyz, NexusAudits, nnez, noured23, oakcobalt, octeezy, ok567, Olugbenga, oxelmiguel12, p_crypt0, peanuts, persik228, pfapostol, phoenixV110, Prestige, pulse, PumpkingWok, Punith, queen, RaOne, rare_one, rbserver, Rhaydden, Riceee, rishab, robertauditor, Rolando, rudhra, Ryonen, sabanaku77, safie, sajeevan_58356, Samueltroydomi, seerether, serial-coder, Shahil_Hussain, shaka, Shinobi, Shipkata494, silver_eth, sl1, SmartAuditPro, sohrabhind, Sparrow, spuriousdragon, stuart_the_minion, t0x1c, tachida2k, Tadev, Tamer, teoslaf, Tiannah, Tigerfrake, Timeless, tonitonitoni, Topmark, tpiliposian, Trepid, typicalHuman, udo, udogodwin, Udsen, unique, unnamed, vahdrak1, verboten_viking, victortheoracle, vladi319, vulkan_xx, wellbyt3, Xcrypt, XDZIBECX, YouCrossTheLineAlfie, Z-bra, zraxx, zubyoz, and ZZhelev

LiquidRon.sol#L91

Finding Description and Impact

The onlyOperator modifier in LiquidRon contract is intended to restrict access to specific functions to either the owner or operator. Functions like harvest, delegateAmount, and harvestAndDelegateRewards rely on this modifier for access control.

However, the modifier implementation is incorrect and will always revert when called by any address other than the owner, even if the caller is a valid operator. As a result, operators are completely unable to perform any of their intended actions.

As we can see, if msg.sender is not the owner, the first condition evaluates to true, triggering a revert. Even if we ignore the first condition, when an operator calls a function using this modifier, operator[msg.sender] evaluates to true, causing the revert to be triggered again.

    /// @dev Modifier to restrict access of a function to an operator or owner
    modifier onlyOperator() {
        if (msg.sender != owner() || operator[msg.sender]) revert ErrInvalidOperator();
        _;
    }

Proof of Concept

Paste the following test in LquidRon.operator.t.sol:

    function test_wronModifierIImplementation() public {
        address operator = makeAddr("operator");
        liquidRon.updateOperator(operator, true);

        assertTrue(liquidRon.operator(operator));

        vm.startPrank(operator);
        vm.expectRevert(LiquidRon.ErrInvalidOperator.selector);
        liquidRon.harvest(1, consensusAddrs);
    }

Recommended Mitigation Steps

The modifier should revert only if the msg.sender is neither the owner nor an operator:

    /// @dev Modifier to restrict access of a function to an operator or owner
    modifier onlyOperator() {
-       if (msg.sender != owner() || operator[msg.sender]) revert ErrInvalidOperator();
+       if (msg.sender != owner() && !operator[msg.sender]) revert ErrInvalidOperator();
        _;
    }

Owl (Liquid Ron) confirmed and commented:

I agree that the finding is valid, I simply wonder if the severity is justified.

The modifier doesn’t permit for anyone to call the operator functions, which for me is a high severity. With this reasoning, the finding could be of medium severity as workarounds external to the contract are possible (owner is a contract with actual correct usage of the operator finding if such code was live).

0xsomeone (judge) decreased severity to Medium and commented:

The submission details an incorrect code implementation that effectively increases the level of access control for functions that utilize the onlyOperator modifier as operators are not able to access those functions and the owner is the only one capable of invoking them.

I believe that such a finding does not result in a material vulnerability and instead falls under the “self-evident code mistake” clause of the relevant Supreme Court verdicts. In such instances, mistakes in code that are clear yet do not result in a significant vulnerability would be considered medium severity and I consider this approach to apply here, thus downgrading the issue to medium severity.

Liquid Ron mitigated:

Bad operator modifer.

Status: Mitigation confirmed. Full details in reports from Aamir, 0rpse, and ilchovski.


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

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 modifier uses OR instead of AND with a negation, so the condition for reverting is true for any non-owner, and also true for operators, causing an unconditional revert for all callers except the owner.

Impact

Operators cannot perform any of their intended actions, effectively locking them out and leaving the owner as the only address able to call functions like harvest, delegateAmount, and harvestAndDelegateRewards.

What the attacker needed

Operator role assigned; caller is an operator

The fix

The modifier should be changed to revert only if the caller is neither the owner nor an operator, using AND with a negation.

How it was found

  1. Deploy the LiquidRon contract and set an operator address.
  2. Call the harvest function from the operator address.
  3. Observe that the transaction reverts with ErrInvalidOperator.

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 modifier is a piece of code that runs before a function to check conditions, like a security guard. Here, the guard was supposed to let in either the owner or an operator, but due to a logic mistake, it only lets in the owner and turns away everyone else, including operators. This means the people meant to help run the contract cannot do their jobs.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by zanderbyte

View all

4 more disclosed reports, best first.

More from Liquid Ron

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.