Skip to content
DoS Audit finding Intermediate

DoS: Attacker May Front-Run createSplit() With A merkleRoot Causing Future Transactions With The Same merkleRoot to Revert

The createSplit() function uses the merkleRoot as a salt for deploying a SplitProxy, so each merkleRoot can only be used once. An attacker can front-run a createSplit() transaction with a higher gas price using the same merkleRoot, causing the original transaction to revert and preventing the user from using that merkleRoot again.

kirk-baird Follow

Originally disclosed on Code4rena

Submitted by kirk-baird

A merkleRoot may only be used once in createSplit() since it is used as salt to the deployment of a SplitProxy.

The result is an attacker may front-run any createSplit() transaction in the mem pool and create another createSplit() transaction with a higher gas price that uses the same merkleRoot but changes the other fields such as the _collectionContract or _splitAsset(). The original transaction will revert and the user will not be able to send any more transaction with this merkleRoot.

The user would therefore have to generate a new merkle tree with different address, different allocations or a different order of leaves in the tree to create a new merkle root. However, the attack is repeateable and there is no guarantee this new merkle root will be successfully added to a split without the attacker front-running the transaction again.

Proof of Concept

The excerpt from createSplitProxy() shows the merkleRoot() being used as a salt.

  splitProxy = address(
    new SplitProxy{salt: keccak256(abi.encode(merkleRoot))}()
  );

Recommended Mitigation Steps

As seems to be the case here if the transaction address does NOT need to be known ahead of time consider removing the salt parameter from the contract deployment.

Otherwise, if the transaction address does need to be known ahead of time then consider concatenating msg.sender to the merkleRoot. e.g.

splitProxy = address(
    new SplitProxy{salt: keccak256(abi.encode(msg.sender, merkleRoot))}()
  )

sofianeOuafir (Joyn) confirmed and commented:

This is an issue and intend to fix it


The original report as published on Code4rena, by kirk-baird. 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 merkleRoot is used as a salt for contract deployment, making it single-use, and there is no protection against front-running.

Impact

The user's transaction reverts and they cannot reuse the same merkleRoot, forcing them to generate a new merkle tree, and the attack can be repeated.

What the attacker needed

Attacker can monitor the mem pool; attacker can pay higher gas

The fix

The salt parameter should be removed if the address does not need to be known in advance, or msg.sender should be concatenated with the merkleRoot in the salt.

How it was found

  1. Attacker observes a createSplit() transaction in the mem pool.
  2. Attacker submits a createSplit() transaction with the same merkleRoot but different other fields and a higher gas price.
  3. The attacker's transaction is mined first, consuming the merkleRoot.
  4. The original transaction reverts because the merkleRoot is already used.

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 you create a split, the system uses a unique code (the merkleRoot) to deploy a new contract. Because that code can only be used once, someone else can copy it and submit their own transaction with a higher fee, which gets processed first. Your transaction then fails, and you cannot reuse that code.

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 kirk-baird

View all

32 more disclosed reports, best first.

More from Joyn 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.