Timelock can call transferProxyOwnership of Dep
The Timelock contract's queueTransaction function does not restrict which calls can be queued, so it can be used to call transferProxyOwnership on the DepositContractProxy and ExchangeProxy. This would let the proxy ownership move to a non-timelock address, after which the new owner could upgrade the implementation without the intended timelock delay.
- Disclosed after under an hour
25917 - [SC - Insight] Timelock can call transferProxyOwnership of Dep...
Submitted on Nov 21st 2023 at 01:59:51 UTC by @said for Boost | DeGate
Report ID: #25917
Report type: Smart Contract
Report severity: Insight
Target: https://etherscan.io/address/0xf2991507952d9594e71a44a54fb19f3109d213a5#code
Impacts:
- Theft of funds from the Default Deposit Contract that requires malicious actions from the DeGate Operator.
- Permanent freezing of funds from the Default Deposit Contract that requires malicious actions from the DeGate Operator.
- Contract fails to deliver promised returns, but doesn't lose value
Description
Bug Description
It is mentioned that the goal of Timelock is to solve the trustless issue when DeGate need to modify the code and complete the upgrade. However, timelock is not restricted to execute transferProxyOwnership inside DepositContractProxy and ExchangeProxy.
Impact
This will allow Timelock to change proxy ownership, then the new owner can execute upgrade and modify code without trough the designed DeGate timelock process. Basically breaking trustless assumption and violating the new upgrade design.
function queueTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public returns (bytes32) {
require(msg.sender == admin, "Timelock::queueTransaction: Call must come from admin.");
require(eta >= getBlockTimestamp().add(delay), "Timelock::queueTransaction: Estimated execution block must satisfy delay.");
bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));
queuedTransactions[txHash] = true;
emit QueueTransaction(txHash, target, value, signature, data, eta);
return txHash;
}
It can be observed that queueTransaction allow any operation including transferProxyOwnership to DepositContractProxy and ExchangeProxy
Risk Breakdown
Difficulty to Exploit: Critical
Recommendation
Restrict the queueTransaction function inside Timelock by checking if it is providing transferProxyOwnership call to DepositContractProxy and ExchangeProxy. If yes, revert the operations
References
Proof of concept
PoC Scenario :
- MultiSig create
transferProxyOwnershipviaqueueTransactionoperation trough timelock process and providing non-timelock address. - All MultiSig owners sign the transaction and wait for the normal timelock time.
- All MultiSig create
executeTransactionfor the timelock operation and sign the transaction id. - The
transferProxyOwnershipis executed and proxy owner changed to non-timelock. - the new owner can change proxy implementation without any notice and delay and can break or steal funds from users.
Setup empty foundry, and run provided test in gist.
Note, to RUN the PoC, add the following to foundry.toml :
evm_version = "shanghai"
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 Timelock's queueTransaction accepts any target, signature and data without checking whether the call is a proxy ownership transfer on the protected proxies.
Impact
The new proxy owner could upgrade the implementation without the timelock delay, which could break or steal user funds, though the report notes this requires malicious action from the DeGate Operator.
What the attacker needed
MultiSig owners act maliciously; timelock delay elapses
The fix
The queueTransaction function should be restricted so that calls to transferProxyOwnership on the DepositContractProxy and ExchangeProxy are rejected.
How it was found
- The MultiSig queues a transferProxyOwnership call through the timelock, naming a non-timelock address as the new owner.
- The MultiSig owners sign the transaction and wait for the normal timelock delay.
- The MultiSig owners sign an executeTransaction call for the queued operation.
- The transferProxyOwnership executes and the proxy owner becomes the non-timelock address.
- The new owner can change the proxy implementation without notice or delay.
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 timelock is a contract that makes changes wait a set period before they take effect, so users can see them coming. Here the timelock could be told to hand ownership of the main contracts to another address, and that new owner could then change the code straight away. The report says this breaks the trustless upgrade process the timelock was meant to provide.
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.