Skip to content
Business logic Audit finding Beginner

Inefficiency in upgradeToAndCall

The upgradeToAndCall function calls the proxy itself after upgrading, which is inefficient because the proxy only has privileged functions and the proxy owner is unlikely to be the proxy. This could cause the call to fail or waste gas, but no direct security impact is claimed.

whunter Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

26530 - [SC - Insight] Inefficiency in upgradeToAndCall

Submitted on Dec 4th 2023 at 14:53:54 UTC by @whunter for Boost | DeGate

Report ID: #26530

Report type: Smart Contract

Report severity: Insight

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

Impacts:

  • Contract fails to deliver promised returns, but doesn't lose value

Description

Bug Description

  function upgradeTo(address implementation) public onlyProxyOwner {
    _upgradeTo(implementation);
  }

  function upgradeToAndCall(address implementation, bytes memory data) payable public onlyProxyOwner {
    upgradeTo(implementation);
    (bool success, ) = address(this).call{value: msg.value}(data);
    require(success);
  }

In upgradeToAndCall, after calling upgradeTo, it calls itself. msg.sender will be the proxy address there. It would be better to call implementation directly because the proxy itself has only privileged functions and it's unlikely that proxyOwner is proxy itself.

Impact

Inefficiency in upgradeToAndCall. Potential reputation damage to the protocol due to unoptimized code.

Risk Breakdown

Difficulty to Exploit: Easy Weakness: CVSS2 Score:

Recommendation

Call (delegate) the implementation directly.

References

The original report as published on Immunefi, by whunter. 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 function uses address(this).call instead of calling the new implementation directly, causing an unnecessary self-call.

Impact

The inefficiency could lead to failed calls or wasted gas, but no loss of funds or security breach is claimed.

What the attacker needed

OnlyProxyOwner role

The fix

The function should call the implementation directly instead of making a self-call.

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 contract is like a middleman that forwards calls to another contract. The upgradeToAndCall function first changes the implementation and then makes a call back to the proxy itself, which is unnecessary and could fail because the proxy only allows its owner to do certain things. This is a code quality issue, not a direct security hole.

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