Skip to content
Access control Audit finding Intermediate

LOW-59 fix is incomplete: CfdEngine and CfdEngineAdmin still allow renounceOwnership(), which makes degraded mode permanent

Two engine contracts still inherit the standard ownership-renounce function, unlike three sibling contracts that were patched to block it. If the engine owner renounces, the only function that clears degraded mode becomes unreachable, so the market can never accept new risk again even after the pool is recapitalised.

Web3Vinay Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#97610 [SC-Low] LOW-59 fix is incomplete: CfdEngine and CfdEngineAdmin still allow renounceOwnership(), which makes degraded mode permanent

Submitted on Nov 2nd 2026 at 14:20:55 UTC by @Web3Vinay for Audit Competition | Plether

Description

Brief/Intro

After Cecuro LOW-59 ("Owner can leave emergency recovery ownerless"), the team made renounceOwnership() revert on HousePool, OrderRouterAdmin and EmergencyPauseCoordinator. Their stated reason: "governance must retain emergency recovery authority". CfdEngine (via CfdTreasury) and CfdEngineAdmin were not changed. The LOW-59 remediation said to override it "in every governance-bearing perps contract". CfdEngine.clearDegradedMode() is the only code path that sets degradedMode = false, and it is onlyOwner. If the engine owner renounces, degraded mode can never be cleared, even after the pool is recapitalized and solvent.

Vulnerability Details

The fix exists in three contracts:

Solidity
// HousePool.sol:265 (same in OrderRouterAdmin.sol:125, EmergencyPauseCoordinator.sol:102)
function renounceOwnership() public view override onlyOwner {
    revert OwnableInvalidOwner(address(0));
}

The engine side has no override:

Solidity
// CfdTreasury.sol:10
@> abstract contract CfdTreasury is ICfdEngineTypes, Ownable2Step {   // no renounceOwnership override
// CfdEngineAdmin.sol:17
@> contract CfdEngineAdmin is Ownable2Step {                          // no renounceOwnership override

degradedMode = true is set at CfdEngine.sol:1366. The only reset is:

Solidity
// CfdEngine.sol:658-667
@> function clearDegradedMode() external onlyOwner {
       if (!degradedMode) revert CfdEngine__NotDegraded();
       if (_availableCashForFreshPoolPayouts() < _maxLiability()) revert CfdEngine__StillInsolvent();
       degradedMode = false;
       emit DegradedModeCleared();
   }

degradedMode = false appears nowhere else in packages/perps/src. After engine.renounceOwnership(), owner() == address(0), so clearDegradedMode() reverts for every caller. engineAdmin.renounceOwnership() also removes proposeRiskConfig, and the engine cannot rotate its admin (setDependencies is one-time, CfdEngine.sol:346-381). The docs describe the owner as the recovery authority: SECURITY.md:246, SECURITY.md:1504-1511 (runbook step 5: "Clear degraded mode only after raw solvency is restored"), EMERGENCY_RESPONSE_GUIDE.md:87 ("Governance owns recovery").

Difference from LOW-59: LOW-59 named only OrderRouterAdmin, HousePool, EmergencyPauseCoordinator. This report covers the engine contracts the fix missed, and the engine-specific consequence (degraded mode permanent).

Impact Details

No funds are lost. Closes, liquidations and free-margin withdrawals still work. The market can never accept new risk again: every open fails with DEGRADED_MODE even though the pool is solvent. The engine cannot be replaced (one-time wiring, non-upgradeable), so recovery needs a full redeploy. Needs an owner mistake or key compromise, the same precondition the team accepted for LOW-59. MarginClearinghouse.sol:30 has the same inheritance; renouncing there permanently disables rescueToken (MarginClearinghouse.sol:324).

Mitigation

Diff
 // CfdTreasury.sol, CfdEngineAdmin.sol, MarginClearinghouse.sol
+    function renounceOwnership() public view override onlyOwner {
+        revert OwnableInvalidOwner(address(0));
+    }

References

  • packages/perps/src/CfdTreasury.sol:10 and CfdEngine.sol:46: Ownable2Step base, no override
  • packages/perps/src/CfdEngineAdmin.sol:17: no override
  • packages/perps/src/CfdEngine.sol:658-667: clearDegradedMode, sole reset path
  • packages/perps/src/CfdEngine.sol:1366: degraded latch
  • packages/perps/src/CfdEngine.sol:346-381: one-time setDependencies
  • packages/perps/src/MarginClearinghouse.sol:30,324: same pattern, rescueToken
  • HousePool.sol:265, OrderRouterAdmin.sol:125, EmergencyPauseCoordinator.sol:102: LOW-59 fix pattern

Proof of Concept

Proof of Concept

  • The LOW-59 fix at a82d4fe covers HousePool.sol:265, OrderRouterAdmin.sol:125 and EmergencyPauseCoordinator.sol:102 only. The LOW-59 remediation asked for the override "in every governance-bearing perps contract". This report shows that fix is incomplete for the engine contracts.

Save as packages/perps/test/insights_privileged/RenounceEngineOwnership.t.sol and run forge test --match-path test/insights_privileged/RenounceEngineOwnership.t.sol -vv from packages/perps. It reuses the repo's BasePerpTest harness and the risk params of the existing degraded-mode fixture.

Solidity
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;

import {BasePerpTest} from "../perps/BasePerpTest.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {CfdEnginePlanTypes} from "@plether/perps/CfdEnginePlanTypes.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {ICfdEngineAdminHost} from "@plether/perps/interfaces/ICfdEngineAdminHost.sol";
import {ICfdEngineTypes} from "@plether/perps/interfaces/ICfdEngineTypes.sol";

contract RenounceEngineOwnershipInsight is BasePerpTest {

    function _riskParams() internal pure override returns (CfdTypes.RiskParams memory) {
        return CfdTypes.RiskParams({
            vpiFactor: 0, maxSkewRatio: 1e18, maintMarginBps: 100, initMarginBps: 150, fadMarginBps: 300,
            baseCarryBps: 500, minBountyAssets: 5e6, bountyBps: 10, keeperShareBps: 5000, protocolShareBps: 0
        });
    }

    function test_EngineRenounceLeavesDegradedModeUnrecoverable() public {
        address longT = address(0xB011);
        address shortT = address(0xBEA2);
        address newT = address(0xCAFE);
        _fundTrader(longT, 100_000e6);
        _fundTrader(shortT, 100_000e6);
        _fundTrader(newT, 100_000e6);

        // 1. Profitable close reveals insolvency -> degraded mode latches.
        _open(shortT, CfdTypes.Side.SHORT, 999_000e18, 50_000e6, 1e8);
        _open(longT, CfdTypes.Side.LONG, 500_000e18, 50_000e6, 1e8);
        _close(longT, CfdTypes.Side.LONG, 500_000e18, 20_000_000);
        assertTrue(engine.degradedMode(), "setup: degraded");

        // 2. Governance recapitalizes; solvency restored.
        settlementToken.mint(address(this), 500_000e6);
        settlementToken.approve(address(engine), 500_000e6);
        engine.recapitalizePool(500_000e6);
        vm.prank(address(juniorVault));
        pool.reconcile();
        // Control: with an owner, recovery succeeds right now.
        uint256 snap = vm.snapshotState();
        engine.clearDegradedMode();
        assertFalse(engine.degradedMode(), "control: owner can recover");
        vm.revertToState(snap);
        assertTrue(engine.degradedMode());

        // 3. LOW-59 fix: these refuse renunciation ...
        vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableInvalidOwner.selector, address(0)));
        pool.renounceOwnership();
        vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableInvalidOwner.selector, address(0)));
        routerAdmin.renounceOwnership();
        // ... but the engine and its admin still accept it.
        engine.renounceOwnership();
        engineAdmin.renounceOwnership();
        assertEq(engine.owner(), address(0));
        assertEq(engineAdmin.owner(), address(0));

        // 4. The sole degraded-mode exit is unreachable.
        vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableUnauthorizedAccount.selector, address(this)));
        engine.clearDegradedMode();
        ICfdEngineAdminHost.EngineRiskConfig memory stricter = _engineRiskConfig();
        vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableUnauthorizedAccount.selector, address(this)));
        engineAdmin.proposeRiskConfig(stricter);

        // 5. New opens stay rejected although the pool is solvent.
        CfdTypes.Order memory o = CfdTypes.Order({
            account: newT, sizeDelta: 10_000e18, marginDelta: 1000e6, targetPrice: 1e8,
            commitTime: uint64(block.timestamp), commitBlock: uint64(block.number), orderId: 0,
            side: CfdTypes.Side.LONG, isClose: false
        });
        uint256 depth = pool.totalAssets();
        vm.expectRevert(
            abi.encodeWithSelector(
                ICfdEngineTypes.CfdEngine__TypedOrderFailure.selector,
                CfdEnginePlanTypes.ExecutionFailurePolicyCategory.ProtocolStateInvalidated,
                uint8(CfdEnginePlanTypes.OpenRevertCode.DEGRADED_MODE),
                false
            )
        );
        vm.prank(address(router));
        engine.processOrderTyped(o, 1e8, depth, uint64(block.timestamp));
        assertTrue(engine.degradedMode(), "degraded mode is now permanent");
    }
}

Result (actually run, forge test --match-path test/insights_privileged/RenounceEngineOwnership.t.sol -vv):

Ran 1 test for test/insights_privileged/RenounceEngineOwnership.t.sol:RenounceEngineOwnershipInsight
[PASS] test_EngineRenounceLeavesDegradedModeUnrecoverable() (gas: 2264672)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 11.66ms (3.79ms CPU time)

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

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 earlier fix that blocked renouncing ownership was applied to only three contracts and missed the engine contracts, which inherit the same ownership base without an override.

Impact

No funds are lost and closes, liquidations and withdrawals still work, but the market can never accept new risk again and the engine cannot be replaced, so recovery needs a full redeploy; this requires an owner mistake or key compromise.

What the attacker needed

Engine owner renounces ownership; or owner key is compromised

The fix

The same renounceOwnership override that reverts should be added to CfdTreasury, CfdEngineAdmin and MarginClearinghouse.

How it was found

  1. Open positions so that a profitable close reveals insolvency and degraded mode latches.
  2. Recapitalise the pool and reconcile so solvency is restored, and confirm the owner can clear degraded mode.
  3. Call renounceOwnership on the pool and router admin, which revert, then on the engine and engine admin, which succeed.
  4. Attempt clearDegradedMode and proposeRiskConfig, both of which revert because the owner is now the zero address.
  5. Attempt a new open and observe it is rejected with DEGRADED_MODE although the pool is solvent.

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 can have an 'owner' account with special powers. One standard power is to give up ownership permanently, leaving nobody in charge. Here, giving up ownership on the trading engine would lock a safety switch called 'degraded mode' in the on position, so the market could never take new trades again.

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 Web3Vinay

View all

36 more disclosed reports, best first.

More from Plether

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.