Skip to content
Business logic Audit finding Beginner

Can’t enableCollateral after a disableCollateral

The disableCollateral function revokes roles but fails to set the collateralActive flag to false, so enableCollateral can never be called again because its require checks that the flag is false. This permanently prevents re-enabling a collateral type.

gpersoon Follow

Originally disclosed on Code4rena

Submitted by gpersoon

Impact

The function disableCollateral of OverlayV1Mothership.sol doesn’t set collateralActive\[\_collateral] = false; But it does revoke the roles.

Now enableCollateral can never be used because collateralActive\[\_collateral] ==true and it will never pass the second require. So you can never grant the roles again.

Note: enableCollateral also doesn’t set collateralActive\[\_collateral] = true

Proof of Concept

https://github.com/code-423n4/2021-11-overlay/blob/914bed22f190ebe7088194453bab08c424c3f70c/contracts/mothership/OverlayV1Mothership.sol#L133-L153

function enableCollateral (address _collateral) external onlyGovernor {
    require(collateralExists[_collateral], "OVLV1:!exists");
    require(!collateralActive[_collateral], "OVLV1:!disabled");
    OverlayToken(ovl).grantRole(OverlayToken(ovl).MINTER_ROLE(), _collateral);
    OverlayToken(ovl).grantRole(OverlayToken(ovl).BURNER_ROLE(), _collateral);
}

function disableCollateral (address _collateral) external onlyGovernor {
    require(collateralActive[_collateral], "OVLV1:!enabled");
    OverlayToken(ovl).revokeRole(OverlayToken(ovl).MINTER_ROLE(), _collateral);
    OverlayToken(ovl).revokeRole(OverlayToken(ovl).BURNER_ROLE(), _collateral);
}

Recommended Mitigation Steps

In function enableCollateral() add the following (after the require): collateralActive\[\_collateral] = true;

In function disableCollateral add the following (after the require): collateralActive\[\_collateral] = false;

mikeyrf (Overlay) confirmed

The original report as published on Code4rena, by gpersoon. 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 disableCollateral function does not update the collateralActive state variable to false, and enableCollateral does not set it to true, causing a mismatch between the flag and the actual role state.

Impact

A collateral type that has been disabled can never be enabled again, permanently preventing its use.

What the attacker needed

Governor role

The fix

The functions enableCollateral and disableCollateral should update the collateralActive flag to true and false respectively after their require checks.

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 has a flag that tracks whether a collateral type is active. When disabling, the code removes permissions but forgets to update the flag, so the contract still thinks it is active. Later, trying to enable it again fails because the contract checks the flag and sees it is already active.

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 gpersoon

View all

47 more disclosed reports, best first.

More from Overlay Protocol 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.