Skip to content
Business logic Audit finding Beginner

Silent override of non global module implementation causes stored state and event log inconsistency

The registerModuleType function silently overrides a non-zero globalImplementation to address(0) for non-global modules, but still emits the original non-zero address in the event. This causes stored state and event logs to disagree, misleading off-chain systems and dependent contracts.

Sharky Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

52137 sc insight silent override of non global module implementation causes stored state and event log inconsistency

Submitted on Aug 8th 2025 at 08:21:45 UTC by @Sharky for Attackathon | Plume Network

Impacts

(See "Impact Details" below for full explanation)

Description

Brief / Intro

When registering a non-global module type in RestrictionsRouter.sol, providing a non-zero globalImplementation address results in a silent state override and inconsistent event logging. This violates contract state integrity, misleads off-chain systems monitoring events, and can cause operational failures in dependent contracts that rely on accurate module registration data.

Vulnerability Details

The registerModuleType function contains logic that forcibly overrides the globalImplementation parameter to address(0) when registering non-global modules (isGlobal = false), even when callers explicitly provide a non-zero address. This occurs at RestrictionsRouter.sol: Lines79-82:

Solidity
if (!isGlobal && globalImplementation != address(0)) {
    // Ensure globalImplementation is 0 if module is per-token
    globalImplementation = address(0); // Silent override
}

This causes two critical inconsistencies:

  • Stored State vs Input Mismatch: The contract stores address(0) in ModuleInfo.globalImplementation despite the caller providing a different address.
  • Event Log Inaccuracy: The function emits ModuleTypeRegistered with the original non-zero address (RestrictionsRouter.sol: Line87):
Solidity
emit ModuleTypeRegistered(typeId, isGlobal, globalImplementation); // Emits original address

Impact Details

This issue can cause multi-system failures:

  1. Off-Chain Monitoring Failure
    Indexers/analytics tools parsing ModuleTypeRegistered events will see non-zero implementations for non-global modules, while the actual stored state is address(0). This creates false assumptions about deployed infrastructure.
  2. Admin Action Corruption
    Admins calling getModuleInfo will receive globalImplementation = address(0) for these modules despite having provided valid addresses, causing confusion and potentially triggering dangerous re-registration attempts.
  3. Dependent Contract Malfunctions
    Contracts using getGlobalModuleAddress() will receive address(0) for these modules, while off-chain systems report non-zero addresses. This breaks synchronization between on-chain and off-chain states.
  4. Data Integrity Exploitation
    Malicious actors could front-run module registrations to create "ghost" module records where event logs show valid implementations but contract storage contains address(0), enabling social engineering attacks against protocol users.

References

Vulnerable Code Sections

  1. Silent Override Logic — RestrictionsRouter.sol (Lines79-82)
Solidity
if (!isGlobal && globalImplementation != address(0)) {
    globalImplementation = address(0); // Silent override
}
  1. Inconsistent Event Emission — RestrictionsRouter.sol (Line87)
Solidity
emit ModuleTypeRegistered(typeId, isGlobal, globalImplementation);

Security References

Link to Proof of Concept

https://gist.github.com/secret/8c5d1a3f7e9b0c2a4b6d5e1f2a3b4c5d

Proof of Concept

Step-by-Step Explanation

{% stepper %} {% step %}

Step 1 — Setup

Admin deploys RestrictionsRouter and initializes with admin privileges. {% endstep %}

{% step %}

Step 2 — Register non-global module with non-zero address

Admin calls:

Solidity
router.registerModuleType(
    keccak256("TEST_MODULE"),
    false,  // isGlobal = false
    0x000000000000000000000000000000000000dEaD // Non-zero address
);

{% endstep %}

{% step %}

Step 3 — Contract execution path

  • Enters override condition (Lines79-82)
  • Silently changes globalImplementation to address(0)
  • Stores address(0) in moduleTypes[typeId].globalImplementation
  • Emits event with original non-zero address (Line87) {% endstep %}

{% step %}

Step 4 — Divergence observed

  • getModuleInfo() returns address(0)
  • Event logs show 0x0000...dEaD
  • getGlobalModuleAddress() returns address(0) {% endstep %} {% endstepper %}

Test Contract (Foundry)

Solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import "forge-std/Test.sol";
import "../src/RestrictionsRouter.sol";

contract RestrictionsRouterTest is Test {
    RestrictionsRouter public router;
    address public admin = makeAddr("admin");
    address public nonZeroAddress = address(0xDeaD);
    bytes32 public constant TEST_TYPE = keccak256("TEST_MODULE");

    event ModuleTypeRegistered(
        bytes32 indexed typeId,
        bool isGlobal,
        address globalImplementation
    );

    function setUp() public {
        vm.startPrank(admin);
        router = new RestrictionsRouter();
        router.initialize(admin);
        vm.stopPrank();
    }

    function test_SilentOverrideVulnerability() public {
        vm.startPrank(admin);
        
        // Register non-global module with non-zero address
        router.registerModuleType(TEST_TYPE, false, nonZeroAddress);
        
        vm.stopPrank();

        // Verify storage shows address(0)
        (, address storedImplementation, ) = router.moduleTypes(TEST_TYPE);
        assertEq(
            storedImplementation,
            address(0),
            "Storage should show address(0)"
        );

        // Verify getter functions return address(0)
        assertEq(
            router.getGlobalModuleAddress(TEST_TYPE),
            address(0),
            "getGlobalModuleAddress should return address(0)"
        );
        
        IRestrictionsRouter.ModuleInfo memory info = router.getModuleInfo(TEST_TYPE);
        assertEq(
            info.globalImplementation,
            address(0),
            "getModuleInfo should return address(0)"
        );
    }

    function test_EventLogInconsistency() public {
        vm.startPrank(admin);
        
        // Expect event with original non-zero address
        vm.expectEmit(true, true, true, true);
        emit ModuleTypeRegistered(TEST_TYPE, false, nonZeroAddress);
        
        router.registerModuleType(TEST_TYPE, false, nonZeroAddress);
        
        vm.stopPrank();
    }
}

Reproduction Steps

{% stepper %} {% step %}

Step 1 — Initialize Foundry project

Bash
forge init --force vuln-test
cd vuln-test
forge install openzeppelin/openzeppelin-contracts-upgradeable

{% endstep %}

{% step %}

Step 2 — Create interface file

Bash
mkdir src
echo '// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

interface IRestrictionsRouter {
    function getGlobalModuleAddress(bytes32 typeId) external view returns (address);
}' > src/IRestrictionsRouter.sol

{% endstep %}

{% step %}

Step 3 — Add vulnerable implementation

Create src/RestrictionsRouter.sol with the provided vulnerable code (the target file referenced in the report). {% endstep %}

{% step %}

Step 4 — Add test file

Bash
mkdir test
echo '<test-contract-code-above>' > test/RestrictionsRouterTest.sol

Replace <test-contract-code-above> with the full test contract provided in this report. {% endstep %}

{% step %}

Step 5 — Run the test

Bash
forge test -vvv --match-test test_SilentOverrideVulnerability

{% endstep %} {% endstepper %}

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

The code explicitly sets globalImplementation to address(0) when isGlobal is false, but the event emission uses the original parameter value instead of the updated variable.

Impact

Off-chain indexers and dependent contracts may see inconsistent data, leading to false assumptions, operational failures, and potential social engineering attacks, though the report does not demonstrate direct loss of funds.

What the attacker needed

Admin privileges to call registerModuleType

The fix

The function should either revert when a non-zero globalImplementation is provided for a non-global module, or emit the event using the updated (zero) value to keep state and logs consistent.

How it was found

  1. Admin deploys RestrictionsRouter and initializes with admin privileges.
  2. Admin calls registerModuleType with isGlobal set to false and a non-zero globalImplementation address.
  3. The contract enters the override condition, sets globalImplementation to address(0), stores address(0), but emits the event with the original non-zero address.
  4. Observe that getModuleInfo and getGlobalModuleAddress return address(0) while event logs show the non-zero address.

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 function is supposed to record the address you give it, but for one type of module it quietly replaces your address with zero. However, the event it announces still shows your original address, so anyone watching the event thinks the address was saved when it was not. This mismatch can confuse systems that rely on the event to know what is deployed.

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 Sharky

View all

2 more disclosed reports, best first.

More from Plume Network

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.