Skip to content
Access control Audit finding Advanced

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.

said Follow

Originally disclosed on Immunefi

Informational View original
  • 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.

https://github.com/degatedev/protocols/blob/180138015197c886ec3c87efa8bf0031b653359f/packages/loopring\\_v3/contracts/thirdparty/timelock/Timelock.sol#L63-L72

Solidity
    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

https://github.com/degatedev/protocols/commit/180138015197c886ec3c87efa8bf0031b653359f?utm\\_source=immunefi#commitcomment-132582143

https://github.com/degatedev/protocols/commit/180138015197c886ec3c87efa8bf0031b653359f?utm\\_source=immunefi#diff-83099129c62e972adeec76325e36fa907afaac960342ce8de1c451d033ac41ef

Proof of concept

PoC Scenario :

  1. MultiSig create transferProxyOwnership via queueTransaction operation trough timelock process and providing non-timelock address.
  2. All MultiSig owners sign the transaction and wait for the normal timelock time.
  3. All MultiSig create executeTransactionfor the timelock operation and sign the transaction id.
  4. The transferProxyOwnership is executed and proxy owner changed to non-timelock.
  5. 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"

The original report as published on Immunefi, by said. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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

  1. The MultiSig queues a transferProxyOwnership call through the timelock, naming a non-timelock address as the new owner.
  2. The MultiSig owners sign the transaction and wait for the normal timelock delay.
  3. The MultiSig owners sign an executeTransaction call for the queued operation.
  4. The transferProxyOwnership executes and the proxy owner becomes the non-timelock address.
  5. 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.

More by said

View all

21 more disclosed reports, best first.

More from DeGate

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.