Skip to content
Business logic Audit finding Beginner

Inconsistent State Missing Event Emission in Fl

The nftClaim function in FluxToken.sol marks an NFT as claimed by setting a state variable but does not emit an event. This makes it harder for external contracts and off-chain systems to track which NFTs have been claimed, potentially leading to inconsistent state.

Wizard Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

30992 - [SC - Insight] Inconsistent State Missing Event Emission in Fl...

Submitted on May 10th 2024 at 08:29:50 UTC by @Wizard for Boost | Alchemix

Report ID: #30992

Report type: Smart Contract

Report severity: Insight

Target: https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/FluxToken.sol

Impacts:

  • contracts or users may not be aware that an NFT has been claimed, leading to inconsistent state

Description

Brief/Intro

The FluxToken.sol::nftClaim function does not emit an event when an NFT is claimed, which can lead to inconsistent state.

Vulnerability Details

The nftClaim function marks an NFT as claimed by setting claimed[_nft][_tokenId] = true, but it does not emit an event to notify external contracts that the NFT has been claimed. This is an important step in tracking claimed NFTs.

Impact Details

While there are no direct financial losses associated with the missing event., not emitting an event would make logging and tracing claimed NFTs much harder for external contracts relying on the function's input.

References

https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/FluxToken.sol?utm\\_source=immunefi#L134

Proof of Concept

event ClaimedNFT(address indexed _nft, uint256 indexed _tokenId, address indexed _claimer);

                            --------Code--------- 

 function nftClaim(address _nft, uint256 _tokenId) external {
        // require claim to be within a year of deploy date
        require(block.timestamp < deployDate + oneYear, "claim period has passed");

        require(!claimed[_nft][_tokenId], "already claimed");

        // value of the NFT
        uint256 tokenData = 0;

        // determine which nft is being claimed
        if (_nft == alchemechNFT) {
            // require sender to be owner of the NFT
            require(IAlchemechNFT(_nft).ownerOf(_tokenId) == msg.sender, "not owner of Alchemech NFT");

            tokenData = IAlchemechNFT(_nft).tokenData(_tokenId);
        } else if (_nft == patronNFT) {
            // require sender to be owner of the NFT
            require(IAlEthNFT(_nft).ownerOf(_tokenId) == msg.sender, "not owner of Patron NFT");

            tokenData = IAlEthNFT(_nft).tokenData(_tokenId);
        } else {
            revert("invalid NFT");
        }

        // mark the token as claimed
        claimed[_nft][_tokenId] = true;
++      emit ClaimedNFT(_nft, _tokenId, msg.sender);

        uint256 amount = getClaimableFlux(tokenData, _nft);

        _mint(msg.sender, amount);
    }

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

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

Impact

There are no direct financial losses, but logging and tracing claimed NFTs becomes much harder for external contracts relying on the function's input.

What the attacker needed

None

The fix

The function should emit an event, such as ClaimedNFT, after marking the NFT as claimed.

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.

When a smart contract changes important information, it should announce that change by emitting an event. Events are like public notifications that other programs and people can listen to. Here, the contract silently marks an NFT as claimed without telling anyone, so other systems might not know it happened.

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 by Wizard

View all

1 more disclosed report, best first.

More from Alchemix

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.