# mintToken(), mintWithBudget(), and forge() in the TraitForgeNft contract will fail due to a wrong modifier used in EntropyGenerator.initializeAlphaIndices()

EntropyGenerator.initializeAlphaIndices() used onlyOwner instead of onlyAllowedCaller, so TraitForgeNft's generation increment reverts, DoSing mintToken(), mintWithBudget() and forge().

- Payout: Audit contest
- Severity: high
- Program: TraitForge
- Found by: 0xAadi
- Disclosed: 2024-09-13
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-07-traitforge-findings/issues/213
- Library page: https://bugbountylibrary.com/r/c4%3A2024-07-traitforge%3AH-06
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:access-control vuln:dos

**Target:** EntropyGenerator / TraitForgeNft Solidity contracts
**Root cause:** initializeAlphaIndices() is guarded by onlyOwner but is only ever invoked by the TraitForgeNft contract via _incrementGeneration(); the intended guard was onlyAllowedCaller, so the call reverts for the NFT contract.
**Steps:**
1. Read EntropyGenerator.sol L206: `function initializeAlphaIndices() public whenNotPaused onlyOwner`.
2. Trace callers: TraitForgeNft._incrementGeneration() calls `entropyGenerator.initializeAlphaIndices()` (L353).
3. Observe _incrementGeneration() is reached from mintToken(), mintWithBudget() and forge() once maxTokensPerGen is hit.
4. Call any of those functions at generation boundary; the onlyOwner check fails since msg.sender is TraitForgeNft, reverting the whole tx.
**How found:** Code review of access-control modifiers: noticed initializeAlphaIndices() was guarded by onlyOwner while its sole caller is the TraitForgeNft contract, then traced the call path from mint/forge functions through _incrementGeneration().
**Exploitation:** No attacker action needed; the flaw is a self-inflicted DoS. Once a generation's mint count reaches maxTokensPerGen, any mintToken(), mintWithBudget() or forge() call routes through _incrementGeneration() and reverts on the onlyOwner check, halting minting and forging permanently.
**Insight:** When auditing modifier-guarded functions, enumerate every internal caller and check msg.sender against the guard; a function only ever called by another contract but gated by onlyOwner is a guaranteed revert at the call site, turning a one-line modifier mistake into a protocol-wide DoS.

## Proof of concept (copied exactly from the original report)

**Wrong onlyOwner modifier on initializeAlphaIndices**

```
function initializeAlphaIndices() public whenNotPaused onlyOwner {
```

**TraitForgeNft calls initializeAlphaIndices in _incrementGeneration**

```
function _incrementGeneration() private {
    require(
      generationMintCounts[currentGeneration] >= maxTokensPerGen,
      'Generation limit not yet reached'
    );
    currentGeneration++;
    generationMintCounts[currentGeneration] = 0;
    priceIncrement = priceIncrement + priceIncrementByGen;
@>  entropyGenerator.initializeAlphaIndices();
```

