Skip to content
Business logic Audit finding Intermediate

createProject can be frontrun

The createProject function in a smart contract can be called by anyone, allowing a malicious user to front-run a legitimate project creation and become the owner of the collection. As owner, the attacker can withdraw the payment token.

wuwe1 Follow

Originally disclosed on Code4rena

Submitted by wuwe1, also found by defsec, and kirk-baird

This is dangerous in scam senario because the malicious user can frontrun and become the owner of the collection. As owner, one can withdraw paymentToken. (note that _collections.isForSale can be change by frontrunner)

Proof of Concept

  1. Anyone can call createProject.

https://github.com/code-423n4/2022-03-joyn/blob/main/core-contracts/contracts/CoreFactory.sol#L70-L77

  function createProject(
    string memory _projectId,
    Collection[] memory _collections
  ) external onlyAvailableProject(_projectId) {
    require(
      _collections.length > 0,
      'CoreFactory: should have more at least one collection'
    );

Recommended Mitigation Steps

Two ways to mitigate.

  1. Consider use white list on project creation.
  2. Ask user to sign their address and check the signature against msg.sender. https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/ECDSA.sol#L102

sofianeOuafir (Joyn) confirmed and commented:

This is an issue and we intend to fix it!

deluca-mike (judge) commented:

The solutions listed in #34 and #35 are better.


The original report as published on Code4rena, by wuwe1. 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 createProject function lacks access control, allowing any address to call it and become the owner of a project ID before the legitimate creator.

Impact

A malicious user could front-run project creation to become the owner and withdraw the payment token, potentially stealing funds.

What the attacker needed

Attacker can submit transactions; attacker can pay higher gas

How it was found

  1. Observe a pending createProject transaction from a legitimate user.
  2. Submit a createProject transaction with the same project ID but with attacker-controlled parameters and a higher gas price to front-run.
  3. The attacker's transaction is mined first, making the attacker the owner of the collection.
  4. As owner, the attacker can withdraw the paymentToken.

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.

In blockchain, transactions wait in a public pool before being processed. An attacker can see a pending transaction and pay a higher fee to get their own transaction processed first. Here, an attacker sees a legitimate project creation and quickly creates the same project first, becoming the owner and gaining control of funds.

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 wuwe1

View all

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

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.