Skip to content
Business logic Audit finding Beginner

Consider implementing a two step process in tra

The proxy ownership transfer function writes the new owner address directly into storage in a single step, with no confirmation from the recipient. If the owner passes a wrong or uncontrolled address, the proxy owner role is lost and no one can upgrade the proxy.

Bauchibred Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

26446 - [SC - Insight] Consider implementing a two step process in tra...

Submitted on Dec 3rd 2023 at 04:50:11 UTC by @Bauchibred for Boost | DeGate

Report ID: #26446

Report type: Smart Contract

Report severity: Insight

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

Impacts:

  • Potentially losing all access to the functionalities meant to be accessed by the owner.

Description

Proof of Concept

Take a look at transferProxyOwnership()

Solidity
/**
  /**
   * @dev Allows the current owner to transfer control of the contract to a newOwner.
   * @param newOwner The address to transfer ownership to.
   */
  function transferProxyOwnership(address newOwner) public onlyProxyOwner {
    require(newOwner != address(0));
    emit ProxyOwnershipTransferred(proxyOwner(), newOwner);
    setUpgradabilityOwner(newOwner);
  }

   * @dev Sets the address of the owner
   */
  function setUpgradabilityOwner(address newProxyOwner) internal {
    bytes32 position = proxyOwnerPosition;
    assembly {
      sstore(position, newProxyOwner)
    }
  }

It's possible that the onlyProxyOwner role mistakenly transfers ownership to the wrong address, resulting in a loss of the onlyProxyOwner role. The current ownership transfer process involves the current owner calling transferProxyOwnership(). This function checks the new owner is not the zero address and proceeds to write the new owner's address into the owner's state variable via setUpgradabilityOwner(). If the nominated EOA account is not a valid account, it is entirely possible the owner may accidentally transfer ownership to an uncontrolled account, breaking all functions with the onlyProxyOwner() modifier.

Impact

Lack of two-step procedure for critical operations leaves them error-prone if the address is incorrect, the new address will take on the functionality of the new role immediately, or in this case if the address is a wrong one then the access to onlyProxyOwner() is forever bricked, in this case the most impactful issue would be that there would be no proxy owner to upgrade the current version of the proxy.

Recommended Mitigation Steps

Consider implementing a two step process where the owner nominates an account and the nominated account needs to call an acceptOwnership() function for the transfer of ownership to fully succeed. This ensures the nominated EOA account is a valid and active account.

Proof of concept

Solidity
/**
  /**
   * @dev Allows the current owner to transfer control of the contract to a newOwner.
   * @param newOwner The address to transfer ownership to.
   */
  function transferProxyOwnership(address newOwner) public onlyProxyOwner {
    require(newOwner != address(0));
    emit ProxyOwnershipTransferred(proxyOwner(), newOwner);
    setUpgradabilityOwner(newOwner);
  }

   * @dev Sets the address of the owner
   */
  function setUpgradabilityOwner(address newProxyOwner) internal {
//@audit
    bytes32 position = proxyOwnerPosition;
    assembly {
      sstore(position, newProxyOwner)
    }
  }

see @audit tag

The original report as published on Immunefi, by Bauchibred. 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 ownership transfer is a single step that writes the new owner straight to storage without the recipient accepting the role.

Impact

A mistaken transfer could permanently remove the only proxy owner, so the proxy could no longer be upgraded.

What the attacker needed

Owner makes a typo or wrong address

The fix

The transfer should be two-step: the owner nominates an address and that address must call an accept function before ownership changes.

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 smart contract has an owner who is allowed to do special things, such as upgrading the contract. This report says the owner can hand that role to any address in one action, with no check that the new address is real and controlled. A typo would lock everyone out of those special actions for good.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Bauchibred

View all

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

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.