mintToken() , mintWithBudget() , and forge() in the TraitForgeNft contract will fail due to a wrong modifier used in EntropyGenerator.initializeAlphaIndices()
The EntropyGenerator contract's initializeAlphaIndices() function uses the onlyOwner modifier instead of onlyAllowedCaller, so the TraitForgeNft contract cannot call it. This causes mintToken(), mintWithBudget(), and forge() to fail when they try to increment the generation.
Submitted by 0xAadi, also found by LogBytes, Fitro, Abdessamed, avoloder, Tomas0707, synackrst, dontonka, _karanel, lrivo, Autosaida, ZanyBonzy, samuraii77, x0t0wt1w, rndquu, Auditor_Nate, blackVul (1, 2), brevis, 0xAleko, zeroProtocol, MinhTriet, 0xb0k0, 0xHelium, AvantGard, Trooper, Stoicov, 0xcontrol, EdMarcavage, yaioxy, anonymousjoe, federodes, Decap, desaperh, ogKapten, LSHFGJ, PENGUN, 0xDarko, onthehunt11, Trident-Audits, ABAIKUNANBAEV, hakunamatata, MrValioBg, 0xlemon, LeFy, kingnull, PetarTolev, binary, Undefined, Bac0nj, Erko, Daniel_eth, pep7siup, vinica_boy, SharpPeaks, yixxas, kutugu, KaligoAudits, inzinko, BajagaSec, franfran20, jeremie, 0x0bserver, dobrevaleri, DigiSafe, Nihavent, mashbust, McToady, King_, Pataroff, eierina, Shahil_Hussain, bhavya0911, amaron, hail_the_lord, ArsenLupin, KupiaSec, gesha17, zxriptor, klau5, ilchovski, Zac, 0xrex, Kalogerone, dimulski, and ZdravkoHr
The EntropyGenerator contract has an issue where the initializeAlphaIndices() function uses the wrong modifier. This function is supposed to be called by the TraitForgeNft contract, but it currently uses the onlyOwner modifier instead of onlyAllowedCaller.
Impact
The initializeAlphaIndices() function will not be callable by the TraitForgeNft contract as intended. This could lead to failures in the expected functionality of the system, particularly in scenarios where the indices need to be initialized or updated by the TraitForgeNft contract while performing minting or forging. That means this vulnerability will cause DoS on mintToken(), mintWithBudget() and forge().
Proof of Concept
The function initializeAlphaIndices() is intended to be called by the TraitForgeNft contract. However, it is currently protected by the onlyOwner modifier. This means only the owner of the EntropyGenerator contract can call it, not the TraitForgeNft contract. The correct modifier should be onlyAllowedCaller, which restricts the function to be called by the address set as the allowedCaller.
The vulnerability lies in the following line of EntropyGenerator contract:
@> function initializeAlphaIndices() public whenNotPaused onlyOwner {
The above initializeAlphaIndices() is called by TraitForgeNft._incrementGeneration():
function _incrementGeneration() private {
require(
generationMintCounts[currentGeneration] >= maxTokensPerGen,
'Generation limit not yet reached'
);
currentGeneration++;
generationMintCounts[currentGeneration] = 0;
priceIncrement = priceIncrement + priceIncrementByGen;
@> entropyGenerator.initializeAlphaIndices();
emit GenerationIncremented(currentGeneration);
}
Some of the important functions defined in TraitForgeNft contract, such as mintToken(), mintWithBudget() and forge(), internally use _incrementGeneration(). Due to this vulnerability, the execution of these mentioned functions will fail.
Recommended Mitigation Steps
Replace the onlyOwner modifier with the onlyAllowedCaller modifier in the initializeAlphaIndices() function to ensure it can be called by the TraitForgeNft contract.
- function initializeAlphaIndices() public whenNotPaused onlyOwner {
+ function initializeAlphaIndices() public whenNotPaused onlyAllowedCaller {
Assessed type
Access Control
TForge1 (TraitForge) confirmed
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
Likely the wrong access control modifier (onlyOwner instead of onlyAllowedCaller) was applied to initializeAlphaIndices().
Impact
The functions mintToken(), mintWithBudget(), and forge() will fail when they attempt to increment the generation, causing a denial of service.
What the attacker needed
None
The fix
Replace the onlyOwner modifier with onlyAllowedCaller in initializeAlphaIndices().
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.
A smart contract has functions that can only be called by certain addresses. Here, a function meant to be called by another contract was mistakenly restricted to only the owner, so the other contract's calls fail. This breaks the minting and forging features.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.