🔴 Critical · contracts/token-factory/src/lib.rs:210-243
Description
add_to_whitelist, remove_from_whitelist, and is_whitelisted fully implement an admin-gated address allow-list backed by instance storage. Grepping the rest of lib.rs shows no call site reads is_whitelisted or the underlying storage key anywhere else in the contract — create_token, create_tokens_batch, mint_tokens, and every other entrypoint are reachable by any address regardless of whitelist state. This is either an incomplete feature (the enforcement was never wired up) or intentionally-unused infrastructure for a future gated-launch mode — either way, it currently ships on mainnet as three public, gas-costing, storage-writing functions that do nothing observable to any other contract behavior, which is confusing for auditors and a wasted attack surface (an admin key compromise gains an extra set of callable functions with no corresponding safety benefit).
Tasks
Acceptance Criteria
🔴 Critical ·
contracts/token-factory/src/lib.rs:210-243Description
add_to_whitelist,remove_from_whitelist, andis_whitelistedfully implement an admin-gated address allow-list backed by instance storage. Grepping the rest oflib.rsshows no call site readsis_whitelistedor the underlying storage key anywhere else in the contract —create_token,create_tokens_batch,mint_tokens, and every other entrypoint are reachable by any address regardless of whitelist state. This is either an incomplete feature (the enforcement was never wired up) or intentionally-unused infrastructure for a future gated-launch mode — either way, it currently ships on mainnet as three public, gas-costing, storage-writing functions that do nothing observable to any other contract behavior, which is confusing for auditors and a wasted attack surface (an admin key compromise gains an extra set of callable functions with no corresponding safety benefit).Tasks
create_token/create_tokens_batch(only whitelisted addresses may create tokens), or something else (e.g. gating who may be set astreasuryrecipients in a fee split)?require_whitelistedcheck at the top ofcreate_token_inner/create_tokens_batch, gated behind a factory-level toggle (e.g.FactoryState.whitelist_enabled: bool, defaulting tofalseso existing deployments are unaffected) so the feature can be turned on without breaking public/open factories.docs/contract-abi.mdand the README to describe the actual, enforced behavior (the README currently describes the whitelist as present-but-unenforced as of this audit — keep that accurate or update it once resolved).Acceptance Criteria
main.create_tokencall fails with a clear, dedicated error variant (not a genericUnauthorized) when whitelist mode is enabled.