Skip to content
Business logic Audit finding Intermediate

[REVISED] Malicious AccessToken creator can steal gas via mintStaticPrice or mintDynamicPrice

The AccessToken payment logic sends ETH to the creator (and possibly a referrer) using a low-level call that forwards all available gas. A malicious creator could run arbitrary code in their receive function during payment, making the buyer pay extra gas.

Belong

Originally disclosed on Immunefi

57203 sc medium revised malicious accesstoken creator can steal gas via mintstaticprice or mintdynamicprice

Description

TO IMMUNEFI TRIAGERS

This section responds to a comment in report #57040 to clarify some points. The rest of the report remains unchanged.

{% stepper %} {% step %}

1. Victim interaction and facilitator contract

The only contract the victim interacts with is the deployed AccessToken. The exploit leverages the AccessToken logic — the AccessToken contract is the facilitator of the attack. During normal execution the victim is not aware that an external call will be made to a malicious contract (external calls are made to the platform, referrer and creator). {% endstep %}

{% step %}

2. Signed message does not include intended owner

To deploy an instance of AccessToken, the Signer address signs a message consisting of NFT name, symbol, contractURI, feeNumerator. This message does not include the intended owner/deployer of AccessToken. Upon deployment the deployer becomes the owner. Consequently:

  • A user can provide NFT data to be signed and then call deploy using a different address.
  • For comparison, Factory::deployVestingWallet includes the intended owner in the signed message (function deployVestingWallet(address _owner, VestingWalletInfo calldata vestingWalletInfo, bytes calldata signature)). That pattern prevents this class of problem for vesting wallets, but it is not applied to AccessToken.
  • During AccessToken::initialize the owner is set as _initializeOwner(_params.creator) which is not controlled by the user submitting the signed data. {% endstep %}

{% step %}

3. Not simply user error

The user only interacts with Belong’s AccessToken code. The code assumes creators are benign; the user has no control over interactions with the creator address during payment flows. This is not purely a user mistake. {% endstep %}

{% step %}

4. Functionality preserved but with hidden attack surface

AccessToken still functions as an access pass (NFT minting), but the hidden doorway in payment logic allows a malicious creator to execute arbitrary actions (unrelated to minting) that impose extra gas costs on the caller. {% endstep %} {% endstepper %}

For a visualization of the exploit flow, the reporter attached "AccessToken-TheftOfGasExploitFlow.png".

Therefore, because the user has no control over the interaction with the creator address and because the AccessToken purpose can be abused to harm users, the issue is considered valid.


Report: Description

The AccessToken allows users to pay for NFT mints using ETH through mintStaticPrice or mintDynamicPrice. When mints are made using ETH, these functions call an internal _pay function which sends payments to:

  1. the platform,
  2. the referrer, and
  3. the creator

using the low-level SafeTransferLib::safeTransferETH. The low-level call forwards all available gas to recipients. A malicious creator (or a malicious referrer, if applicable) can use this to steal gas from users when they pay using ETH, by executing arbitrary code in their fallback/receive while receiving the payment. The caller pays for the extra gas.

Important things to note:

  1. Factory::produce does not verify the caller. Once the Signer provides a valid signature for NFT name, symbol, contractURI, feeNumerator, produce can be called by any address.
  2. SafeTransferLib.sol contains a more gas-restrictive function forceSafeTransferETH which uses a gas stipend, but it was not used.
  3. If the referrer is not protocol-controlled, the same attack can extend to payments made to the referrer address if the AccessToken was created using a referral code.

The associated Code for _pay called by mintStaticPrice() and mintDynamicPrice()

Solidity
function _pay(uint256 price, address expectedPayingToken) private returns (uint256 amount) {
    AccessTokenParameters memory _parameters = parameters;
    Factory.FactoryParameters memory factoryParameters = _parameters.factory.nftFactoryParameters();

    amount = expectedPayingToken == NATIVE_CURRENCY_ADDRESS ? msg.value : price;

    require(amount == price, IncorrectNativeCurrencyAmountSent(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); //@audit-issue: (Secondary case) if not protocol controlled, then can also abuse to steal gas
        }

        _parameters.creator.safeTransferETH(amountToCreator); //@audit-issue: (Primary case): possible for a malicious creator to use the low-level call to steal gas
    } else {
        //--snip--

The SafeTransferLib::safeTransferETH logic

Solidity
function safeTransferETH(address to, uint256 amount) internal {
    /// @solidity memory-safe-assembly
    assembly {
        if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) { //@audit-issue: low-level call forwards all available gas enabling gas theft attacks
            mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
            revert(0x1c, 0x04)
        }
    }
}

Impact

A malicious creator (or referrer) can abuse the payment logic to steal gas by executing additional arbitrary logic in their fallback/receive when receiving ETH. The unsuspecting buyer pays for the extra gas, leading to:

  • Theft of gas (attacker causes buyer to spend more gas than necessary).
  • Griefing (attacker causes damage without direct monetary profit).

Mitigation

{% hint style="info" %} Replace safeTransferETH calls with the more restrictive forceSafeTransferETH from the same SafeTransferLib.sol, which uses a gas stipend to limit forwarded gas and mitigate this class of gas-stealing attacks. {% endhint %}

No additional functionality or protocol-level assumptions are suggested beyond using a gas-stipend-limited transfer to protocol-controlled addresses (and ensuring referral/creator addresses are validated or protocol-controlled where appropriate).


Proof of Concept

A runnable Foundry PoC and a stack trace are available in the private gist:

https://gist.github.com/blackgrease/840497c0aa53d6a459e03c5708b1108e

The gist contains:

  • a runnable Foundry PoC
  • PoC-StackTrace_TheftOfGasFromMaliciousCreator.txt

{% stepper %} {% step %}

PoC Steps — Setup and exploit flow

  1. Deploy an AccessToken via Factory::produce from a contract that implements a malicious receive.
  2. A buyer pays the required price and mints the NFT.
  3. When the payment is made to the creator, the malicious receive is triggered and executes arbitrary logic, stealing gas.
  4. Console logs show starting and remaining gas and the amount of gas consumed via the malicious interaction. {% endstep %} {% endstepper %}

(Note: referral-based attack is described in the report and can be applied analogously to any non-protocol-controlled referrer.)


If you need the PoC reproduced inline or want extracted test cases / specific locations in the repository mapped to suggested fixes, I can prepare a patch-style suggestion applying forceSafeTransferETH where appropriate and highlighting where referral/creator addresses should be protocol-controlled or validated.

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

The target is AccessToken.sol in the Belong contracts repository, a smart contract that acts as an access pass: users pay for NFT mints in ETH through mintStaticPrice or mintDynamicPrice. When payment is made in ETH, both functions call an internal _pay function that distributes the money to three recipients: the platform, the referrer and the creator. The report is a medium-severity smart contract finding about gas theft and griefing enabled by how those payments are sent.

The report opens with a clarification section addressed to Immunefi triagers, responding to a comment on report #57040. The rest of the report is unchanged.

Setup

The relevant roles and components are:

  1. The Signer, which signs a message consisting of NFT name, symbol, contractURI, feeNumerator so that an AccessToken instance can be deployed.
  2. The Factory, whose produce function deploys the token. Factory::produce does not verify the caller: once the Signer provides a valid signature, produce can be called by any address.
  3. The deployer, who becomes the owner of the deployed AccessToken.
  4. The creator, the address that receives the creator share of each mint payment.
  5. The referrer, an optional address used when the token was created with a referral code.
  6. The buyer, who pays the price in ETH and mints the NFT.

The proof of concept is a runnable Foundry PoC, together with a stack trace, published in a private gist. The gist contains a runnable Foundry PoC and PoC-StackTrace_TheftOfGasFromMaliciousCreator.txt. The report does not reproduce the PoC inline.

Finding it

The researcher looked at the payment path used by mintStaticPrice and mintDynamicPrice. When mints are paid in ETH, _pay sends funds to the platform, the referrer and the creator using the low-level SafeTransferLib::safeTransferETH. That low-level call forwards all available gas to the recipient. A malicious creator, or a malicious referrer where applicable, can therefore execute arbitrary code in their fallback/receive while being paid, and the caller pays for the extra gas.

The report also notes that SafeTransferLib.sol contains a more gas-restrictive function, forceSafeTransferETH, which uses a gas stipend, but it was not used here.

The associated code for _pay, called by mintStaticPrice() and mintDynamicPrice(), is:

Solidity
function _pay(uint256 price, address expectedPayingToken) private returns (uint256 amount) {
    AccessTokenParameters memory _parameters = parameters;
    Factory.FactoryParameters memory factoryParameters = _parameters.factory.nftFactoryParameters();

    amount = expectedPayingToken == NATIVE_CURRENCY_ADDRESS ? msg.value : price;

    require(amount == price, IncorrectNativeCurrencyAmountSent(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); //@audit-issue: (Secondary case) if not protocol controlled, then can also abuse to steal gas
        }

        _parameters.creator.safeTransferETH(amountToCreator); //@audit-issue: (Primary case): possible for a malicious creator to use the low-level call to steal gas
    } else {
        //--snip--

The SafeTransferLib::safeTransferETH logic is:

Solidity
function safeTransferETH(address to, uint256 amount) internal {
    /// @solidity memory-safe-assembly
    assembly {
        if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) { //@audit-issue: low-level call forwards all available gas enabling gas theft attacks
            mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
            revert(0x1c, 0x04)
        }
    }
}

The call(gas(), ...) forwards all remaining gas to to, which is the point the researcher flagged.

Exploitation

The report's PoC steps describe the exploit flow, and the reporter attached a visualization named AccessToken-TheftOfGasExploitFlow.png.

Step 1: Deploy a malicious AccessToken

Deploy an AccessToken via Factory::produce from a contract that implements a malicious receive. Because produce does not verify the caller, any address holding a valid signature for the NFT data can perform this deployment.

Step 2: Buyer mints

A buyer pays the required price and mints the NFT. The buyer interacts only with the deployed AccessToken; during normal execution the victim is not aware that an external call will be made to a malicious contract, since external calls are made to the platform, referrer and creator.

Step 3: Malicious receive runs

When the payment is made to the creator, the malicious receive is triggered and executes arbitrary logic, stealing gas. The same applies to the referrer payment in the secondary case, if the referrer is not protocol-controlled and the AccessToken was created using a referral code.

Step 4: Gas accounting

Console logs show starting and remaining gas and the amount of gas consumed via the malicious interaction.

The referral-based attack can be applied analogously to any non-protocol-controlled referrer.

Root cause

Two design decisions combine:

  1. Factory::produce does not verify the caller. The Signer signs only NFT name, symbol, contractURI, feeNumerator, and that message does not include the intended owner or deployer of the AccessToken. Upon deployment the deployer becomes the owner. A user can therefore provide NFT data to be signed and then call deploy from a different address. For comparison, Factory::deployVestingWallet includes the intended owner in the signed message:
Solidity
function deployVestingWallet(address _owner, VestingWalletInfo calldata vestingWalletInfo, bytes calldata signature)

That pattern prevents this class of problem for vesting wallets, but it is not applied to AccessToken. During AccessToken::initialize the owner is set as _initializeOwner(_params.creator), which is not controlled by the user submitting the signed data.

  1. _pay sends ETH with safeTransferETH, whose low-level call(gas(), ...) forwards all available gas to the recipient. The more restrictive forceSafeTransferETH, which uses a gas stipend, exists in the same library but was not used.

The researcher argues this is not simply user error: the user only interacts with Belong's AccessToken code, the code assumes creators are benign, and the user has no control over interactions with the creator address during payment flows. AccessToken still functions as an access pass (NFT minting), but the payment logic allows a malicious creator to execute arbitrary actions unrelated to minting that impose extra gas costs on the caller.

Impact

A malicious creator, or a referrer where the referrer is not protocol-controlled, can abuse the payment logic to steal gas by executing additional arbitrary logic in their fallback/receive when receiving ETH. The unsuspecting buyer pays for the extra gas. The listed impacts are:

  • Theft of gas: the attacker causes the buyer to spend more gas than necessary.
  • Griefing: the attacker causes damage without direct monetary profit.

The report severity is Medium, and the impacts are listed as theft of gas and griefing with no profit motive required.

Fix

The recommended mitigation is to replace safeTransferETH calls with the more restrictive forceSafeTransferETH from the same SafeTransferLib.sol, which uses a gas stipend to limit forwarded gas and mitigate this class of gas-stealing attacks. The report suggests no additional functionality or protocol-level assumptions beyond using a gas-stipend-limited transfer to protocol-controlled addresses, and ensuring referral and creator addresses are validated or protocol-controlled where appropriate. The report does not state that any change was made.

Variants to test

  1. Other payment paths that use safeTransferETH or any low-level call(gas(), ...) to an address supplied by a user or creator. A positive result is a recipient contract whose receive consumes gas and the caller's transaction cost rising accordingly.
  2. Referral flows where the referrer address is not protocol-controlled. A positive result is the same gas inflation on the referral share.
  3. Factory deployment functions whose signed message omits the intended owner, as Factory::produce does here. A positive result is deploying an instance from a different address than the one that obtained the signature, with the deployer becoming owner.
  4. Comparisons with sibling deployment functions such as Factory::deployVestingWallet, which includes _owner in the signed message, to find functions that do not follow the same pattern.

Hunting notes

This kind of bug hides in payment distribution code: internal helpers such as _pay that fan out ETH to several recipients, and library wrappers around low-level calls. The signal during review is a call(gas(), ...) in assembly, or a safeTransferETH-style helper, reaching an address that a third party controls, combined with a deployment path that does not bind the signed data to the deployer. The PoC steps are to deploy through Factory::produce from a contract with a malicious receive, have a buyer mint, and log starting gas, remaining gas and gas consumed by the malicious interaction, with a runnable Foundry PoC and stack trace supplied privately. The report also argues against the user-error objection, noting that the signed message omits the intended owner and that the victim has no control over the creator address during payment.

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 can create and sell access passes, which are small digital tokens (NFTs) that prove you are allowed into something. The contract at the centre of this report, AccessToken.sol, is the piece of code that handles those passes: it lets a buyer pay for a pass in ETH (the cryptocurrency of the Ethereum network) and hands out the NFT in return.

When a buyer pays, the money does not all go to one place. It is split three ways: a cut for the platform, a cut for a referrer (someone who recommended the pass and gets a small reward), and the rest for the creator of the pass. The contract sends each share with a helper function called safeTransferETH.

The problem is how that helper sends money. In Ethereum, sending ETH to another address can trigger code on the receiving side, a bit like a doorbell that makes the person inside run a little routine before they open the door. The helper gives that receiving code all the gas that is left in the transaction. Gas is the unit that measures computing effort on Ethereum, and the person who started the transaction pays for every unit used. So if the creator is a malicious contract, its little routine can burn as much gas as it likes, and the buyer foots the bill.

The researcher calls this gas theft, and also griefing: causing harm to someone without making a direct profit yourself. The report is rated Medium severity.

Before the main body, the report includes a clarification section addressed to the people who triage bug reports at Immunefi, the platform hosting the audit competition. It answers a comment made on an earlier report, #57040. The rest of the report is unchanged.

The pieces involved

To follow the attack you only need to know who the players are. Think of a theatre ticket office:

  1. The Signer: a trusted key held by Belong. It signs a message listing the NFT's name, symbol, contractURI (a link to the collection's metadata) and feeNumerator (a royalty setting). A signature here is like a stamped approval form: it says "this data is fine to deploy".
  2. The Factory: the contract whose produce function actually creates the AccessToken. Crucially, produce does not check who is calling it. Anyone holding a valid signature can press the button.
  3. The deployer: whoever calls produce. On deployment, that address becomes the owner of the new token.
  4. The creator: the address that receives the creator's share of every mint payment.
  5. The referrer: an optional address, used when the token was created with a referral code, that receives a referral share.
  6. The buyer: the person paying ETH and receiving the NFT.

The proof of concept is a runnable Foundry PoC (Foundry is a toolkit for writing and running tests against Ethereum contracts) plus a stack trace, both published in a private gist. The gist contains the runnable Foundry PoC and a file named PoC-StackTrace_TheftOfGasFromMaliciousCreator.txt. The report does not reproduce the PoC inline.

How the researcher found it

The researcher read the payment path used by two public functions, mintStaticPrice and mintDynamicPrice. Both let a buyer mint an NFT by paying ETH. Both call an internal helper, _pay, which splits the money and sends it out with SafeTransferLib::safeTransferETH.

That helper uses a low-level call that forwards all available gas to the recipient. In plain terms: the contract does not say "here is your money, and here is a small fixed budget for anything you want to run"; it says "here is your money, and here is the entire remaining budget". A malicious creator, or a malicious referrer where the referrer is not controlled by the protocol, can therefore run arbitrary code in its fallback or receive function while being paid, and the caller pays for the extra gas.

A receive function is the special piece of code an Ethereum contract runs when it is sent plain ETH. A fallback function is the catch-all that runs when a contract is called with data it does not recognise. Both are ordinary code, so both can loop, write storage, or do anything else that costs gas.

The report also notes that SafeTransferLib.sol already contains a stricter helper, forceSafeTransferETH, which uses a gas stipend (a small fixed allowance of gas) instead of forwarding everything. It was not used here.

Here is the _pay code, called by mintStaticPrice() and mintDynamicPrice():

Solidity
function _pay(uint256 price, address expectedPayingToken) private returns (uint256 amount) {
    AccessTokenParameters memory _parameters = parameters;
    Factory.FactoryParameters memory factoryParameters = _parameters.factory.nftFactoryParameters();

    amount = expectedPayingToken == NATIVE_CURRENCY_ADDRESS ? msg.value : price;

    require(amount == price, IncorrectNativeCurrencyAmountSent(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); //@audit-issue: (Secondary case) if not protocol controlled, then can also abuse to steal gas
        }

        _parameters.creator.safeTransferETH(amountToCreator); //@audit-issue: (Primary case): possible for a malicious creator to use the low-level call to steal gas
    } else {
        //--snip--

Line by line, in plain words:

  • function _pay(uint256 price, address expectedPayingToken) private returns (uint256 amount) { declares a private helper that takes the price and the token the buyer is expected to pay with, and returns the amount paid.
  • AccessTokenParameters memory _parameters = parameters; copies the token's stored settings into memory so they can be read cheaply.
  • Factory.FactoryParameters memory factoryParameters = _parameters.factory.nftFactoryParameters(); asks the factory for its global settings, such as the platform commission and the platform address.
  • amount = expectedPayingToken == NATIVE_CURRENCY_ADDRESS ? msg.value : price; if the buyer is paying in ETH (the native currency), the amount is whatever ETH was attached to the call (msg.value); otherwise it is the listed price.
  • require(amount == price, IncorrectNativeCurrencyAmountSent(amount)); stops the transaction if the amount does not match the price.
  • uint256 fees = (amount * factoryParameters.platformCommission) / PLATFORM_COMISSION_DENOMINATOR; works out the platform's cut as a fraction of the amount.
  • uint256 amountToCreator; declares a variable for the creator's share.
  • unchecked { amountToCreator = amount - fees; } subtracts the platform cut from the total. unchecked means Solidity skips its usual overflow checks here, which is safe because the subtraction cannot go below zero.
  • bytes32 referralCode = _parameters.referralCode; reads the token's referral code, if any.
  • uint256 referralFees; and address refferalCreator; declare the referral share and the address that should receive it.
  • if (referralCode != bytes32(0)) { runs the referral logic only when a referral code was set.
  • referralFees = _parameters.factory.getReferralRate(_parameters.creator, referralCode, fees); asks the factory how much of the fees the referrer should get.
  • if (referralFees > 0) { continues only if there is something to pay the referrer.
  • refferalCreator = _parameters.factory.getReferralCreator(referralCode); looks up the referrer's address.
  • unchecked { fees -= referralFees; } takes the referral share out of the platform's cut.
  • if (expectedPayingToken == NATIVE_CURRENCY_ADDRESS) { enters the ETH payment branch.
  • if (fees > 0) { factoryParameters.platformAddress.safeTransferETH(fees); } sends the platform's share.
  • if (referralFees > 0) { refferalCreator.safeTransferETH(referralFees); //@audit-issue: (Secondary case) if not protocol controlled, then can also abuse to steal gas } sends the referral share. The researcher's comment marks this as the secondary attack case: if the referrer is not controlled by the protocol, it can abuse the same weakness.
  • _parameters.creator.safeTransferETH(amountToCreator); //@audit-issue: (Primary case): possible for a malicious creator to use the low-level call to steal gas sends the creator's share. The researcher's comment marks this as the primary case.
  • } else { //--snip-- is the branch for payments made in another token, which the report does not show.

Now the helper that actually moves the ETH:

Solidity
function safeTransferETH(address to, uint256 amount) internal {
    /// @solidity memory-safe-assembly
    assembly {
        if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) { //@audit-issue: low-level call forwards all available gas enabling gas theft attacks
            mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
            revert(0x1c, 0x04)
        }
    }
}

Line by line:

  • function safeTransferETH(address to, uint256 amount) internal { declares an internal helper that sends amount to to.
  • assembly { switches to inline assembly, raw EVM instructions written by hand rather than normal Solidity.
  • if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) { performs the low-level call. gas() is the key part: it passes all remaining gas to the recipient. to is the destination, amount is the ETH value, and the remaining arguments describe empty input and output data. iszero checks whether the call failed (a call returns zero on failure).
  • mstore(0x00, 0xb12d13eb) writes the error selector for ETHTransferFailed() into memory, so the revert carries a meaningful error.
  • revert(0x1c, 0x04) reverts the transaction with that error.

The call(gas(), ...) is exactly the point the researcher flagged: the recipient gets the whole gas budget, not a small fixed one.

How the attack plays out

The report's PoC steps describe the exploit flow, and the reporter attached a visualisation named AccessToken-TheftOfGasExploitFlow.png.

Step 1: Deploy a malicious AccessToken

Deploy an AccessToken through Factory::produce from a contract that implements a malicious receive. Because produce does not check the caller, any address holding a valid signature for the NFT data can do this deployment. This step matters because it is how the attacker gets a creator address that is really a piece of hostile code.

Step 2: The buyer mints

A buyer pays the required price and mints the NFT. The buyer interacts only with the deployed AccessToken. During normal execution the victim has no idea that an external call will be made to a malicious contract, because external calls are made to the platform, the referrer and the creator, all of which look like ordinary recipients.

Step 3: The malicious receive runs

When the payment reaches the creator, the malicious receive is triggered and runs arbitrary logic, stealing gas. The same applies to the referrer payment in the secondary case, if the referrer is not controlled by the protocol and the AccessToken was created with a referral code.

Step 4: Gas accounting

Console logs show the starting gas, the remaining gas, and the amount of gas consumed by the malicious interaction. The PoC steps include console logs showing the starting gas, the remaining gas, and the amount of gas consumed by the malicious interaction.

The referral-based attack can be applied in the same way to any referrer that is not controlled by the protocol.

Why it works

Two design decisions combine to make the attack possible.

  1. Factory::produce does not verify the caller. The Signer signs only NFT name, symbol, contractURI, feeNumerator, and that message does not include the intended owner or deployer of the AccessToken. On deployment the deployer becomes the owner. So a user can get NFT data signed and then call deploy from a different address. For comparison, Factory::deployVestingWallet includes the intended owner in the signed message:
Solidity
function deployVestingWallet(address _owner, VestingWalletInfo calldata vestingWalletInfo, bytes calldata signature)

That pattern prevents this class of problem for vesting wallets, but it is not applied to AccessToken. During AccessToken::initialize the owner is set as _initializeOwner(_params.creator), which the user submitting the signed data does not control.

  1. _pay sends ETH with safeTransferETH, whose low-level call(gas(), ...) forwards all available gas to the recipient. The stricter forceSafeTransferETH, which uses a gas stipend, exists in the same library but was not used.

The researcher argues this is not simply user error. The user only interacts with Belong's AccessToken code, the code assumes creators are benign, and the user has no control over interactions with the creator address during payment flows. AccessToken still works as an access pass (NFT minting), but the payment logic lets a malicious creator run arbitrary actions unrelated to minting that impose extra gas costs on the caller.

What the attacker gains

A malicious creator, or a referrer that is not controlled by the protocol, can abuse the payment logic to steal gas by running extra arbitrary logic in its fallback or receive while receiving ETH. The unsuspecting buyer pays for the extra gas. The listed impacts are:

  • Theft of gas: the attacker causes the buyer to spend more gas than necessary.
  • Griefing: the attacker causes damage without direct monetary profit.

The report severity is Medium, and the impacts are listed as theft of gas and griefing with no profit motive required.

The fix

The recommended mitigation is to replace the safeTransferETH calls with the stricter forceSafeTransferETH from the same SafeTransferLib.sol, which uses a gas stipend to limit forwarded gas and mitigate this class of gas-stealing attack. The report suggests nothing beyond using a gas-stipend-limited transfer to protocol-controlled addresses, and ensuring referral and creator addresses are validated or controlled by the protocol where appropriate. The report does not state that any change was made.

Other places to look

  1. Other payment paths that use safeTransferETH, or any low-level call(gas(), ...), to an address supplied by a user or creator. A positive result is a recipient contract whose receive consumes gas and the caller's transaction cost rising accordingly.
  2. Referral flows where the referrer address is not controlled by the protocol. A positive result is the same gas inflation on the referral share.
  3. Factory deployment functions whose signed message omits the intended owner, as Factory::produce does here. A positive result is deploying an instance from a different address than the one that obtained the signature, with the deployer becoming owner.
  4. Comparisons with sibling deployment functions such as Factory::deployVestingWallet, which includes _owner in the signed message, to find functions that do not follow the same pattern.

How to hunt for this yourself

This kind of bug hides in payment distribution code: internal helpers such as _pay that fan out ETH to several recipients, and library wrappers around low-level calls. The signal during review is a call(gas(), ...) in assembly, or a safeTransferETH-style helper, reaching an address that a third party controls, combined with a deployment path that does not bind the signed data to the deployer. The PoC steps are to deploy through Factory::produce from a contract with a malicious receive, have a buyer mint, and log starting gas, remaining gas and gas consumed by the malicious interaction, with a runnable Foundry PoC and stack trace supplied privately. The report also argues against the user-error objection, noting that the signed message omits the intended owner and that the victim has no control over the creator address during payment.

Glossary

  • Access pass: a digital token (NFT) that proves the holder is allowed into something.
  • NFT: a non-fungible token, a unique digital item recorded on a blockchain.
  • Smart contract: code deployed on a blockchain that runs automatically when called.
  • ETH: the cryptocurrency of the Ethereum network.
  • Gas: the unit that measures computing effort on Ethereum; the transaction sender pays for every unit used.
  • Gas theft: making someone else's transaction consume more gas than necessary, so they pay more.
  • Griefing: causing harm to another user without making a direct profit.
  • AccessToken: the Belong contract that handles access passes and mint payments.
  • Factory: the contract that deploys AccessToken instances.
  • Factory::produce: the deployment function; it does not check who calls it.
  • Signer: the trusted key that signs NFT data so it can be deployed.
  • Signature: cryptographic proof that a particular key approved a particular message.
  • contractURI: a link to the collection's metadata.
  • feeNumerator: a royalty setting included in the signed message.
  • Creator: the address that receives the creator's share of each mint payment.
  • Referrer: an optional address that receives a referral share when a referral code was used.
  • Referral code: a code stored on the token that routes part of the fees to a referrer.
  • Buyer: the person paying ETH and receiving the NFT.
  • mintStaticPrice / mintDynamicPrice: the public functions that let a buyer mint an NFT by paying ETH.
  • _pay: the internal helper that splits the payment between platform, referrer and creator.
  • SafeTransferLib: a library of helpers for moving tokens and ETH safely.
  • safeTransferETH: the helper used here; it forwards all remaining gas to the recipient.
  • forceSafeTransferETH: a stricter helper in the same library that uses a gas stipend.
  • Gas stipend: a small fixed allowance of gas given to a recipient, instead of everything that is left.
  • Low-level call: a raw EVM instruction that sends a message to an address, bypassing Solidity's usual checks.
  • call(gas(), ...): a low-level call that passes all remaining gas to the recipient.
  • receive: the special function a contract runs when it is sent plain ETH.
  • fallback: the catch-all function a contract runs when called with data it does not recognise.
  • msg.value: the amount of ETH attached to the current call.
  • unchecked: a Solidity block where overflow and underflow checks are skipped.
  • require: a Solidity statement that reverts the transaction if a condition is false.
  • Revert: cancelling a transaction and undoing its effects.
  • Inline assembly: raw EVM instructions written inside Solidity code.
  • initialize: the function that sets up a newly deployed contract's state, including its owner.
  • Owner: the address with special rights over a deployed contract.
  • Vesting wallet: a contract that releases funds to an owner over time.
  • Foundry: a toolkit for writing and running tests against Ethereum contracts.
  • PoC (proof of concept): runnable code that demonstrates an attack works.
  • Stack trace: a record of the sequence of calls that led to a result.
  • Gist: a small code-sharing page.
  • Immunefi: the bug bounty and audit competition platform hosting this report.
  • Triager: the person who reviews a submitted report and decides whether it is valid.
  • Severity: the rating given to a finding, here Medium.

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.