Skip to content
Business logic Audit finding Intermediate

Funds can be locked indefinitely in NukeFund.sol

The NukeFund contract only allows funds to be withdrawn when an NFT holder calls the nuke function, which burns their NFT. If all NFTs are burned or holders never call nuke, the remaining funds become permanently locked in the contract.

Sabit Follow with 0xDemon, KupiaSec and 1 other

Originally disclosed on Code4rena

Submitted by Sabit, also found by 0xDemon, KupiaSec, and dimulski

https://github.com/code-423n4/2024-07-traitforge/blob/279b2887e3d38bc219a05d332cbcb0655b2dc644/contracts/NukeFund/NukeFund.sol#L40-L61

Impact

  • Permanent loss of funds.
  • Dependency on user action.

Proof of Concept

The NukeFund contract has a unique fund distribution model where the primary - and only - method to withdraw funds is through the nuke() function. This design creates a specific set of circumstances under which funds can be extracted from the contract.

Practical example: Let’s say the contract has accumulated 100 ETH in its fund. A user holding a qualified NFT (let’s call it TokenID 42) wants to claim a portion of this fund.

function nuke(uint256 tokenId) public whenNotPaused nonReentrant {
    // ... (verification checks)
    uint256 claimAmount = /* calculated based on nuke factor */;
    fund -= claimAmount;
    nftContract.burn(tokenId);
    payable(msg.sender).call{value: claimAmount}("");
    // ... (event emissions)
}

https://github.com/code-423n4/2024-07-traitforge/blob/279b2887e3d38bc219a05d332cbcb0655b2dc644/contracts/NukeFund/NukeFund.sol#L153-L183

In this scenario:

  • The user calls nuke(42).
  • The function calculates the claim amount based on the token’s properties.
  • The NFT (TokenID 42) is burned.
  • The calculated amount is sent to the user.
  • The fund is reduced by the claimed amount.

This process works as intended, but it relies entirely on NFT holders initiating the withdrawal process. There’s no other mechanism for fund distribution or withdrawal, which leads to the second point.

  • Risk of permanently locked funds.

If all NFTs are burned or if no one calls the nuke() function, there’s a real risk that funds could remain permanently locked in the contract.

Practical example: Imagine a scenario where the contract has accumulated 500 ETH over time. There are only 10 NFTs left that are eligible for nuking.

Scenario A: All NFTs are burned:

  • Users with the remaining 10 NFTs all call nuke().
  • After these transactions, all NFTs are burned.
  • The contract still holds, say, 100 ETH (depending on the nuke factor calculations).
  • There are no more NFTs left to trigger the nuke() function.
  • The remaining 100 ETH is now locked in the contract with no way to withdraw it.

OR

  • Users decide to directly call burn() to ball their NFTs.
 function burn(uint256 tokenId) external whenNotPaused nonReentrant {
    require(
      isApprovedOrOwner(msg.sender, tokenId),
      'ERC721: caller is not token owner or approved'
    );
    if (!airdropContract.airdropStarted()) {
      uint256 entropy = getTokenEntropy(tokenId);
      airdropContract.subUserAmount(initialOwners[tokenId], entropy);
    }
    _burn(tokenId);
  }

https://github.com/code-423n4/2024-07-traitforge/blob/279b2887e3d38bc219a05d332cbcb0655b2dc644/contracts/TraitForgeNft/TraitForgeNft.sol#L141-L151

Scenario B: Inactivity:

  • Out of the 10 NFT holders, only 5 decide to call nuke().
  • The other 5 forget about their NFTs or lose access to their wallets.
  • The contract is left with 200 ETH and 5 unclaimed NFTs.
  • If these 5 NFTs are never used to call nuke(), the 200 ETH remains locked indefinitely.

Recommended Mitigation Steps

Add a function that allows the contract owner to withdraw funds in case of emergencies or when all NFTs are burned.

Assessed type

Context

Koolex (judge) decreased severity to Medium


The original report as published on Code4rena, by Sabit. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

The contract lacks any alternative withdrawal mechanism, so fund distribution depends entirely on NFT holders calling nuke().

Impact

Funds could be permanently locked in the contract if all NFTs are burned or if holders never call nuke(), resulting in permanent loss of funds.

What the attacker needed

Contract holds ETH; NFTs burned or holders inactive

The fix

Add a function that allows the contract owner to withdraw funds in case of emergencies or when all NFTs are burned.

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.

This is a smart contract that holds money (ETH) collected from users. The only way to take money out is for someone who owns a special digital token (an NFT) to 'nuke' it, which destroys the token and sends them a share of the money. If nobody does that, or if all tokens are destroyed, the money stays stuck in the contract forever with no way to retrieve it.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More from TraitForge

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.