Skip to content
Business logic Audit finding Intermediate

Long tokens will be stuck in the escrow if customers exclusively use usdc payments in paytovenue

Venue-deposited LONG tokens sit in an escrow and are only paid out as subsidies when customers pay in LONG; if every customer pays in USDC that payout path never runs. The reporter claims venues then have no way to withdraw their LONG, so the funds could be permanently locked.

Belong

Originally disclosed on Immunefi

Informational View original

57892 sc insight long tokens will be stuck in the escrow if customers exclusively use usdc payments in paytovenue

Description

Brief / Intro

In the BelongCheckIn contract, venue-deposited LONG tokens are held in an Escrow and primarily disbursed as subsidies during customer LONG payments (via payToVenue with paymentInUSDC = false). If all customers exclusively pay in USDC (paymentInUSDC = true), subsidy distributions never occur, leaving LONG funds in the Escrow without a direct redemption mechanism for venues. This can result in LONG deposits being permanently locked, as there are no functions allowing venues to withdraw LONG balances or otherwise redeem unused LONG.

Vulnerability Details

LONG deposits (recorded in Escrow as longDeposits) are only disbursed via distributeLONGDiscount, which is exclusively called in the LONG payment path of payToVenue to provide subsidies (subsidyMinusFees). If customers always choose USDC payments, this path is never triggered, and no LONG outflows occur. The contract lacks any venue-direct withdrawal, burn-to-redeem, or timed release for unused LONG.

Impact Details

Venue owners may be unable to access deposited LONG, leading to locked LONG funds.

{% hint style="warning" %} Permanent freezing of funds: deposited LONG can become permanently inaccessible to venue owners if the contract never invokes the LONG-distribution path. {% endhint %}

References

Proof of Concept

Save the following test into file.test.ts and run:

yarn test test/v2/platform/file.test.ts

TS
import { ethers } from 'hardhat';
import { BigNumber } from 'ethers';
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
import EthCrypto from 'eth-crypto';
import {
  AccessToken,
  CreditToken,
  Escrow,
  Factory,
  Helper,
  MockTransferValidatorV2,
  RoyaltiesReceiverV2,
  SignatureVerifier,
  Staking,
  BelongCheckIn,
  VestingWalletExtended,
} from '../../../typechain-types';
import {
  deployCreditTokens,
  deployAccessTokenImplementation,
  deployCreditTokenImplementation,
  deployFactory,
  deployRoyaltiesReceiverV2Implementation,
  deployStaking,
  deployBelongCheckIn,
  deployEscrow,
  deployVestingWalletImplementation,
} from '../../../helpers/deployFixtures';
import { getSignerFromAddress, getToken, startSimulateMainnet, stopSimulate } from '../../../helpers/fork';
import { deployHelper, deploySignatureVerifier } from '../../../helpers/deployLibraries';
import { deployMockTransferValidatorV2, deployPriceFeeds } from '../../../helpers/deployMockFixtures';
import { expect } from 'chai';
import {
  CustomerInfoStruct,
  PromoterInfoStruct,
  VenueInfoStruct,
  VenueRulesStruct,
} from '../../../typechain-types/contracts/v2/platform/BelongCheckIn';
import { U, u } from '../../../helpers/math';

describe('BelongCheckIn ETH Uniswap', () => {
  const chainId = 31337;

  const WETH_ADDRESS = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
  const USDC_ADDRESS = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
  const ENA_ADDRESS = '0x57e114B691Db790C35207b2e685D4A43181e6061'; //used instead of LONG

  const USDC_WHALE_ADDRESS = '0x8EB8a3b98659Cce290402893d0123abb75E3ab28';
  const WETH_WHALE_ADDRESS = '0x57757E3D981446D585Af0D9Ae4d7DF6D64647806';
  const ENA_WHALE_ADDRESS = '0xF977814e90dA44bFA03b6295A0616a897441aceC';

  const UNISWAP_FACTORY_ADDRESS = '0x1F98431c8aD98523631AE4a59f267346ea31F984';
  const UNISWAP_ROUTER_ADDRESS = '0xE592427A0AEce92De3Edee1F18E0157C05861564';
  const UNISWAP_QUOTER_ADDRESS = '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6';
  const POOL_FEE = 3000;
  const MAX_PRICEFEED_DELAY = 3600;

  const usdcPercentage = 2000;
  const convenienceFeeAmount = U(5, 6); // $5

  const paymentsInfo: BelongCheckIn.PaymentsInfoStruct = {
    swapPoolFees: POOL_FEE,
    slippageBps: BigNumber.from(10).pow(27).sub(1),
    swapV3Factory: UNISWAP_FACTORY_ADDRESS,
    swapV3Router: UNISWAP_ROUTER_ADDRESS,
    swapV3Quoter: UNISWAP_QUOTER_ADDRESS,
    wNativeCurrency: WETH_ADDRESS,
    usdc: USDC_ADDRESS,
    long: ENA_ADDRESS,
    maxPriceFeedDelay: MAX_PRICEFEED_DELAY,
  };

  const stakingRewards: [
    BelongCheckIn.RewardsInfoStruct,
    BelongCheckIn.RewardsInfoStruct,
    BelongCheckIn.RewardsInfoStruct,
    BelongCheckIn.RewardsInfoStruct,
    BelongCheckIn.RewardsInfoStruct,
  ] = [
    {
      venueStakingInfo: {
        depositFeePercentage: 1000,
        convenienceFeeAmount,
      } as BelongCheckIn.VenueStakingRewardInfoStruct,
      promoterStakingInfo: {
        usdcPercentage,
        longPercentage: 800,
      } as BelongCheckIn.PromoterStakingRewardInfoStruct,
    } as BelongCheckIn.RewardsInfoStruct,
    {
      venueStakingInfo: {
        depositFeePercentage: 900,
        convenienceFeeAmount,
      } as BelongCheckIn.VenueStakingRewardInfoStruct,
      promoterStakingInfo: {
        usdcPercentage,
        longPercentage: 700,
      } as BelongCheckIn.PromoterStakingRewardInfoStruct,
    } as BelongCheckIn.RewardsInfoStruct,
    {
      venueStakingInfo: {
        depositFeePercentage: 800,
        convenienceFeeAmount,
      } as BelongCheckIn.VenueStakingRewardInfoStruct,
      promoterStakingInfo: {
        usdcPercentage,
        longPercentage: 600,
      } as BelongCheckIn.PromoterStakingRewardInfoStruct,
    } as BelongCheckIn.RewardsInfoStruct,
    {
      venueStakingInfo: {
        depositFeePercentage: 700,
        convenienceFeeAmount,
      } as BelongCheckIn.VenueStakingRewardInfoStruct,
      promoterStakingInfo: {
        usdcPercentage,
        longPercentage: 500,
      } as BelongCheckIn.PromoterStakingRewardInfoStruct,
    } as BelongCheckIn.RewardsInfoStruct,
    {
      venueStakingInfo: {
        depositFeePercentage: 500,
        convenienceFeeAmount,
      } as BelongCheckIn.VenueStakingRewardInfoStruct,
      promoterStakingInfo: {
        usdcPercentage,
        longPercentage: 400,
      } as BelongCheckIn.PromoterStakingRewardInfoStruct,
    } as BelongCheckIn.RewardsInfoStruct,
  ];
  const fees: BelongCheckIn.FeesStruct = {
    referralCreditsAmount: 3,
    affiliatePercentage: 1000,
    longCustomerDiscountPercentage: 300,
    platformSubsidyPercentage: 300,
    processingFeePercentage: 250,
    buybackBurnPercentage: 5000,
  };
  let implementations: Factory.ImplementationsStruct, contracts: BelongCheckIn.ContractsStruct;

  before(startSimulateMainnet);
  after(stopSimulate);

  async function fixture() {
    const [admin, treasury, manager, minter, burner, pauser, referral] = await ethers.getSigners();
    const signer = EthCrypto.createIdentity();

    const WETH_whale = await getSignerFromAddress(WETH_WHALE_ADDRESS);
    const USDC_whale = await getSignerFromAddress(USDC_WHALE_ADDRESS);
    const ENA_whale = await getSignerFromAddress(ENA_WHALE_ADDRESS);
    const WETH = await getToken(WETH_ADDRESS);
    const USDC = await getToken(USDC_ADDRESS);
    const ENA = await getToken(ENA_ADDRESS);

    const signatureVerifier: SignatureVerifier = await deploySignatureVerifier();
    const validator: MockTransferValidatorV2 = await deployMockTransferValidatorV2();
    const accessTokenImplementation: AccessToken = await deployAccessTokenImplementation(signatureVerifier.address);
    const royaltiesReceiverV2Implementation: RoyaltiesReceiverV2 = await deployRoyaltiesReceiverV2Implementation();
    const creditTokenImplementation: CreditToken = await deployCreditTokenImplementation();
    const vestingWallet: VestingWalletExtended = await deployVestingWalletImplementation();

    const treasuryUsdcBalance = await USDC.balanceOf(treasury.address);
    if (!treasuryUsdcBalance.isZero()) {
      await USDC.connect(treasury).transfer(USDC_whale.address, treasuryUsdcBalance);
    }

    implementations = {
      accessToken: accessTokenImplementation.address,
      creditToken: creditTokenImplementation.address,
      royaltiesReceiver: royaltiesReceiverV2Implementation.address,
      vestingWallet: vestingWallet.address,
    };

    const factory: Factory = await deployFactory(
      treasury.address,
      signer.address,
      signatureVerifier.address,
      validator.address,
      implementations,
    );

    const helper: Helper = await deployHelper();
    const staking: Staking = await deployStaking(admin.address, treasury.address, ENA_ADDRESS);

    const referralCode = EthCrypto.hash.keccak256([
      { type: 'address', value: referral.address },
      { type: 'address', value: factory.address },
      { type: 'uint256', value: chainId },
    ]);

    await factory.connect(referral).createReferralCode();

    const belongCheckIn: BelongCheckIn = await deployBelongCheckIn(
      signatureVerifier.address,
      helper.address,
      admin.address,
      paymentsInfo,
    );

    const escrow: Escrow = await deployEscrow(belongCheckIn.address);
    const { pf1, pf2, pf2_2, pf2_3, pf3 } = await deployPriceFeeds();
    const { venueToken, promoterToken } = await deployCreditTokens(
      true,
      false,
      factory.address,
      signer.privateKey,
      admin,
      manager.address,
      belongCheckIn.address,
      belongCheckIn.address,
    );

    contracts = {
      factory: factory.address,
      escrow: escrow.address,
      staking: staking.address,
      venueToken: venueToken.address,
      promoterToken: promoterToken.address,
      longPF: pf1.address,
    };

    await belongCheckIn.setContracts(contracts);

    return {
      signatureVerifier,
      helper,
      factory,
      staking,
      venueToken,
      promoterToken,
      belongCheckIn,
      escrow,
      pf1,
      pf2,
      pf2_2,
      pf2_3,
      pf3,
      admin,
      treasury,
      manager,
      minter,
      burner,
      pauser,
      referral,
      signer,
      referralCode,
      WETH,
      USDC,
      ENA,
      WETH_whale,
      USDC_whale,
      ENA_whale,
    };
  }

  describe('Funds Stuck', () => {
    it('payToVenue() (w/o promoter)', async () => {
      const { belongCheckIn, signer, USDC, USDC_whale, ENA_whale, escrow, ENA } = await loadFixture(fixture);

      const uri = 'uriuri';
      const venueAmount = await u(100, USDC);
      const venue = USDC_whale.address;
      const venueMessage = ethers.utils.solidityKeccak256(
        ['address', 'bytes32', 'string', 'uint256'],
        [venue, ethers.constants.HashZero, uri, chainId],
      );
      const venueSignature = EthCrypto.sign(signer.privateKey, venueMessage);
      const venueInfo: VenueInfoStruct = {
        rules: { paymentType: 1, bountyType: 0, longPaymentType: 0 } as VenueRulesStruct,
        venue,
        amount: venueAmount,
        referralCode: ethers.constants.HashZero,
        uri,
        signature: venueSignature,
      };
      const willBeTaken = convenienceFeeAmount.add(venueAmount);
      await USDC.connect(USDC_whale).approve(belongCheckIn.address, willBeTaken);
      await belongCheckIn.connect(USDC_whale).venueDeposit(venueInfo);

      const customerAmount = await u(5, USDC);
      const customerMessage = ethers.utils.solidityKeccak256(
        ['bool', 'uint128', 'uint24', 'address', 'address', 'address', 'uint256', 'uint256'],
        [
          true, // paymentInUSDC
          0, // visitBountyAmount (uint24, adjust to uint256 if needed)
          0, // spendBountyPercentage (uint24, adjust to uint256 if needed)
          ENA_whale.address, // customer
          USDC_whale.address, // venueToPayFor
          ethers.constants.AddressZero, // promoter
          customerAmount, // amount
          chainId, // block.chainid
        ],
      );
      const customerSignature = EthCrypto.sign(signer.privateKey, customerMessage);
      const customerInfo: CustomerInfoStruct = {
        paymentInUSDC: true,
        visitBountyAmount: 0,
        spendBountyPercentage: 0,
        customer: ENA_whale.address,
        venueToPayFor: USDC_whale.address,
        promoter: ethers.constants.AddressZero,
        amount: customerAmount,
        signature: customerSignature,
      };

      await USDC.connect(USDC_whale).transfer(ENA_whale.address, customerAmount);
      await USDC.connect(ENA_whale).approve(belongCheckIn.address, customerAmount);

      const tx = await belongCheckIn.connect(ENA_whale).payToVenue(customerInfo);

      const venueBalance_escrow = await ENA.balanceOf(escrow.address);

      console.log('venueBalance_escrow', venueBalance_escrow);

      // No function to withdraw long funds by venue owner
    });
  });
});

Example test output (shows LONG tokens remain in Escrow):

venueBalance_escrow BigNumber { value: "7957086772067060989" }
      ✔ payToVenue() (w/o promoter) (2096ms)
  1 passing (6s)

Notes / Next steps

  • The contract should provide a path for venues to reclaim LONG tokens that were deposited into Escrow but never distributed (for example: a venue-withdraw function, burn-to-redeem, owner-triggered distribution, or a timed/unclaimed-release mechanism).
  • Any proposed fix should preserve intended subsidy mechanics while ensuring deposited LONG cannot be permanently locked when customers exclusively pay in USDC.

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. 6 min read.

Context

Belong is a platform whose smart contracts handle venue check-ins and payments. The target of this report is BelongCheckIn.sol, specifically the payToVenue flow and the escrow that sits behind it.

Venues deposit LONG tokens into an Escrow contract. Those deposits are recorded as longDeposits. The intended use of the deposited LONG is to fund subsidies during customer payments: when a customer pays in LONG (the paymentInUSDC = false path of payToVenue), the contract calls distributeLONGDiscount, which pays out a subsidy amount (subsidyMinusFees) from the escrowed LONG.

The report is filed as a Smart Contract Insight with the impact "Permanent freezing of funds". The vulnerable code is referenced at line 421 of the contract:

Text
https://github.com/immunefi-team/audit-comp-belong/blob/main/contracts/v2/platform/BelongCheckIn.sol#L421

Setup

The proof of concept is a Hardhat test written in TypeScript. It runs against a mainnet fork (startSimulateMainnet / stopSimulate from the project's fork helpers) with chainId = 31337, and uses the project's own deploy fixtures and typechain types.

Because the test needs real token balances, it impersonates three mainnet whales:

Role Address used in the test
USDC whale (also the venue) [redacted]
WETH whale [redacted]
ENA whale (also the customer) [redacted]

ENA is used in place of LONG (//used instead of LONG), and the test wires the Uniswap V3 factory, router and quoter addresses into the payments configuration:

TS
const WETH_ADDRESS = '[redacted]';
const USDC_ADDRESS = '[redacted]';
const ENA_ADDRESS = '[redacted]'; //used instead of LONG

const USDC_WHALE_ADDRESS = '[redacted]';
const WETH_WHALE_ADDRESS = '[redacted]';
const ENA_WHALE_ADDRESS = '[redacted]';

const UNISWAP_FACTORY_ADDRESS = '[redacted]';
const UNISWAP_ROUTER_ADDRESS = '[redacted]';
const UNISWAP_QUOTER_ADDRESS = '[redacted]';
const POOL_FEE = 3000;
const MAX_PRICEFEED_DELAY = 3600;

The fixture deploys the full stack: signature verifier, mock transfer validator, access token, royalties receiver, credit token, vesting wallet, factory, helper, staking, BelongCheckIn, escrow, price feeds and the venue and promoter credit tokens. It then registers the contract addresses on BelongCheckIn with setContracts. The staking reward tiers and fee configuration are set up as follows:

TS
const usdcPercentage = 2000;
const convenienceFeeAmount = U(5, 6); // $5

const paymentsInfo: BelongCheckIn.PaymentsInfoStruct = {
  swapPoolFees: POOL_FEE,
  slippageBps: BigNumber.from(10).pow(27).sub(1),
  swapV3Factory: UNISWAP_FACTORY_ADDRESS,
  swapV3Router: UNISWAP_ROUTER_ADDRESS,
  swapV3Quoter: UNISWAP_QUOTER_ADDRESS,
  wNativeCurrency: WETH_ADDRESS,
  usdc: USDC_ADDRESS,
  long: ENA_ADDRESS,
  maxPriceFeedDelay: MAX_PRICEFEED_DELAY,
};
TS
const fees: BelongCheckIn.FeesStruct = {
  referralCreditsAmount: 3,
  affiliatePercentage: 1000,
  longCustomerDiscountPercentage: 300,
  platformSubsidyPercentage: 300,
  processingFeePercentage: 250,
  buybackBurnPercentage: 5000,
};

The staking rewards array defines five tiers, each with a venue deposit fee percentage (1000, 900, 800, 700, 500), the same convenienceFeeAmount, and promoter splits of usdcPercentage 2000 with longPercentage 800, 700, 600, 500 and 400 respectively.

Finding it

The report states where escrowed LONG can leave the contract. The only outflow is distributeLONGDiscount, and that function is called exclusively from the LONG payment path of payToVenue. If every customer chooses USDC (paymentInUSDC = true), that path is never taken, so no LONG ever leaves the escrow.

The contract has no venue-direct withdrawal, no burn-to-redeem and no timed release for unused LONG. A venue that has deposited LONG therefore has no route to get it back if the LONG payment path is never exercised. The researcher's comment in the test states the point directly:

TS
// No function to withdraw long funds by venue owner

Exploitation

This is a design-level finding rather than an attack: no adversary is needed. The condition is simply that customers pay in USDC only.

Step 1: Create the test file and run it

Save the test as file.test.ts and run it with:

Bash
yarn test test/v2/platform/file.test.ts

Step 2: Venue deposits USDC and the deposit is recorded

The venue is the USDC whale. It signs a venue message over the venue address, a zero referral hash, the URI and the chain ID, then calls venueDeposit with paymentType: 1:

TS
const uri = 'uriuri';
const venueAmount = await u(100, USDC);
const venue = USDC_whale.address;
const venueMessage = ethers.utils.solidityKeccak256(
  ['address', 'bytes32', 'string', 'uint256'],
  [venue, ethers.constants.HashZero, uri, chainId],
);
const venueSignature = EthCrypto.sign(signer.privateKey, venueMessage);
const venueInfo: VenueInfoStruct = {
  rules: { paymentType: 1, bountyType: 0, longPaymentType: 0 } as VenueRulesStruct,
  venue,
  amount: venueAmount,
  referralCode: ethers.constants.HashZero,
  uri,
  signature: venueSignature,
};
const willBeTaken = convenienceFeeAmount.add(venueAmount);
await USDC.connect(USDC_whale).approve(belongCheckIn.address, willBeTaken);
await belongCheckIn.connect(USDC_whale).venueDeposit(venueInfo);

The approval covers the venue amount plus the $5 convenience fee (U(5, 6)).

Step 3: Customer pays in USDC

The customer is the ENA whale. The signed customer message encodes paymentInUSDC = true, zero visit bounty, zero spend bounty percentage, the customer address, the venue to pay for, a zero promoter address, the amount and the chain ID:

TS
const customerAmount = await u(5, USDC);
const customerMessage = ethers.utils.solidityKeccak256(
  ['bool', 'uint128', 'uint24', 'address', 'address', 'address', 'uint256', 'uint256'],
  [
    true, // paymentInUSDC
    0, // visitBountyAmount (uint24, adjust to uint256 if needed)
    0, // spendBountyPercentage (uint24, adjust to uint256 if needed)
    ENA_whale.address, // customer
    USDC_whale.address, // venueToPayFor
    ethers.constants.AddressZero, // promoter
    customerAmount, // amount
    chainId, // block.chainid
  ],
);
const customerSignature = EthCrypto.sign(signer.privateKey, customerMessage);
const customerInfo: CustomerInfoStruct = {
  paymentInUSDC: true,
  visitBountyAmount: 0,
  spendBountyPercentage: 0,
  customer: ENA_whale.address,
  venueToPayFor: USDC_whale.address,
  promoter: ethers.constants.AddressZero,
  amount: customerAmount,
  signature: customerSignature,
};

await USDC.connect(USDC_whale).transfer(ENA_whale.address, customerAmount);
await USDC.connect(ENA_whale).approve(belongCheckIn.address, customerAmount);

const tx = await belongCheckIn.connect(ENA_whale).payToVenue(customerInfo);

The customer is funded with USDC from the venue, approves the contract, and calls payToVenue. Because paymentInUSDC is true, the LONG subsidy path is not taken.

Step 4: Observe the escrow balance

The test reads the LONG (ENA) balance held by the escrow after the payment:

TS
const venueBalance_escrow = await ENA.balanceOf(escrow.address);

console.log('venueBalance_escrow', venueBalance_escrow);

The output confirms that LONG remains in the escrow:

Text
venueBalance_escrow BigNumber { value: "7957086772067060989" }
      ✔ payToVenue() (w/o promoter) (2096ms)
  1 passing (6s)

That balance has no withdrawal path for the venue owner.

Root cause

LONG deposits are tracked in the escrow as longDeposits, but the only function that moves LONG out is distributeLONGDiscount, and it is called only from the LONG branch of payToVenue. The contract offers no venue-direct withdrawal, no burn-to-redeem and no timed release for unused LONG. If the LONG payment path is never exercised, the escrowed LONG is stranded. There is no other exit function to reach.

Impact

Venue owners may be unable to access deposited LONG, which leads to locked LONG funds. The report frames this as permanent freezing of funds: deposited LONG can become permanently inaccessible to venue owners if the contract never invokes the LONG-distribution path. The condition is that customers exclusively use USDC payments in payToVenue.

Fix

The report recommends giving venues a path to reclaim LONG that was deposited into the escrow but never distributed. The suggested options are:

  1. A venue-withdraw function.
  2. A burn-to-redeem mechanism.
  3. An owner-triggered distribution.
  4. A timed or unclaimed-release mechanism.

Any fix should preserve the intended subsidy mechanics while ensuring deposited LONG cannot be permanently locked when customers pay only in USDC.

  1. Other escrow-backed subsidy tokens. Look for any token whose only outflow is a branch of a payment function. A positive result is a deposit that stays in the escrow after every payment path that does not touch that branch.
  2. Payment-method gating. Check whether a venue's deposit is only redeemable through a customer action. If a venue can deposit but only customers can trigger the outflow, the same stranding applies whenever customer behaviour changes.
  3. Missing exit functions. Enumerate every function that transfers each token out of the escrow. If a token has exactly one outflow and it is conditional, treat it as a candidate.
  4. Timed release absence. Confirm there is no fallback release after a delay. A positive result is a balance that remains unchanged across many blocks with no callable withdrawal.

This kind of bug hides in escrow and deposit contracts where funds enter through one function and leave through a different, conditional function. During recon, map every token balance the contract can hold and trace each one to its outflow. A token with a single conditional outflow is the signal.

The researcher's fork test deposits, performs a USDC-only payment, and prints the escrow's LONG balance, which remains. The report frames the remaining balance and the absence of an exit path as a risk of permanent freezing.

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. 16 min read.

What happened, in plain words

Belong is a platform whose smart contracts handle check-ins and payments at venues (think of a venue as a shop, bar or event space that accepts payments through Belong). The report looks at one contract, BelongCheckIn.sol, and in particular at the function payToVenue, which is the part of the contract that pays a venue when a customer makes a payment.

A contract, in this context, is a small program that lives on a blockchain. A blockchain is a shared ledger that many computers keep copies of, and a smart contract is code on that ledger that runs automatically when someone calls one of its functions. Nobody can quietly change the code after it is deployed, and the code can hold and move digital tokens. A token is a unit of value recorded on the blockchain, similar to a currency inside that system.

Belong uses two kinds of token here:

  • USDC, a token designed to be worth one US dollar each.
  • LONG, the platform's own token.

Venues put LONG tokens into a holding area called an Escrow. An escrow is like a locked safe that a program controls: money goes in, and only specific functions in the code can take it out. The contract records these deposits under the name longDeposits.

The intended purpose of the deposited LONG is to pay subsidies. A subsidy is a discount or bonus that the platform covers on the customer's behalf. When a customer pays in LONG (the path where paymentInUSDC = false), the contract calls a function called distributeLONGDiscount, which pays out a subsidy amount called subsidyMinusFees from the LONG held in escrow.

The problem the researcher found is simple to state: that subsidy payout is the only way LONG ever leaves the escrow. If every customer chooses to pay in USDC instead (paymentInUSDC = true), the LONG payment path is never used, so no LONG ever leaves. And the contract has no other function that lets a venue take its LONG back. There is no direct withdrawal, no "burn to redeem" (destroying a token in exchange for getting the underlying value back) and no timed release (an automatic return after a set period).

The report is filed as a Smart Contract Insight with the impact "Permanent freezing of funds". "Insight" means the researcher is pointing out a design weakness rather than demonstrating an attacker stealing something. "Permanent freezing of funds" means tokens become stuck forever with no way to move them. The vulnerable code is referenced at line 421 of the contract:

Text
https://github.com/immunefi-team/audit-comp-belong/blob/main/contracts/v2/platform/BelongCheckIn.sol#L421

That link points to the exact line in the public source code on GitHub, so anyone can read the code being discussed.

Setting up the test

The proof of concept is a Hardhat test written in TypeScript. Hardhat is a development tool that lets you run a copy of a blockchain on your own computer, so you can try contract behaviour without spending real money. TypeScript is a programming language built on top of JavaScript, which is the language web pages use.

The test runs against a mainnet fork. A fork is a copy of the real Ethereum blockchain's state at a chosen moment, running locally. It behaves as if all the real accounts and token balances exist, which is useful because you can borrow balances from real holders instead of inventing them. The test starts and stops this simulation with startSimulateMainnet and stopSimulate from the project's fork helpers, and uses chainId = 31337. A chain ID is a number that identifies which blockchain you are talking to; 31337 is the conventional ID for a local test chain.

Because the test needs real token balances, it impersonates three mainnet whales. A whale is an address that holds a very large amount of a token. Impersonating means telling the local test chain "treat this address as if I control it", so the test can move tokens from it without knowing its private key. A private key is the secret that proves ownership of an address.

Role Address used in the test
USDC whale (also the venue) [redacted]
WETH whale [redacted]
ENA whale (also the customer) [redacted]

ENA is used in place of LONG (//used instead of LONG). ENA is a real token that exists on mainnet, so using it lets the test work with a genuine token contract rather than a fake one. The test also wires the Uniswap V3 factory, router and quoter addresses into the payments configuration. Uniswap is a decentralised exchange, a service that swaps one token for another; the factory creates trading pools, the router executes swaps, and the quoter estimates how much a swap would return.

TS
const WETH_ADDRESS = '[redacted]';
const USDC_ADDRESS = '[redacted]';
const ENA_ADDRESS = '[redacted]'; //used instead of LONG

const USDC_WHALE_ADDRESS = '[redacted]';
const WETH_WHALE_ADDRESS = '[redacted]';
const ENA_WHALE_ADDRESS = '[redacted]';

const UNISWAP_FACTORY_ADDRESS = '[redacted]';
const UNISWAP_ROUTER_ADDRESS = '[redacted]';
const UNISWAP_QUOTER_ADDRESS = '[redacted]';
const POOL_FEE = 3000;
const MAX_PRICEFEED_DELAY = 3600;

Line by line:

  • WETH_ADDRESS is the address of Wrapped Ether, a token that represents Ether one-for-one and behaves like any other token. The contract needs it because swaps on Uniswap go through WETH.
  • USDC_ADDRESS is the address of the USDC token contract.
  • ENA_ADDRESS is the address of the ENA token, used here as a stand-in for LONG.
  • The three WHALE constants are the addresses the test impersonates to get token balances.
  • UNISWAP_FACTORY_ADDRESS, UNISWAP_ROUTER_ADDRESS and UNISWAP_QUOTER_ADDRESS are the three Uniswap contracts the payment logic uses.
  • POOL_FEE = 3000 is the fee tier of the Uniswap pool, expressed in hundredths of a basis point; 3000 corresponds to the 0.3% pool.
  • MAX_PRICEFEED_DELAY = 3600 is the maximum age, in seconds, that a price feed answer is accepted. A price feed is an on-chain service that reports the current price of an asset.

The fixture (a setup function that prepares a fresh state for each test) deploys the full stack: signature verifier, mock transfer validator, access token, royalties receiver, credit token, vesting wallet, factory, helper, staking, BelongCheckIn, escrow, price feeds and the venue and promoter credit tokens. A signature verifier checks that a message was signed by the right key; a mock is a simplified stand-in used in tests; a vesting wallet releases tokens gradually over time. It then registers the contract addresses on BelongCheckIn with setContracts, so the main contract knows where the other pieces live.

The staking reward tiers and fee configuration are set up as follows:

TS
const usdcPercentage = 2000;
const convenienceFeeAmount = U(5, 6); // $5

const paymentsInfo: BelongCheckIn.PaymentsInfoStruct = {
  swapPoolFees: POOL_FEE,
  slippageBps: BigNumber.from(10).pow(27).sub(1),
  swapV3Factory: UNISWAP_FACTORY_ADDRESS,
  swapV3Router: UNISWAP_ROUTER_ADDRESS,
  swapV3Quoter: UNISWAP_QUOTER_ADDRESS,
  wNativeCurrency: WETH_ADDRESS,
  usdc: USDC_ADDRESS,
  long: ENA_ADDRESS,
  maxPriceFeedDelay: MAX_PRICEFEED_DELAY,
};

Line by line:

  • usdcPercentage = 2000 is a percentage setting used in the promoter reward split. Percentages in these contracts are usually expressed in hundredths of a percent, so 2000 means 20%.
  • convenienceFeeAmount = U(5, 6) builds the number 5 with 6 decimal places, which is how USDC represents amounts. The comment says it is $5.
  • paymentsInfo is a bundle of settings the contract needs in order to handle payments: the Uniswap pool fee, the slippage tolerance, the three Uniswap addresses, the wrapped native currency, the USDC address, the LONG address and the maximum price feed delay.
  • slippageBps is the slippage tolerance in basis points. Slippage is how much worse a swap result may be than expected before the transaction is rejected. A basis point is one hundredth of a percent. The value here is 10^27 - 1, an extremely large number, which effectively disables the slippage check in the test.
TS
const fees: BelongCheckIn.FeesStruct = {
  referralCreditsAmount: 3,
  affiliatePercentage: 1000,
  longCustomerDiscountPercentage: 300,
  platformSubsidyPercentage: 300,
  processingFeePercentage: 250,
  buybackBurnPercentage: 5000,
};

Line by line:

  • referralCreditsAmount: 3 is how many credits a referral earns.
  • affiliatePercentage: 1000 is the affiliate share, 10% in hundredths of a percent.
  • longCustomerDiscountPercentage: 300 is the discount given to customers who pay in LONG, 3%.
  • platformSubsidyPercentage: 300 is the platform subsidy, 3%.
  • processingFeePercentage: 250 is the processing fee, 2.5%.
  • buybackBurnPercentage: 5000 is the share used for buyback and burn, 50%. Burning a token means sending it to an address nobody controls, which removes it from circulation permanently.

The staking rewards array defines five tiers, each with a venue deposit fee percentage (1000, 900, 800, 700, 500), the same convenienceFeeAmount, and promoter splits of usdcPercentage 2000 with longPercentage 800, 700, 600, 500 and 400 respectively. In plain terms, the more a venue stakes, the lower its deposit fee, and the promoter's reward is split between USDC and LONG in a ratio that changes per tier.

Finding it

The report states where escrowed LONG can leave the contract. Tracing means following every code path that could move a token out, the way you would follow every exit from a building. The only outflow is distributeLONGDiscount, and that function is called exclusively from the LONG payment path of payToVenue. If every customer chooses USDC (paymentInUSDC = true), that path is never taken, so no LONG ever leaves the escrow.

The contract has no venue-direct withdrawal, no burn-to-redeem and no timed release for unused LONG. A venue that has deposited LONG therefore has no route to get it back if the LONG payment path is never exercised. The researcher's comment in the test states the point directly:

TS
// No function to withdraw long funds by venue owner

That comment states the point directly: the venue owner has no function to call to get the LONG back.

Exploitation

This is a design-level finding rather than an attack: no adversary is needed. There is no attacker to stop, no password to guess and no trick to perform. The condition is simply that customers pay in USDC only. Think of a car park where the only exit barrier opens when a particular type of car arrives; if that type of car never comes, everyone inside stays inside, with no malice involved.

Step 1: Create the test file and run it

Save the test as file.test.ts and run it with:

Bash
yarn test test/v2/platform/file.test.ts

yarn is a package manager, a tool that downloads and runs the libraries a project depends on. yarn test runs the project's test command, and the path after it selects which test file to execute. Running the test reproduces the situation on the local fork so you can see the escrow balance for yourself.

Step 2: Venue deposits USDC and the deposit is recorded

The venue is the USDC whale. It signs a venue message over the venue address, a zero referral hash, the URI and the chain ID, then calls venueDeposit with paymentType: 1. Signing a message means producing a cryptographic proof that the holder of a private key approved that exact content; the contract checks the signature so nobody can submit a deposit on someone else's behalf. A URI is a text identifier for the venue, here the placeholder string uriuri.

TS
const uri = 'uriuri';
const venueAmount = await u(100, USDC);
const venue = USDC_whale.address;
const venueMessage = ethers.utils.solidityKeccak256(
  ['address', 'bytes32', 'string', 'uint256'],
  [venue, ethers.constants.HashZero, uri, chainId],
);
const venueSignature = EthCrypto.sign(signer.privateKey, venueMessage);
const venueInfo: VenueInfoStruct = {
  rules: { paymentType: 1, bountyType: 0, longPaymentType: 0 } as VenueRulesStruct,
  venue,
  amount: venueAmount,
  referralCode: ethers.constants.HashZero,
  uri,
  signature: venueSignature,
};
const willBeTaken = convenienceFeeAmount.add(venueAmount);
await USDC.connect(USDC_whale).approve(belongCheckIn.address, willBeTaken);
await belongCheckIn.connect(USDC_whale).venueDeposit(venueInfo);

Line by line:

  • uri = 'uriuri' is a placeholder identifier for the venue.
  • venueAmount = await u(100, USDC) converts 100 USDC into the token's smallest unit, so the contract receives an exact integer amount.
  • venue = USDC_whale.address sets the venue address to the impersonated whale.
  • venueMessage builds a hash of the venue address, a zero referral hash, the URI and the chain ID. A hash is a fixed-length fingerprint of some data; solidityKeccak256 is the hashing function used, and the first argument lists the types of the values in order.
  • venueSignature signs that hash with the test's signing key, proving the venue approved this deposit.
  • venueInfo packages the rules, venue address, amount, referral code, URI and signature into the structure the contract expects. paymentType: 1 selects the payment type for this venue.
  • willBeTaken adds the $5 convenience fee to the venue amount, so the approval covers everything that will be pulled from the venue's balance.
  • approve is the standard token permission step: it tells the USDC token contract that BelongCheckIn may move up to willBeTaken USDC from the venue. Without an approval, the contract cannot take the tokens.
  • venueDeposit(venueInfo) calls the deposit function, which pulls the USDC and records the venue's deposit.

Step 3: Customer pays in USDC

The customer is the ENA whale. The signed customer message encodes paymentInUSDC = true, zero visit bounty, zero spend bounty percentage, the customer address, the venue to pay for, a zero promoter address, the amount and the chain ID. A bounty here is a reward paid for a visit or for spending; both are set to zero so the test isolates the payment path. The promoter is the person or account that referred the customer; a zero address means no promoter is involved.

TS
const customerAmount = await u(5, USDC);
const customerMessage = ethers.utils.solidityKeccak256(
  ['bool', 'uint128', 'uint24', 'address', 'address', 'address', 'uint256', 'uint256'],
  [
    true, // paymentInUSDC
    0, // visitBountyAmount (uint24, adjust to uint256 if needed)
    0, // spendBountyPercentage (uint24, adjust to uint256 if needed)
    ENA_whale.address, // customer
    USDC_whale.address, // venueToPayFor
    ethers.constants.AddressZero, // promoter
    customerAmount, // amount
    chainId, // block.chainid
  ],
);
const customerSignature = EthCrypto.sign(signer.privateKey, customerMessage);
const customerInfo: CustomerInfoStruct = {
  paymentInUSDC: true,
  visitBountyAmount: 0,
  spendBountyPercentage: 0,
  customer: ENA_whale.address,
  venueToPayFor: USDC_whale.address,
  promoter: ethers.constants.AddressZero,
  amount: customerAmount,
  signature: customerSignature,
};

await USDC.connect(USDC_whale).transfer(ENA_whale.address, customerAmount);
await USDC.connect(ENA_whale).approve(belongCheckIn.address, customerAmount);

const tx = await belongCheckIn.connect(ENA_whale).payToVenue(customerInfo);

Line by line:

  • customerAmount = await u(5, USDC) is the payment amount, 5 USDC in the token's smallest unit.
  • customerMessage hashes the payment details in a fixed order: whether the payment is in USDC (true), the visit bounty, the spend bounty percentage, the customer address, the venue to pay, the promoter address, the amount and the chain ID. The type list in the first argument must match the values in the second argument exactly, or the hash will not match what the contract expects.
  • customerSignature signs the hash, proving the customer approved this payment.
  • customerInfo packages the same values plus the signature into the structure payToVenue expects. paymentInUSDC: true is the key setting: it selects the USDC path.
  • transfer sends USDC from the venue to the customer, so the customer has funds to pay with.
  • approve lets BelongCheckIn move the customer's USDC.
  • payToVenue(customerInfo) is the actual payment call. Because paymentInUSDC is true, the LONG subsidy path is not taken, and distributeLONGDiscount is never called.

Step 4: Observe the escrow balance

The test reads the LONG (ENA) balance held by the escrow after the payment:

TS
const venueBalance_escrow = await ENA.balanceOf(escrow.address);

console.log('venueBalance_escrow', venueBalance_escrow);

Line by line:

  • ENA.balanceOf(escrow.address) asks the ENA token contract how many ENA tokens the escrow address holds. This is a read-only call; it changes nothing.
  • console.log prints the result to the terminal so the test output shows the balance.

The output confirms that LONG remains in the escrow:

Text
venueBalance_escrow BigNumber { value: "7957086772067060989" }
      ✔ payToVenue() (w/o promoter) (2096ms)
  1 passing (6s)

BigNumber is a library for handling very large integers exactly, because JavaScript's normal numbers lose precision with big values. The value 7957086772067060989 is the amount of ENA, in the token's smallest unit, still sitting in the escrow after the USDC payment. The tick and 1 passing lines show the single test succeeded. That balance has no withdrawal path for the venue owner, which is the finding.

Root cause

LONG deposits are tracked in the escrow as longDeposits, but the only function that moves LONG out is distributeLONGDiscount, and it is called only from the LONG branch of payToVenue. The contract offers no venue-direct withdrawal, no burn-to-redeem and no timed release for unused LONG. If the LONG payment path is never exercised, the escrowed LONG is stranded. There is no other exit function to reach.

A useful comparison is a vending machine that only returns change when you buy a particular product. If nobody ever buys that product, the change inside stays there forever, even though the machine is working exactly as designed.

Impact

Venue owners may be unable to access deposited LONG, which leads to locked LONG funds. The report frames this as permanent freezing of funds: deposited LONG can become permanently inaccessible to venue owners if the contract never invokes the LONG-distribution path. The condition is that customers exclusively use USDC payments in payToVenue.

Fix

The report recommends giving venues a path to reclaim LONG that was deposited into the escrow but never distributed. The suggested options are:

  1. A venue-withdraw function.
  2. A burn-to-redeem mechanism.
  3. An owner-triggered distribution.
  4. A timed or unclaimed-release mechanism.

Any fix should preserve the intended subsidy mechanics while ensuring deposited LONG cannot be permanently locked when customers pay only in USDC. In everyday terms: keep the discount scheme working, but add a door out of the safe so the money cannot be trapped by a change in customer habits.

Variants to test

  1. Other escrow-backed subsidy tokens. Look for any token whose only outflow is a branch of a payment function. A positive result is a deposit that stays in the escrow after every payment path that does not touch that branch.
  2. Payment-method gating. Check whether a venue's deposit is only redeemable through a customer action. If a venue can deposit but only customers can trigger the outflow, the same stranding applies whenever customer behaviour changes.
  3. Missing exit functions. Enumerate every function that transfers each token out of the escrow. If a token has exactly one outflow and it is conditional, treat it as a candidate.
  4. Timed release absence. Confirm there is no fallback release after a delay. A positive result is a balance that remains unchanged across many blocks with no callable withdrawal.

This kind of bug hides in escrow and deposit contracts where funds enter through one function and leave through a different, conditional function. During recon (the early phase of exploring a target), map every token balance the contract can hold and trace each one to its outflow. A token with a single conditional outflow is the signal.

The researcher's fork test deposits, performs a USDC-only payment, and prints the escrow's LONG balance, which remains. The report frames the remaining balance and the absence of an exit path as a risk of permanent freezing.

Glossary

  • Smart contract: a program stored on a blockchain that runs automatically when its functions are called.
  • Blockchain: a shared ledger kept by many computers, where entries are hard to change after the fact.
  • Token: a unit of value recorded on a blockchain, such as USDC or LONG.
  • LONG: the Belong platform's own token.
  • Escrow: a holding area controlled by a contract, where funds go in and only specific functions can take them out.
  • Subsidy: a discount or bonus that the platform covers on the customer's behalf.
  • Insight: a report type that points out a design weakness rather than demonstrating an attack.
  • Permanent freezing of funds: a situation where tokens become stuck forever with no way to move them.
  • Hardhat: a development tool that runs a copy of a blockchain locally for testing.
  • TypeScript: a programming language built on top of JavaScript.
  • Mainnet fork: a local copy of the real blockchain's state at a chosen moment.
  • Chain ID: a number identifying which blockchain you are interacting with.
  • Whale: an address holding a very large amount of a token.
  • Impersonate: telling a local test chain to treat an address as controlled by the test.
  • Private key: the secret that proves ownership of a blockchain address.
  • Uniswap: a decentralised exchange that swaps one token for another.
  • Factory / router / quoter: Uniswap contracts that create pools, execute swaps and estimate swap results.
  • WETH: Wrapped Ether, a token that represents Ether one-for-one.
  • Price feed: an on-chain service that reports the current price of an asset.
  • Signature verifier: a contract that checks a message was signed by the right key.
  • Mock: a simplified stand-in used in tests.
  • Vesting wallet: a wallet that releases tokens gradually over time.
  • Fixture: a setup function that prepares a fresh state for each test.
  • Slippage: how much worse a swap result may be than expected before the transaction is rejected.
  • Basis point: one hundredth of a percent.
  • Burning: sending a token to an address nobody controls, removing it from circulation permanently.
  • Hash: a fixed-length fingerprint of some data.
  • BigNumber: a library for handling very large integers exactly.
  • Recon: the early phase of exploring a target before testing it.

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.