Reproduced Exploit
TraitForge: onlyOwner on initializeAlphaIndices bricks mint, budget mint, and forge
initializeAlphaIndices is whenNotPaused onlyOwner. TraitForgeNft._incrementGeneration is what calls it, after generationMintCounts reaches maxTokensPerGen. The NFT contract is allowedCaller, not the owner. With the cap set to 1, the first mintToken, mintWithBudget, and forge each hit the cap, call…
Loss
mintToken, mintWithBudget, and forge all revert. No NFT is issued once a generation fills
Chain
Other
Category
access-control
Date
Jul 2024
Source
AuditVault
EVM Playground
Source-level debugger — step opcodes and Solidity in sync
The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.
Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 37920-h-06-minttoken-mintwithbudget-and-forge-in-the-traitforgenft. Standalone Foundry PoC and full write-up: 37920-h-06-minttoken-mintwithbudget-and-forge-in-the-traitforgenft_exp in the
evm-hack-registrymirror.
Vulnerability classes:
vuln/access-control/broken-logic
Key info#
| Field | Value |
|---|---|
| Loss | mintToken, mintWithBudget, and forge all revert. No NFT is issued once a generation fills |
| Vulnerable contract | EntropyGenerator.initializeAlphaIndices |
| Attacker EOA | 0x1111111111111111111111111111111111111111 |
| Attack contract | Exploit |
| Attack tx | Exploit.run() |
| Chain / block / date | Local synthetic · 2024-07 |
| Compiler | solc 0.8.27, cancun, via IR |
| Bug class | The NFT contract calls a function gated by onlyOwner |
TL;DR#
initializeAlphaIndices is whenNotPaused onlyOwner. TraitForgeNft._incrementGeneration is what calls it, after generationMintCounts reaches maxTokensPerGen. The NFT contract is allowedCaller, not the owner. With the cap set to 1, the first mintToken, mintWithBudget, and forge each hit the cap, call the entropy contract, and revert on onlyOwner. No generation advances and initialized stays false. Replacing the modifier with onlyAllowedCaller lets the same mint open generation 2.
The vulnerable code#
modifier onlyOwner() {
require(msg.sender == owner, "onlyOwner"); // @> VULN
_;
}
function initializeAlphaIndices() public whenNotPaused onlyOwner {
initialized = true;
}
entropyGenerator.initializeAlphaIndices();
The recommended change is onlyAllowedCaller. The control sets that path and tryMint returns true, fixedInitialized is true, and currentGeneration is 2.
Root cause#
The function was given the owner's modifier instead of the modifier that names the NFT contract. Every mint path that rolls a generation depends on that call succeeding.
Preconditions#
allowedCalleris the NFT contract.owneris a different address.maxTokensPerGenis reached by the mint being attempted. The audited code uses a large cap; this run sets it to 1 so the roll happens on the first mint. The revert is the same one the report describes.
Attack walkthrough#
tryMintcallsmintToken. The generation count becomes 1, which is the cap, so_incrementGenerationruns.- The NFT calls
initializeAlphaIndices.whenNotPausedpasses.onlyOwnersees the NFT asmsg.senderand reverts. - The mint rolls back.
tryMintWithBudgetandtryForgedo the same thing. failedMintsis 3. Generation is still 1. No index was initialized.
Diagrams#
Impact#
Users cannot mint, mint against a budget, or forge once a generation is full. With a cap of 1 that is immediate: all three entry points revert and the collection cannot issue the next token. This is a liveness break of the core issuance functions, not a token profit, so the Playground profit is 0.
How to reproduce#
cd 37920-h-06-minttoken-mintwithbudget-and-forge-in-the-traitforgenft_exp
forge test -vv
Sources#
- AuditVault finding: https://github.com/Auditware/AuditVault/blob/main/findings/37920-h-06-minttoken-mintwithbudget-and-forge-in-the-traitforgenft.md
- Report: https://code4rena.com/reports/2024-07-traitforge
- Blamed line: https://github.com/code-423n4/2024-07-traitforge/blob/279b2887e3d38bc219a05d332cbcb0655b2dc644/contracts/EntropyGenerator/EntropyGenerator.sol#L206
- Call site: https://github.com/code-423n4/2024-07-traitforge/blob/279b2887e3d38bc219a05d332cbcb0655b2dc644/contracts/TraitForgeNft/TraitForgeNft.sol#L353
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 37920-h-06-minttoken-mintwithbudget-and-forge-in-the-traitforgenft_exp (evm-hack-registry mirror).
- AuditVault finding: 37920-h-06-minttoken-mintwithbudget-and-forge-in-the-traitforgenft.
Alerts & third-party analyses
These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.