Skip to content
DoS Audit finding Intermediate

DOS by Frontrunning NoteERC20 initialize() Function

The deployment script deploys the NoteERC20 proxy contract and calls its initialize() function in separate transactions, allowing an attacker to front-run the initialization and become the owner. This can be repeated to prevent deployment, causing a denial of service and wasted gas.

leastwood Follow

Originally disclosed on Code4rena

Submitted by leastwood

The scripts/ folder outlines a number of deployment scripts used by the Notional team. Some of the contracts deployed utilize the ERC1967 upgradeable proxy standard. This standard involves first deploying an implementation contract and later a proxy contract which uses the implementation contract as its logic.

When users make calls to the proxy contract, the proxy contract will delegate call to the underlying implementation contract. NoteERC20.sol and Router.sol both implement an initialize() function which aims to replace the role of the constructor() when deploying proxy contracts. It is important that these proxy contracts are deployed and initialized in the same transaction to avoid any malicious front-running.

However, scripts/deployment.py does not follow this pattern when deploying NoteERC20.sol’s proxy contract. As a result, a malicious attacker could monitor the Ethereum blockchain for bytecode that matches the NoteERC20 contract and front-run the initialize() transaction to gain ownership of the contract. This can be repeated as a Denial Of Service (DOS) type of attack, effectively preventing Notional’s contract deployment, leading to unrecoverable gas expenses. See deployment.py L44-L60, and deploy_governance.py L71-L105.

As the GovernanceAlpha.sol and NoteERC20.sol are co-dependent contracts in terms of deployment, it won’t be possible to deploy the governance contract before deploying and initializing the token contract. Therefore, it would be worthwhile to ensure the NoteERC20.sol proxy contract is deployed and initialized in the same transaction, or ensure the initialize() function is callable only by the deployer of the NoteERC20.sol contract. This could be set in the proxy contracts constructor().

jeffywu (Notional) confirmed

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

Likely the deployment script did not deploy and initialize the proxy in the same transaction, leaving the initialize() function callable by anyone.

Impact

An attacker could gain ownership of the contract and repeatedly block deployment, leading to unrecoverable gas expenses.

What the attacker needed

Ability to monitor Ethereum blockchain; ability to front-run transactions

The fix

The proxy contract should be deployed and initialized in the same transaction, or the initialize() function should be restricted to the deployer.

How it was found

  1. Monitor the Ethereum blockchain for bytecode matching the NoteERC20 contract.
  2. Front-run the initialize() transaction to gain ownership of the contract.
  3. Repeat to cause denial of service and prevent deployment.

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.

When a contract is deployed behind a proxy, it needs an initialization step to set things like the owner. If that step is a separate transaction, someone else can call it first and take control. Here the deployment script did that, so an attacker could repeatedly grab ownership and block the real deployment.

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.