Skip to content
Crypto Audit finding Intermediate

Signatures can be replayed in castVoteWithReasonAndParamsBySig() to use up more votes than a user intended

The signature used in castVoteWithReasonAndParamsBySig() lacks a nonce, so the same signature can be replayed multiple times. An attacker can replay a voter's signature to allocate more votes to a candidate than the voter intended.

MiloTruck Follow with KingNFT and HE1M

Originally disclosed on Code4rena

Submitted by MiloTruck, also found by KingNFT and HE1M

In the SecurityCouncilNomineeElectionGovernor and SecurityCouncilMemberElectionGovernor contracts, users can provide a signature to allow someone else to vote on their behalf using the castVoteWithReasonAndParamsBySig() function, which is in Openzeppelin’s GovernorUpgradeable:

GovernorUpgradeable.sol#L480-L495

        address voter = ECDSAUpgradeable.recover(
            _hashTypedDataV4(
                keccak256(
                    abi.encode(
                        EXTENDED_BALLOT_TYPEHASH,
                        proposalId,
                        support,
                        keccak256(bytes(reason)),
                        keccak256(params)
                    )
                )
            ),
            v,
            r,
            s
        );

As seen from above, the signature provided does not include a nonce. This becomes an issue in nominee and member elections, as users can choose not to use all of their votes in a single call, allowing them split their voting power amongst contenders/nominees:

Nominee Election Specification

A single delegate can split their vote across multiple candidates.

Member Election Specification

Additionally, delegates can cast votes for more than one nominee:

  • Split voting. delegates can split their tokens across multiple nominees, with 1 token representing 1 vote.

Due to the lack of a nonce, castVoteWithReasonAndParamsBySig() can be called multiple times with the same signature.

Therefore, if a user provides a signature to use a portion of his votes, an attacker can repeatedly call castVoteWithReasonAndParamsBySig() with the same signature to use up more votes than the user originally intended.

Impact

Due to the lack of signature replay protection in castVoteWithReasonAndParamsBySig(), during nominee or member elections, an attacker can force a voter to use more votes on a contender/nominee than intended by replaying his signature multiple times.

Proof of Concept

Assume that a nominee election is currently ongoing:

  • Bob has 1000 votes, he wants to split his votes between contender A and B:

    • He signs one signature to give 500 votes to contender A.
    • He signs a second signature to allocate 500 votes to contender B.
  • castVoteWithReasonAndParamsBySig() is called to submit Bob’s first signature:

    • This gives contender A 500 votes.
  • After the transaction is executed, Alice sees Bob’s signature in the transaction.

  • As Alice wants contender A to be elected, she calls castVoteWithReasonAndParamsBySig() with Bob’s first signature again:

    • Due to a lack of a nonce, the transaction is executed successfully, giving contender A another 500 votes.
  • Now, when castVoteWithReasonAndParamsBySig() is called with Bob’s second signature, it reverts as all his 1000 votes are already allocated to contender A.

In the scenario above, Alice has managed to allocate all of Bob’s votes to contender A against his will. Note that this can also occur in member elections, where split voting is also allowed.

Recommended Mitigation

Consider adding some form of signature replay protection in the SecurityCouncilNomineeElectionGovernor and SecurityCouncilMemberElectionGovernor contracts.

One way of achieving this is to override the castVoteWithReasonAndParamsBySig() function to include a nonce in the signature, which would protect against signature replay.

DZGoldman (Arbitrum) confirmed and commented via duplicate issue #173:

Confirmed; see here for fix.


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

The signature digest in castVoteWithReasonAndParamsBySig() does not include a nonce, so the same signature remains valid for multiple calls.

Impact

An attacker can force a voter to use more votes on a contender or nominee than intended by replaying the voter's signature multiple times.

What the attacker needed

Nominee or member election ongoing; voter provides a signature for partial votes; attacker can see the signature

The fix

The contracts should add signature replay protection, such as including a nonce in the signed data; the report notes a fix was implemented.

How it was found

  1. Bob signs a signature to give 500 votes to contender A.
  2. Bob signs a second signature to allocate 500 votes to contender B.
  3. castVoteWithReasonAndParamsBySig() is called with Bob's first signature, giving contender A 500 votes.
  4. Alice sees Bob's signature in the transaction and calls castVoteWithReasonAndParamsBySig() with the same signature again.
  5. The transaction succeeds, giving contender A another 500 votes.
  6. When Bob's second signature is used, it reverts because all 1000 votes are already allocated to contender A.

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.

When you sign a message to vote, the system should ensure that signature can only be used once. Here, because the signature does not include a unique number (a nonce), someone else can submit the same signature again and again, each time using more of your voting power.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by MiloTruck

View all

35 more disclosed reports, best first.

More from Arbitrum Security Council Election System

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.