Skip to content
Access control Audit finding Beginner

Malformed equate statement

The onlyOwner and onlyManager modifiers in a Solidity contract only evaluate a condition without enforcing it, so any caller can execute functions meant to be restricted to the owner or managers. An attacker could perform privileged actions such as withdrawing funds or changing critical settings.

ChaseTheLight Follow

Originally disclosed on Code4rena

Submitted by ChaseTheLight

Note: This finding was reported via the winning Automated Findings report. It was declared out of scope for the audit, but is being included here for completeness.

Lines of code

8, 13

Vulnerability details

Using the provided modifier onlyOwner for function access control without a proper enforcement mechanism like require or revert is a dire mistake because it fails to restrict access as intended. The modifier merely evaluates a condition (msg.sender == owner) without any action taken based on the result. This means any user, regardless of whether they are the owner, can execute functions that are supposed to be restricted to the owner, potentially leading to unauthorized actions, such as withdrawing funds or altering critical contract settings.

Recommended Mitigation

To fix this, the modifier should enforce the ownership check using a require statement:

modifier onlyOwner() {
  require(msg.sender == owner, "Caller is not the owner");
  _;
}

With this correction, the modifier effectively ensures that only the account designated as owner can access the function. If a non-owner attempts to call the function, the transaction is reverted, maintaining the intended access control and contract integrity.

8:     modifier onlyOwner() { // <= FOUND
9:         msg.sender == owner; // <= FOUND
10:         _;
11:     }
13:     modifier onlyManager() { // <= FOUND
14:         managers[msg.sender] == true; // <= FOUND
15:         _;
16:     }

andresaiello (Curves) confirmed


The original report as published on Code4rena, by ChaseTheLight. 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 modifiers evaluate a boolean expression but do not use require or revert to enforce it, so the check has no effect.

Impact

Any user could execute functions intended for the owner or managers, potentially leading to unauthorised actions such as withdrawing funds or altering critical contract settings.

What the attacker needed

None

The fix

The modifier should enforce the ownership check using a require statement so that non-owners are reverted.

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.

In smart contracts, a modifier is a small piece of code that runs before a function to check something, like whether the caller is the owner. Here the check was written as a statement that does nothing, so the function runs for anyone. This means anyone could call owner-only functions.

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 ChaseTheLight

View all

8 more disclosed reports, best first.

More from Curves

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.