Skip to content
DoS Audit finding Intermediate

Potential DOS in Contracts Inheriting UUPSUpgradeable.sol

The implementation contract behind the NoteERC20 proxy was left uninitialized, allowing any user to become its owner. That user could then upgrade the implementation to a malicious contract that self-destructs, causing a denial of service for all NoteERC20 interactions until a new implementation is deployed.

leastwood Follow

Originally disclosed on Code4rena

Submitted by leastwood

There are a number of contracts which inherit UUPSUpgradeable.sol, namely; GovernanceAction.sol, PauseRouter.sol and NoteERC20.sol.

All these contracts are deployed using a proxy pattern whereby the implementation contract is used by the proxy contract for all its logic. The proxy contract will make delegate calls to the implementation contract. This helps to facilitate future upgrades by pointing the proxy contract to a new and upgraded implementation contract.

However, if the implementation contract is left uninitialized, it is possible for any user to gain ownership of the onlyOwner role in the implementation contract for NoteERC20.sol. Once the user has ownership they are able to perform an upgrade of the implementation contract’s logic contract and delegate call into any arbitrary contract, allowing them to self-destruct the proxy’s implementation contract. Consequently, this will prevent all NoteERC20.sol interactions until a new implementation contract is deployed.

Initial information about this issue was found here.

Consider the following scenario:

  • Notional finance deploys their contracts using their deployment scripts. These deployment scripts leave the implementation contracts uninitialized. Specifically the contract in question is NoteERC20.sol.
  • This allows any arbitrary user to call initialize() on the NoteERC20.sol implementation contract.
  • Once a user has gained control over NoteERC20.sol’s implementation contract, they can bypass the _authorizeUpgrade check used to restrict upgrades to the onlyOwner role.
  • The malicious user then calls UUPSUpgradeable.upgradeToAndCall() shown here which in turn calls this function. The new implementation contract then points to their own contract containing a self-destruct call in its fallback function.
  • As a result, the implementation contract will be self-destructed due to the user-controlled delegate call shown here, preventing all future calls to the NoteERC20.sol proxy contract until a new implementation contract has been deployed.

Recommend considering initializing the implementation contract for NoteERC20.sol and checking the correct permissions before deploying the proxy contract or performing any contract upgrades. This will help to ensure the implementation contract cannot be self-destructed.

jeffywu (Notional) acknowledged and disagreed with severity:

Acknowledged, I don’t think this should be categorized high risk because the worst case is a denial of service and a redeployment of the ERC20 contract. As it stands, we’ve already successfully deployed our ERC20 contract so this is a non-issue.

I would categorize as 0 (Non-critical)

adamavenir (organizer) commented:

Warden leastwood added this proof of concept to illustrate the vulnerability https://gist.github.com/leastwood/b23d9e975883c817780116c2ceb785b8

jeffywu (Notional) commented:

Ok I retract my previous statement, I misread the issue description. Up to you guys but do you want to pay out a full amount to someone who is reporting issues discovered elsewhere? OZ has already called initialize on our deployed contract for us.

adamavenir (organizer) commented:

@jeffywu (Notional) I think the question is whether the issue is valid based on the original code base. Given your initial response and change after his proof of concept, my read was there was value here in what he reported. Is that a correct understanding?

jeffywu (Notional) commented:

There was value added here but perhaps not at the same level as the other high risk issues.

adamavenir (organizer) commented:

@jeffywu (Notional) Thanks for the input. As per our rules, awards are determined strictly based on the judge’s assessment of the validity and severity, so we’ll see how our judge chooses to score this.

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

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

The implementation contract was left uninitialized, allowing an attacker to become its owner and upgrade it to a malicious contract.

Impact

This could cause a denial of service for all NoteERC20 interactions until a new implementation contract is deployed; the report notes the issue was already mitigated because OpenZeppelin had called initialize on the deployed contract.

What the attacker needed

Implementation contract left uninitialized; Attacker can call initialize() on implementation

The fix

The implementation contract should be initialized and correct permissions checked before deploying the proxy or performing upgrades.

How it was found

  1. Deploy contracts with uninitialized implementation contracts, specifically NoteERC20.sol.
  2. Call initialize() on the NoteERC20.sol implementation contract to gain ownership.
  3. Bypass the _authorizeUpgrade check and call UUPSUpgradeable.upgradeToAndCall() to point to a malicious contract.
  4. The malicious contract's fallback function contains a self-destruct call, which destroys the implementation contract.

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 forwards calls to an implementation contract, which holds the actual code. If that implementation contract is not initialised, anyone can claim ownership and change its code to something harmful, like a contract that destroys itself. This would break the proxy until a new implementation is deployed.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by leastwood

View all

70 more disclosed reports, best first.

More from Notional contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.