# CoreCollection: Starting index is pseudo-randomly generated, allowing for gameable NFT launches

CoreCollection derives NFT starting index from block.number, letting anyone precompute rare token IDs and snipe them at mint.

- Payout: Audit contest
- Severity: medium
- Program: Joyn
- Found by: hickuphh3
- Disclosed: 2022-07-25
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2022-03-joyn-findings/issues/50
- Library page: https://bugbountylibrary.com/r/c4%3A2022-03-joyn%3AM-08
- Tags: domain:web3 impact:integrity kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:business-logic

**Target:** NFT CoreCollection starting-index generation
**Root cause:** Starting index is computed as keccak256("CoreCollection", block.number) % maxSupply + 1; block.number is public and predictable, so the index for any future block is computable.
**Steps:**
1. Read CoreCollection init: startingIndex = keccak256(abi.encodePacked("CoreCollection", block.number)) % maxSupply + 1
2. Fetch _baseUri metadata to map token IDs to rarity
3. Precompute startingIndex for upcoming blocks via a view function mirroring the formula
4. Identify which token IDs map to rare NFTs for each candidate block
5. Mint in the block whose starting index places rare NFTs at the minted IDs
**How found:** Recognized block.number is not entropy; noted _baseUri is set at initialization so metadata is known before mint, enabling precomputation of rare IDs.
**Exploitation:** Attacker precomputes starting indexes for future blocks and scrapes metadata from the already-set _baseUri to identify rare token IDs, then times mints to obtain the rarest NFTs, disadvantaging other minters.
**Insight:** When auditing NFT launches, check the entropy source for the starting index and whether metadata/baseUri is readable before mint; predictable block fields plus pre-set metadata turn 'random' shuffles into a sniping oracle.
