Skip to content
Access control Audit finding Intermediate

High Risk in transfer of proxyOwnership

The proxy ownership transfer function lets the current owner set a new owner in a single step, with no check that the new address differs from the current one and no two-step confirmation. A malicious or careless operator could hand control to a compromised or invalid address, which the report says could lead to theft or permanent freezing of funds.

SentientX Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

26431 - [SC - Insight] High Risk in transfer of proxyOwnership

Submitted on Dec 2nd 2023 at 22:05:37 UTC by @SentientX for Boost | DeGate

Report ID: #26431

Report type: Smart Contract

Report severity: Insight

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

Impacts:

  • Permanent freezing of funds from the Default Deposit Contract that requires malicious actions from the DeGate Operator.
  • Theft of funds from the Default Deposit Contract that requires malicious actions from the DeGate Operator.

Description

Bug Description

The function:

  function transferProxyOwnership(address newOwner) public onlyProxyOwner {
    require(newOwner != address(0));
    emit ProxyOwnershipTransferred(proxyOwner(), newOwner);
    setUpgradabilityOwner(newOwner);
  }

handles the transfer of ownership to new proxy owner, however the function fails to recognize two fundamental risks:

  1. Transfer of ownership to compromised current owner address
  2. Transfer of ownership to invalid address.

both of which can be caused by operational error or malicious actions of Degate Operator.

Risk 1 Scenario:

  1. Current owner address is compromised. (eg. private key leaked)
  2. In state of panic ownership is transferred to same owner
  3. Risk exposure has not changed

Risk 2 Scenario

  1. Current owner address is compromised
  2. In state of Panic transfer is made to in valid address

Impact

  1. Funds can be stolen if malicious Degate Operator transfers proxy to an address he controls
  2. Funds can be permanently locked up if an error in transfer is made to in valid address

Risk Breakdown

Difficulty to Exploit: Easy Weakness: CVSS2 Score:

Recommendation

  1. Consider use of 2-step transferOwnersip Proxy
  2. Ensure proxy address is not the same address as current owner
  3. transferProxyOwnership by changing pending owner to newOwner

example:

   * @dev Allows the current owner to transfer control of the contract to a newOwner.
   *changes the pending owner to newOwner. But doesn't actually transfer
   * @param newOwner The address to transfer ownership to.
   */
   function transferProxyOwnership(address newOwner) external onlyProxyOwner {
       require(newOwner != address(0));
       _setPendingUpgradeabilityOwner(newOwner);
       emit NewPendingOwner(proxyOwner(), newOwner);
   }
  1. Let pending Owner claim ownership:
    /**
    * @dev Allows the pendingOwner to claim ownership of the proxy
    */
    function claimProxyOwnership() external onlyPendingProxyOwner {
        emit ProxyOwnershipTransferred(proxyOwner(), pendingProxyOwner());
        _setUpgradeabilityOwner(pendingProxyOwner());
        _setPendingUpgradeabilityOwner(address(0));
    }

Finally internal function,

    function _setUpgradeabilityOwner(address newProxyOwner) internal {
        bytes32 position = proxyOwnerPosition;
        assembly {
            sstore(position, newProxyOwner)
        }
    }

References

Reference implementation:

https://www.codeslaw.app/contracts/ethereum/0x0000852600ceb001e08e00bc008be620d60031f2?file=TrueHKD.sol\\&start=98

Proof of concept

  1. Current Proxy owner calls transferProxyOwnership(address newOwner) public onlyProxyOwner setting new owner to compromised address accidently or maliciously.
  2. Protocol Default Deposit contract is compromised
  3. Funds Stolen or Funds Frozen

The original report as published on Immunefi, by SentientX. 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 single-step ownership transfer lacks a two-step accept flow and a check that the new owner differs from the current one.

Impact

Funds could be stolen if a malicious operator transfers the proxy to an address they control, or permanently locked if the transfer goes to an invalid address; both depend on the operator acting maliciously or making an error.

What the attacker needed

Control of the proxy owner key; operator error or malicious intent

The fix

The report recommends a two-step transfer where the new owner is recorded as pending and must claim ownership, plus a check that the new address differs from the current owner.

How it was found

  1. The current proxy owner calls the ownership transfer function.
  2. The new owner is set to a compromised or invalid address, by mistake or on purpose.
  3. The default deposit contract is then under the wrong control.
  4. Funds are stolen or frozen.

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 proxy is a contract that holds the funds but passes calls to a logic contract, and whoever owns the proxy can swap that logic. This report says the owner can change the proxy owner in one step, so a mistake or a stolen key can put the funds under the wrong control. A safer pattern asks the new owner to accept the role before it takes effect.

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 SentientX

View all

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