Skip to content
Access control Audit finding Advanced

MultiSig Owners can set malicious implementatio

The report argues that the multisig owners of an upgradeable proxy could queue a benign-looking implementation upgrade in the timelock, then swap the implementation contract at the same address for malicious bytecode before execution. This would let the owners run a malicious implementation that users could not detect during the timelock window.

Shogoki Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

25927 - [SC - Insight] MultiSig Owners can set malicious implementatio...

Submitted on Nov 21st 2023 at 05:25:48 UTC by @Shogoki for Boost | DeGate

Report ID: #25927

Report type: Smart Contract

Report severity: Insight

Target: https://etherscan.io/address/0xf2991507952d9594e71a44a54fb19f3109d213a5#code

Impacts:

  • Introducing Malicious Contract

Description

Bug Description

The DeGate Team made it clear, that they want to prevent any possible malicious actions from the MultiSig Owners. Only exception should be a malicious action that can be detected early (45 days before) via the TimeLock feature. However, there is a possible "attack" that the Owners could run, by:

  • deploying a (seemingly) harmless new version of the implementation contract
  • queue a Transaction in Timelock to change the implementation on the proxy
  • waiting for the Timelock to finsish
  • replacing the implementation contract with a new malicious one at the same address
  • call executeTransaction, to configure the malicious implementation contract

In this scenario the malicious contract cannot be seen by the users before it is actually deployed.

To deploy the malicious contract on the same address, the attackers could use a similiar technique like the Tornado Cash Governance Hack in May 2023, where the attackers deployed an intermediate contract with a predictable address using create2, which in turns creates the actual implementation contract. Leveraging selfdestruct and this technique it is possible to deploy another contract with different bytecode on the same address.

Impact

  • Possible Loss of Funds
  • Malicious implementation contract get´s used by proxy

Risk Breakdown

Difficulty to Exploit: Medium

Recommendation

One way to avoid this would be to also pass the hash of the bytecode for the implementation contract that when changing it. So nobody could actually deploy a different contract there.

References

https://github.com/degatedev/protocols/blob/c8961f2cd354a6578bb332337f983ab4c39c1806/packages/loopring\\_v3/contracts/thirdparty/proxies/OwnedUpgradabilityProxy.sol#L74-L76

Proof of concept

I attached a PoC in Foundry as a Gist. Note: Because selfdestruct is only executed at the end of the call and a limitation in Foundry i added the first part of the test in Setup.

The original report as published on Immunefi, by Shogoki. 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 upgrade mechanism trusts only the implementation address and does not commit to the bytecode hash, so the code at that address can change between queueing and execution.

Impact

The proxy could end up using a malicious implementation, which the report says could lead to loss of funds.

What the attacker needed

Control of the multisig owners; ability to redeploy at same address

The fix

The upgrade should also commit to the hash of the implementation bytecode so a different contract cannot be deployed at that address.

How it was found

  1. Deploy a seemingly harmless new implementation contract.
  2. Queue a timelock transaction to change the proxy implementation.
  3. Wait for the timelock to finish.
  4. Replace the implementation contract with malicious code at the same address.
  5. Call executeTransaction to configure the malicious implementation.

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.

An upgradeable contract keeps its data in a proxy and points to a separate implementation contract that holds the logic. The report says the people who control upgrades could show a harmless implementation during the waiting period, then secretly replace it with a harmful one at the same address before the upgrade runs. Users watching the timelock would see the harmless version and not the harmful one.

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 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.