Skip to content
Business logic Audit finding Intermediate

Inconsistant parameter requirements between constructor() and Set() functions in RANGE.sol and Operator.sol .

The constructor functions in RANGE.sol and Operator.sol do not validate parameters that the corresponding setter functions do validate. If the contracts are deployed with improper parameters, they may behave unexpectedly.

hansfriese Follow

Originally disclosed on Code4rena

Submitted by hansfriese, also found by datapunk and itsmeSTYJ

Inconsistant parameter requirements between constructor and Set() functions in RANGE.sol and Operator.sol.

The contracts might work unexpectedly when the params are set improperly using constructor().

Proof of Concept

    File: 2022-08-olympus\src\modules\RANGE.sol
    242:     function setSpreads(uint256 cushionSpread_, uint256 wallSpread_) external permissioned {
    243:         // Confirm spreads are within allowed values
    244:         if (
    245:             wallSpread_ > 10000 ||
    246:             wallSpread_ < 100 ||
    247:             cushionSpread_ > 10000 ||
    248:             cushionSpread_ < 100 ||
    249:             cushionSpread_ > wallSpread_
    250:         ) revert RANGE_InvalidParams();
    251:
    252:         // Set spreads
    253:         _range.wall.spread = wallSpread_;
    254:         _range.cushion.spread = cushionSpread_;
    255:
    256:         emit SpreadsChanged(wallSpread_, cushionSpread_);
    257:     }
    File: 2022-08-olympus\src\modules\RANGE.sol
    263:     function setThresholdFactor(uint256 thresholdFactor_) external permissioned {
    264:         if (thresholdFactor_ > 10000 || thresholdFactor_ < 100) revert RANGE_InvalidParams();
    265:         thresholdFactor = thresholdFactor_;
    266:
    267:         emit ThresholdFactorChanged(thresholdFactor_);
    268:     }
    269:
    File: 2022-08-olympus\src\policies\Operator.sol
    516:     function setCushionFactor(uint32 cushionFactor_) external onlyRole("operator_policy") {
    517:         /// Confirm factor is within allowed values
    518:         if (cushionFactor_ > 10000 || cushionFactor_ < 100) revert Operator_InvalidParams();
    519:
    520:         /// Set factor
    521:         _config.cushionFactor = cushionFactor_;
    522:
    523:         emit CushionFactorChanged(cushionFactor_);
    524:     }
    525:

Tools Used

Solidity Visual Developer of VSCode

Recommended Mitigation Steps

Recommend adding same validation for the parameters between constructor() and Set() functions.

Oighty (Olympus) disagreed with severity and commented:

Agree that the constructor should validate these parameters, but it is only an issue if configured improperly.

0xean (judge) commented:

While I am typically weary of marking input validations as medium severity, I do think in this case it’s warranted as it directly leads to malfunctions at the protocol level and it seems that the sponsors thought it important enough to add the checks elsewhere. Hard call, but will award it at medium severity.


The original report as published on Code4rena, by hansfriese. 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

Likely the constructor functions lack the same input validation checks that are present in the setter functions.

Impact

If the contracts are deployed with improper parameters, they could malfunction at the protocol level.

What the attacker needed

Contract deployed with improper parameters

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.

Smart contracts often have settings that can be changed later by an admin. The code that changes a setting checks that the new value is within a safe range, but the code that sets the initial value when the contract is first deployed does not. If the deployer makes a mistake, the contract could start with bad settings and not work as intended.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by hansfriese

View all

65 more disclosed reports, best first.

More from Olympus DAO contest

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.