Skip to content
Smart contracts Audit finding Intermediate

Potential Signature Validation Bypass

The signature verification function returns true when given empty arrays of signers and signatures because it does not check that the arrays are non-empty. An attacker could bypass signature validation if this function were used, but the report notes it is not currently used in the protocol.

EricTee Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

26286 - [SC - Insight] Potential Signature Validation Bypass

Submitted on Nov 30th 2023 at 09:33:15 UTC by @EricTee for Boost | DeGate

Report ID: #26286

Report type: Smart Contract

Report severity: Insight

Target: https://github.com/degatedev/protocols/blob/degate\\_mainnet/packages/loopring\\_v3/contracts/lib/SignatureUtil.sol#L32-L51

Impacts:

  • Signature Validation Bypass

Description

Bug Description

In https://github.com/degatedev/protocols/blob/degate_mainnet/packages/loopring_v3/contracts/lib/SignatureUtil.sol#L32-L51:

    function verifySignatures(
        bytes32          signHash,
        address[] memory signers,
        bytes[]   memory signatures
        )
        internal
        view
        returns (bool)
    {
        require(signers.length == signatures.length, "BAD_SIGNATURE_DATA");
        address lastSigner;
        for (uint i = 0; i < signers.length; i++) {
            require(signers[i] > lastSigner, "INVALID_SIGNERS_ORDER");
            lastSigner = signers[i];
            if (!verifySignature(signHash, signers[i], signatures[i])) {
                return false;
            }
        }
        return true;
    }

There is a potential signature validation bypass scenario happens in the above code, since there is no check that require(signers.length != 0), if an attacker passes in empty array of signers and signatures values, he can bypass the for loop. As a result, the function will directly return true. Though this function is not used anyway in the protocol yet, but I think the awareness should be raised to the protocol team in case this function is implemented in the future.

Impact

Potential Signature Validation Bypass

Risk Breakdown

Difficulty to Exploit: Easy Weakness: Signature Validation Bypass CVSS2 Score: NA

Recommendation

Consider adding the check require(signers.length != 0, "BAD_SIGNATURE_DATA");:

Diff
    function verifySignatures(
        bytes32          signHash,
        address[] memory signers,
        bytes[]   memory signatures
        )
        internal
        view
        returns (bool)
    {
++      require(signers.length != 0, "BAD_SIGNATURE_DATA");
        require(signers.length == signatures.length, "BAD_SIGNATURE_DATA");
        address lastSigner;
        for (uint i = 0; i < signers.length; i++) {
            require(signers[i] > lastSigner, "INVALID_SIGNERS_ORDER");
            lastSigner = signers[i];
            if (!verifySignature(signHash, signers[i], signatures[i])) {
                return false;
            }
        }
        return true;
    }

References

NA

Proof of concept

NA

The original report as published on Immunefi, by EricTee. 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 function lacks a check that the signers array is non-empty, so an empty array causes the loop to be skipped and the function to return true.

Impact

Potential signature validation bypass, but the function is not used in the protocol yet, so no current impact.

What the attacker needed

Function must be used in the protocol

The fix

The function should be fixed by adding a check that the signers array is not empty.

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 signature check is meant to prove that the right people approved an action. This function loops over a list of signers, but if the list is empty the loop never runs and the function says 'yes' anyway. That means an empty list could be treated as a valid approval, though the report says this function is not used yet.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by EricTee

View all

2 more disclosed reports, best first.

More from DeGate

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.