Missing produce name sanitization allows breaking snip 12 standard compliance
The NFT factory contract only checks that NFT names and symbols are non-empty, so a user can create tokens whose identifiers contain characters that SNIP-12 forbids. This can cause wallets, explorers and other StarkNet tooling that assume SNIP-12 compliance to display or parse the identifiers incorrectly.
- Disclosed after under an hour
57838 sc insight missing produce name sanitization allows breaking snip 12 standard compliance
Submitted on Oct 29th 2025 at 06:35:55 UTC by @Another for Audit Comp | Belong
- Report ID: #57838
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/immunefi-team/audit-comp-belong/blob/feat/cairo/src/nftfactory/nftfactory.cairohttps://github.com/immunefi-team/audit-comp-belong/blob/feat/cairo/src/nftfactory/nftfactory.cairo
Description
Brief/Intro
The NFTFactory contract does not properly sanitize user-provided NFT names and symbols, allowing malicious or malformed input that can break SNIP-12 compliance. This can lead to interoperability issues with wallets, explorers, and other StarkNet infrastructure that expect properly formatted token identifiers.
Vulnerability Details
The _produce function allows the user to provide the name and symbol for the NFT. The function only checks that names and symbols are non-empty but does not validate allowed characters. This enables creation of NFTs with names and symbols that are not SNIP-12 compliant.
Relevant snippet:
{% code title="nftfactory.cairo (excerpt)" %}
{% endcode %}
fn _produce(
ref self: ContractState, instance_info: InstanceInfo,
) -> (ContractAddress, ContractAddress) {
let info = instance_info.clone();
assert(info.name.len().is_non_zero(), super::Errors::EMPTY_NAME);
assert(info.symbol.len().is_non_zero(), super::Errors::EMPTY_SYMBOL);
let metadata_name_hash: felt252 = info.name.hash();
let metadata_symbol_hash: felt252 = info.symbol.hash();
let contract_uri_hash: felt252 = info.contract_uri.hash();
assert(
self
.nft_info
.entry((metadata_name_hash, metadata_symbol_hash))
.nft_address
.read()
.is_zero(),
super::Errors::NFT_EXISTS,
);
let message = ProduceHash {
name_hash: metadata_name_hash,
symbol_hash: metadata_symbol_hash,
contract_uri: contract_uri_hash,
royalty_fraction: info.royalty_fraction,
};
let hash = message.get_message_hash(get_contract_address());
let is_valid_signature_felt = ISRC6Dispatcher {
contract_address: self.factory_parameters.signer.read(),
}
(unchanged links and file paths preserved)
According to SNIP-12 (StarkNet Improvement Proposal 12), token identifiers should follow additional constraints beyond non-empty strings, for example:
- No empty name (already enforced)
- Name can't be enclosed in parentheses
- Name can't contain the comma (,) character (since it is used as a delimiter in the enum type)
- ...and other character/formatting restrictions defined by SNIP-12
Impact Details
A malicious user can create NFTs with names/symbols containing special or delimiter characters that break SNIP-12 assumptions. Consequences include:
- Interoperability issues with wallets, explorers, and other tooling expecting SNIP-12 compliant identifiers
- Display or parsing issues in frontends, potentially enabling UI/UX issues or spoofing/confusion
{% hint style="warning" %} The contract currently allows creation of tokens with problematic characters (beyond just non-empty checks). This can be weaponized to cause downstream issues across StarkNet tooling that assumes SNIP-12 compliance. {% endhint %}
References
- https://github.com/immunefi-team/audit-comp-belong/blob/a17f775dcc4c125704ce85d4e18b744daece65af/src/nftfactory/nftfactory.cairo#L251-L285
- https://github.com/starknet-io/SNIPs/blob/906b19074038005dc26d3574b6853a7c68d14e02/SNIPS/snip-12.md#type-identification
Proof of Concept
<details> <summary>Test demonstrating creation of NFT with special characters (add to test_nftfactory.cairo)</summary>#[test]
fn test_produce_with_special_characters() {
let account = deploy_account_mock();
let contract = deploy_initialize(account);
let erc20mock = deploy_erc20_mock();
let nft_factory = INFTFactoryDispatcher { contract_address: contract };
let problematic_name = ByteArray::from("Test\x***,NFT");
let problematic_symbol = ByteArray::from("T\x01\x02\x03");
let fraction = 0;
let produce_hash = ProduceHash {
name_hash: problematic_name.hash(),
symbol_hash: problematic_symbol.hash(),
contract_uri: constants::CONTRACT_URI().hash(),
royalty_fraction: fraction,
};
start_cheat_caller_address_global(account);
let signature = sign_message(produce_hash.get_message_hash(contract));
stop_cheat_caller_address_global();
let instance_info = InstanceInfo {
name: problematic_name,
symbol: problematic_symbol,
contract_uri: constants::CONTRACT_URI(),
payment_token: erc20mock,
royalty_fraction: fraction,
transferrable: true,
max_total_supply: constants::MAX_TOTAL_SUPPLY(),
mint_price: constants::MINT_PRICE(),
whitelisted_mint_price: constants::WL_MINT_PRICE(),
collection_expires: constants::EXPIRES(),
referral_code: '',
signature,
};
start_cheat_caller_address(contract, constants::CREATOR());
// This should work currently, demonstrating the vulnerability
let (nft, receiver) = nft_factory.produce(instance_info);
// Verify the NFT was created with problematic characters
let nft_info = nft_factory.nftInfo(problematic_name, problematic_symbol);
assert_eq!(nft_info.nft_address, nft);
}
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 _produce function validates only that the name and symbol are non-empty and never checks them against SNIP-12 character restrictions.
Impact
NFTs with non-compliant identifiers could cause display or parsing problems in wallets, explorers and frontends, potentially leading to user confusion or spoofing, though the report does not demonstrate a concrete exploit.
What the attacker needed
Ability to call the produce function; a valid signature from the signer
The fix
The contract should reject names and symbols that contain characters forbidden by SNIP-12, such as commas and enclosing parentheses, in addition to the existing non-empty check.
How it was found
- Deploy the factory and an account mock in the test environment.
- Build an InstanceInfo whose name and symbol contain special characters.
- Sign the produce hash with the account and call produce.
- Read nftInfo for that name and symbol and confirm the NFT was created.
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.
When you create an NFT, you give it a name and a short symbol. A StarkNet standard called SNIP-12 says these identifiers must avoid certain characters, such as commas and parentheses, because other software uses those characters as separators. This contract only checks that the name and symbol are not empty, so someone can create an NFT with a name that breaks those rules and confuses wallets or block explorers.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.