Skip to content
Race condition Audit finding Intermediate

Multisig can execute the same proposal repeatedly

The multisig contract resets the vote tally after executing a proposal, so if enough signers vote in the same block, the same external call can be executed more than once. An attacker who controls or colludes with signers could cause duplicate execution, potentially leading to loss of funds.

pcarranzav Follow with immeas

Originally disclosed on Code4rena

Submitted by pcarranzav, also found by immeas

Lines of code

https://github.com/code-423n4/2023-07-axelar/blob/aeabaa7086eb35e8614e58b42f0d50728e023881/contracts/cgp/auth/MultisigBase.sol#L44-L77 https://github.com/code-423n4/2023-07-axelar/blob/9f642fe854eb11ad9f18fe028e5a8353c258e926/contracts/cgp/governance/Multisig.sol#L30-L36

Impact

In MultisigBase and its use in Multisig, the onlySigners modifier will reset the vote count and execute the external call when the vote threshold is met. This means that if many signers send their transactions during the same block, the votes that are executed after the call execution will start a new tally, potentially re-executing the same external call if the votes are enough to meet the threshold again. This is probably low-likelihood for multisigs where the threshold is high relative to the number of signers, but could be quite likely if the threshold is relatively low.

In the general case, users of Multisig may not be aware of this behavior and have no good way of avoiding this other than off-chain coordination. An accidental double execution could easily lead to a loss of funds.

This doesn’t affect AxelarServiceGovernance because of the additional requirement of an interchain message, but it might still leave behind unwanted votes; which reduces the overall security of the governance mechanism.

Proof of Concept

Arguably, this unit test is a PoC in itself.

But the following example might be a better illustration. The following test passes (when based on the explanation above, it shouldn’t), and is a modification of the above test but using threshold 1:

    it('executes the same call twice, accidentally', async () => {
        const targetInterface = new Interface(['function callTarget() external']);
        const calldata = targetInterface.encodeFunctionData('callTarget');
        const nativeValue = 1000;

        // Set the threshold to 1
        await multisig.connect(signer1).rotateSigners(accounts, 1)
        await multisig.connect(signer2).rotateSigners(accounts, 1)

        // Say these two signers send their vote at the same time:
        await expect(multisig.connect(signer1).execute(targetContract.address, calldata, nativeValue, { value: nativeValue })).to.emit(
            targetContract,
            'TargetCalled',
        );
        await expect(multisig.connect(signer2).execute(targetContract.address, calldata, nativeValue, { value: nativeValue })).to.emit(
            targetContract,
            'TargetCalled',
        );
        // The call was executed twice!
    });

Recommended Mitigation Steps

Consider adding an incrementing nonce to each topic, so that repeating the call requires using a new nonce. If the intent is to allow arbitrary-order execution, then using a random or unique topic ID in addition to the topic hash could be used instead (like you did with the commandId in AxelarGateway).

Assessed type

Access Control

berndartmueller (judge) commented:

Referencing the comment in Issue #333:

it is assumed that the signers are trusted

Isn’t the purpose of a multisig not to trust individual signers or even N-1 signers, but only trust when N of them sign?

I would argue that a multisig meets it’s purpose if and only if the configured threshold is the absolute minimum number of signers that must be compromised to execute a proposal maliciously. The fact that overvotes can leave a spurious proposal with N-1 votes being sufficient for execution breaks one of the core assumptions when using a multisig.

(I’d also note #116 and #245 could be considered duplicates. The impact descriptions are slightly different but the underlying issue is the same)

After careful consideration, I’d like to change my stance on the validity and severity of the outlined issue of overcounting proposal votes. Let me elaborate on my reasoning:

First of all, there’s an underlying trust assumption on the used multisig. All signers, initially chosen by the deployer of the multisig contract (MultisigBase or the derived Multisig contract), are trusted. Rotating signers, i.e., adding/removing signers and changing the threshold (quorum), is also voted on by the existing signers. Thus, assuming the new set of signers (and threshold) is reasonable and trustworthy.

However, a multisig is purposefully used to ensure proposals only get executed once the quorum of the signers is reached.

Given the outlined issue in the submission, overvoting by signers can occur. For example, if the signing transactions get executed within the same block. Moreover, it can be assumed that the Multisig.execute function is intended to be executed multiple times with the same arguments (calldata). For instance, to repeatedly perform certain token transfers on a regular basis. Adding some kind of “nonce” or additional data to the arguments to achieve a new and unique proposal (specifically, a unique topic) to be voted on is not reasonable as the Multisig.execute function does not provide such parameters. Contrary to OpenZeppelin’s Governor contract, which allows specifying a (unique) proposal description (see Governor.sol#L268-L289). Additionally, in OZ’s Governor contract, casting votes is only possible on pending proposals and reverts otherwise.

I consider “overvoting” as a bug worth mitigating as it leaves proposals in an inconsistent state, leading to unpredictable outcomes.

Given C4’s judging criteria and severity categorization

2 — Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted or leak value with a hypothetical attack path with stated assumptions, but external requirements.

I’m considering this submission valid and the chosen Medium severity to be appropriate.

deanamiel (Axelar) disputed and commented via duplicate issue #333:

Perhaps for a generic multi-sig in which signers are not trusted this would be true. However, for the multi-sig that we have designed for our governance purposes, signers will be part of Axelar governance and therefore, will be trusted. It is the signer’s responsibility to ensure that a proposal exists before voting on it. We still wish to dispute validity.

berndartmueller (judge) commented via duplicate issue #333:

@deanamiel - I understand your point. Nevertheless, overvoting is possible (even if not done with malicious intent), and it can be fixed to prevent any future, while unlikely, issue.

I acknowledge that the sponsor disagrees with the validity. The validity and severity are certainly close to being invalid and QA, respectively. Still, I lean more towards being valid and Medium severity.

milapsheth (Axelar) commented:

This was an intentional design decision. It’s designed for internal use and will have low usage frequency with a coordinated participation such that this issue is Low impact, but we acknowledge the concern for general use.


The original report as published on Code4rena, by pcarranzav. 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 contract clears the vote count after executing a proposal but does not mark the proposal as executed, so later votes in the same block can start a fresh tally and trigger execution again.

Impact

An accidental double execution could easily lead to a loss of funds; the report notes this is low-likelihood for high-threshold multisigs but quite likely if the threshold is relatively low.

What the attacker needed

Multiple signers; transactions in the same block; low threshold relative to signer count

The fix

Add an incrementing nonce to each topic so that repeating the call requires a new nonce, or use a unique topic ID in addition to the topic hash.

How it was found

  1. Set the multisig threshold to 1.
  2. Have two signers submit the same proposal in the same block.
  3. Observe that the target call is executed twice.

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 multisig is a wallet that requires several people to approve a transaction before it happens. This report found that if those approvals arrive very close together, the wallet can accidentally send the same transaction twice. That could mean money is sent twice when it should have been sent once.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

More by pcarranzav

View all

1 more disclosed report, best first.

More from Axelar Network

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.