Bad implementation of executeTransaction functi
The multisig wallet's executeTransaction function can be called by anyone after a failed execution attempt, because the low-level call does not revert the whole transaction and the executed flag is set to false. An attacker could then trigger the timelock upgrade at an unintended time, potentially changing the proxy's implementation logic within the same block.
- Disclosed after under an hour
26275 - [SC - Insight] Bad implementation of executeTransaction functi...
Submitted on Nov 30th 2023 at 02:13:44 UTC by @v0id for Boost | DeGate
Report ID: #26275
Report type: Smart Contract
Report severity: Insight
Target: https://etherscan.io/address/0x2028834B2c0A36A918c10937EeA71BE4f932da52#code
Impacts:
- Block stuffing for profit
Description
DeGate designs its proxy upgrade implementation by the following rule : a multisig proposal will first get Initiated to to store the upgrade implementation data in a timelock contract . the timelock contract meets a special requirement where it can only upgrade contract and change the proxy address when it has been 45 days between the day that the request has been initiiated and it will get executed . another multisig proposal would then get involved to call timelock whenever it was possible (after 45 days) to let the upgrade process happen. while taking a look at multisig smart contract we can understand that : for a proposal to get executed successfully it has to go through some situations . an owner has to first call submitTransaction function which would get the destination address and the data that it has to attach to the transaction from the caller , and then it would call confirmTransaction function internally , at this function the owner/caller would get added to the array of owners that have signed the transaction to get executed . and in the end the executeTransaction function would get called internally . the executeTransaction function is where the transaction would get executed , but to execute that transaction and the tx.executed to get successful set as true , two conditions have to happen , first number of owners who have signed the transaction has to meet the prescribed amount , and second the transaction call to the destination address has to get successfully executed or else the tx.executed would get a false value .
the issue here is that the contract would either let another person execute their signed transaction or it fails to implement an Appropriate Environment where the someone would not be able to execute their transaction .
let say the multisig requires 4 signers to sign a proposal .those 4 may decide to call the confirmTransaction function before the timelock's settled time , what will happen here is that at 4th call after the first condition would become pass and tx.destination would get called which will get reverted because it has noy yet meet the mentioned time . and because contract uses low level call method .call , the whole execution would not get reverted and so in the next line : tx.executed = false and after that anyone can call executeTransaction . or in Low probability of occurrence situations 4th call would get executed after timelock's settled time but this time the call it self would get reverted for some reasons ... .
now lets say what is the impact of letting anyone call a function that will change address of our proxy's implementation . in defi proxies play an important role , they will have one storage but multiple contract . that means that the storage will always be the same but its only the logic and source code of the proxy that will get changed by changing the address of where it will delegate call its calls to . having the above condition its possible for a maliciuse user to call a function with logic of smart contract A and store/change/delete the storage C value and then call the same function or another one with logic of smart contract B and store/change/delete value storage C value , with same block.timestamp .
for example depositing and withdrawing funds in current implementation looks like :
deposit> wexchange proxy > exchange implementation > depositcontract proxy > deposit contract implementation
^^^^^^^^^^^^
withdraw > exchange proxy > exchange implementation > depositcontract proxy > deposit contract implementation
now if someone change logic of depositcontract implementation at ^^^^^^^^^^^^ they will get a different result , that idea may not cause a huge loss of funds by it self but when we can do all of them in one transaction we can probably use flashloans . we also have block.timestamp that is set to same value before and after the upgrade . this is important because in many smart contracts its not possible to take a profit by eg depositing your finds in and withdrawing them out in one block .
the above scenario is just one example to help to understand the issue. and because of that there is no vision of future implementation 's source code or the current one in this contest we cant 100% say how this can happen or even this can happen or not . we have to also mention that the mentioned issue is being fixed in original gnosis multisig wallets by adding a Stealth Safe Guard (https://mirror.xyz/yearn-finance-engineering.eth/9uInM\\_sCrogPBs5qkFSNF6qe-32-0XLN5bty5wKLVqU)
to fix the issue , first of all executetransaction function can contain a requirement where it will only accept calls from owners/admins/executors and/or revert a confirmation transaction if it got reverted at executetransaction call .
because of some Low probability of occurrence conditions that this vulnerability requires we somehow agree if project wants to change the severity .
Proof of concept
// SPDX-License-Identifier: MIT
pragma solidity ^0.4.4;
contract MultiSigWalletWithDailyLimit {
function callExecuteTransaction(uint transactionId) public {
this.executeTransaction(transactionId);
}
}
contract MyInteractingContract {
MultiSigWalletWithDailyLimit public multiSigWallet;
constructor() public {
multiSigWallet = 0x2028834B2c0A36A918c10937EeA71BE4f932da52;
}
function executeTransactionFromOtherContract(uint transactionId) public {
multiSigWallet.callExecuteTransaction(transactionId);
}
}
//for the above contract transaction execution to be successful its required that all 4 mutlsig owners sign the transaction, but the execution call gets reverted .
//when owners sign the transaction , the multisig contract will try to execute it as well as confirming it by the owner . the execute may fail due to unexpeted conditions and/or timelock's //cooldown delay , but the confirmation would still happen and that is where the issue lies
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 use of a low-level call whose failure is ignored, combined with setting the executed flag to false without reverting the confirmation, allows an unauthorised caller to retry the execution later.
Impact
An attacker could trigger a proxy implementation upgrade at a time not intended by the owners, potentially combining deposit and withdraw logic in one transaction with the same block timestamp, though the report notes the scenario is not proven and depends on low-probability conditions.
What the attacker needed
Multisig owners confirm before timelock delay; execution call fails and is not reverted; attacker can call executeTransaction
The fix
The executeTransaction function should restrict callers to owners, admins, or executors, and a failed execution should revert the confirmation rather than leaving the transaction executable by anyone.
How it was found
- Four owners confirm a multisig proposal before the timelock's 45-day delay has elapsed.
- The fourth confirmation triggers executeTransaction, but the destination call reverts due to the timelock, and the low-level call swallows the failure.
- The transaction is marked as not executed, but the confirmations remain recorded.
- Anyone can later call executeTransaction for that transaction ID, causing the upgrade to run when the timelock allows it.
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 wallet is a contract that needs several owners to approve a transaction before it runs. Here, if the approved transaction fails (for example because a 45-day waiting period has not passed), the contract still records the approval but marks the transaction as not executed. Because the failure does not undo the approval, any random person can later trigger that same transaction, which in this case can upgrade the contract's logic.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.