Lack of ability to make an some external function calls makes the DAO stage unreachable
The TraitForgeNft contract owns the Airdrop contract but lacks a function to call Airdrop.allowDaoFund(), making it impossible to enable DAO fund distribution. As a result, the NukeFund contract can never enter the DAO stage, so dev shares are sent to the owner instead of the DAO.
Submitted by pfapostol, also found by 0xlemon and yixxas
Switching to DAO phase in NukeFund is not possible. This vulnerability is on the boundary of scope because it makes it impossible to use the out-of-scope contract but the problem is in the contact inside the scope that is the owner of this external contract.
The TraitForgeNft contract is written in such a way that it can add and remove users from the airdrop. For this the NFT contract must have ownership over the airdrop contract.
Because of this, an additional function is created in TraitForgeNft to start the airdrop while other functions that can only be called by the owner (setTraitToken, allowDaoFund) are absent in TraitForgeNft contract. Which makes these functions impossible to call.
The first function may not be necessary (deployer can call it at deploy), but the second function must have its own handle in the TraitForgeNft contract since this function is used by NukeFund and can only be called after the start of the airdrop; that is, after the transfer of ownership to the TraitForgeNft contract.
Proof of Concept
With normal initialization owner of Airdrop is TraitForgeNft:
contract DeployAllTest is Test {
string constant NAME = "TRAIT";
string constant SYMBOL = "TRAIT";
uint8 constant DECIMALS = 18;
uint256 constant TOTAL_SUPPLY = 1_000_000e18;
address constant UNISWAP_ROUTER = address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address immutable DEPLOYER = makeAddr("DEPLOYER");
address immutable USER1 = makeAddr("USER1");
address immutable USER2 = makeAddr("USER2");
address immutable USER3 = makeAddr("USER3");
address immutable DEV1 = makeAddr("DEV1");
address immutable DEV2 = makeAddr("DEV2");
address immutable DEV3 = makeAddr("DEV3");
Trait token;
TraitForgeNft nft;
EntropyGenerator entropyGenerator;
EntityTrading entityTrading;
EntityForging entityForging;
DevFund devFund;
Airdrop airdrop;
DAOFund daoFund;
NukeFund nukeFund;
Attacker attacker;
uint256 trackId = 0;
function setUp() public {
vm.startPrank(DEPLOYER);
// Deploy all contracts using Foundry's deployment method
token = new Trait(NAME, SYMBOL, DECIMALS, TOTAL_SUPPLY); // @audit-qa Would be nice to burn some tokens
nft = new TraitForgeNft();
entropyGenerator = new EntropyGenerator(address(nft));
entityTrading = new EntityTrading(address(nft));
entityForging = new EntityForging(address(nft));
devFund = new DevFund();
airdrop = new Airdrop();
daoFund = new DAOFund(address(token), UNISWAP_ROUTER);
nukeFund = new NukeFund(address(nft), address(airdrop), payable(address(devFund)), payable(address(daoFund)));
attacker = new Attacker(nft, airdrop);
vm.stopPrank();
}
function _initVars() internal {
vm.startPrank(DEPLOYER);
nft.setEntityForgingContract(address(entityForging));
nft.setEntropyGenerator(address(entropyGenerator));
nft.setAirdropContract(address(airdrop));
airdrop.setTraitToken(address(token));
airdrop.transferOwnership(address(nft));
nft.setNukeFundContract(payable(address(nukeFund)));
entropyGenerator.transferOwnership(address(nft));
entityTrading.setNukeFundAddress(payable(address(nukeFund)));
entityForging.setNukeFundAddress(payable(address(nukeFund)));
entropyGenerator.writeEntropyBatch1();
entropyGenerator.writeEntropyBatch2();
entropyGenerator.writeEntropyBatch3();
vm.stopPrank();
}
function testMedium_deadFunc() public {
_initVars();
console2.log(airdrop.owner());
assert(airdrop.owner() == address(nft));
}
}
There is no way to call Airdrop.allowDaoFund(). The third stage in NukeFund dev share distribution relies completely on airdropContract.daoFundAllowed().
if (!airdropContract.airdropStarted()) {
(bool success,) = devAddress.call{value: devShare}("");
require(success, "ETH send failed");
emit DevShareDistributed(devShare);
} else if (!airdropContract.daoFundAllowed()) {
(bool success,) = payable(owner()).call{value: devShare}("");
require(success, "ETH send failed");
} else {
(bool success,) = daoAddress.call{value: devShare}("");
require(success, "ETH send failed");
emit DevShareDistributed(devShare);
}
Recommended Mitigation Steps
Add delegate handle to TraitForgeNft:
diff --git a/contracts/TraitForgeNft/TraitForgeNft.sol b/contracts/TraitForgeNft/TraitForgeNft.sol
index b933d74..14b2f99 100644
--- a/contracts/TraitForgeNft/TraitForgeNft.sol
+++ b/contracts/TraitForgeNft/TraitForgeNft.sol
@@ -86,6 +86,11 @@ contract TraitForgeNft is ITraitForgeNft, ERC721Enumerable, ReentrancyGuard, Own
airdropContract.startAirdrop(amount); //@external-logic
}
+ function allowDaoFund() external whenNotPaused onlyOwner {
+ airdropContract.allowDaoFund();
+ }
+
function setStartPrice(uint256 _startPrice) external onlyOwner {
startPrice = _startPrice;
}
Assessed type
Access Control
I think this issue was marked as invalid because validators mistakenly flagged it as a duplicate of Issue 214, but this is a completely different issue. Issue #214 addresses the normal behavior by reporting that “the
TraitForgeNftcannot callsubUserAmountandaddUserAmountbecause they are ownable”, but this is incorrect since the ownership is transferred toTraitForgeNft.Since the ownership is transferred to
TraitForgeNft,allowDaoFundcannot be called (not implemented); which results in the failure to switch to the DAO stage of the project.
samuraii77 (warden) commented:
@Koolex - I just want to mention that the Airdrop contract is OOS and any issues related to improper access control set on it should not be valid at all.
I believe the issue is valid. Owner of Airdrop is TraitForgeNft and the bug prevents from entering the DAO stage. The root cause and the fix is in TraitForgeNft, therefore it is in scope.
Note: For full discussion, see here.
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 TraitForgeNft contract lacks a wrapper function to call Airdrop.allowDaoFund(), so the owner cannot trigger the DAO fund allowance.
Impact
The DAO stage of NukeFund cannot be reached, so dev shares are sent to the owner instead of the DAO.
What the attacker needed
Airdrop ownership transferred to TraitForgeNft
The fix
Add a function in TraitForgeNft that calls Airdrop.allowDaoFund(), restricted to the owner.
How it was found
- Deploy all contracts and initialise variables, transferring ownership of Airdrop to TraitForgeNft.
- Attempt to call Airdrop.allowDaoFund() — no function exists in TraitForgeNft to do so.
- Observe that NukeFund's dev share distribution checks airdropContract.daoFundAllowed(), which remains false, so the DAO stage is never reached.
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.
In this system, a contract called TraitForgeNft controls another contract called Airdrop. To switch to a new phase where fees go to a DAO (a community fund), someone must call a function on Airdrop. But only the owner (TraitForgeNft) can call it, and TraitForgeNft has no way to make that call. So the switch never happens, and fees keep going to the owner instead of the DAO.
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.