Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IvanFitro - CouncilMember.sol :: Burning a NFT impossibilities minting new NFTs (DOS). #6

Closed
sherlock-admin opened this issue Jan 15, 2024 · 6 comments
Assignees
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Jan 15, 2024

IvanFitro

high

CouncilMember.sol :: Burning a NFT impossibilities minting new NFTs (DOS).

Summary

mint() is used to create new NFTs for users. However, a problem arises when an NFT is burned, making it impossible to mint new NFTs due to the calculation of the nftID being dependent on the totalSupply().

Vulnerability Detail

When the mint() is called to create a new NFT for a user, the calculation of the nftID relies on the totalSupply().

function mint(
        address newMember
    ) external onlyRole(GOVERNANCE_COUNCIL_ROLE) {
        if (totalSupply() != 0) {
            _retrieve();
        }

        balances.push(0);
        _mint(newMember, totalSupply());
    }

Initially, this process works as expected. However, a problem arises when an NFT is burned using the burn() , as it decrements the totalSupply.

The issue becomes apparent when the burned NFT is not the latest one minted. In such a scenario, the subsequent call to mint() reverts. This failure occurs because it attempts to use an nftID that already exists (owned by other user).

As a consequence, the transaction reverts with the ERC721 custom error ERC721InvalidSender("0x0000000000000000000000000000000000000000").
This is because for the successful minting of a new NFT, the previous owner must be the zero address. This situation provocates a Denial of Service (DOS).

POC

To run the POC, copy the provided code into the CouncilMember.test.ts file.

describe("Burn custom", () => {

            beforeEach(async () => {
                telcoin.transfer(await stream.getAddress(), 100000);
                await expect(councilMember.mint(member.address)).to.not.reverted;
                await expect(councilMember.mint(support.address)).to.not.reverted;
                await expect(councilMember.mint(await stream.getAddress())).to.not.reverted;
            });

            it("if a NFT is burned impossibilities mint new NFT", async () => {
                await councilMember.burn(0, support.address);
                await expect(councilMember.mint(member.address)).to.revertedWithCustomError(councilMember, "ERC721InvalidSender");
            });
        });

Impact

New NFTs can't be minted (DOS).

Code Snippet

https://github.com/sherlock-audit/2024-01-telcoin/blob/0954297f4fefac82d45a79c73f3a4b8eb25f10e9/telcoin-audit/contracts/sablier/core/CouncilMember.sol#L173-L182
https://github.com/sherlock-audit/2024-01-telcoin/blob/0954297f4fefac82d45a79c73f3a4b8eb25f10e9/telcoin-audit/contracts/sablier/core/CouncilMember.sol#L210-L222

Tool used

Manual Review.

Recommendation

To address this issue, introduce a state variable that increments with each minted NFT.

uint256 nftID;
function mint(
        address newMember
    ) external onlyRole(GOVERNANCE_COUNCIL_ROLE) {
        if (totalSupply() != 0) {
            _retrieve();
        }

        balances.push(0);
-       _mint(newMember, totalSupply());
+       _mint(newMember, nftID);
+       nftID++
    }

Duplicate of #199

@amshirif amshirif self-assigned this Jan 16, 2024
@amshirif amshirif added High A valid High severity issue Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed Reward A payout will be made for this issue labels Jan 16, 2024
@amshirif
Copy link

amshirif commented Jan 16, 2024

@amshirif amshirif removed the Reward A payout will be made for this issue label Jan 16, 2024
@amshirif
Copy link

This is an issue, however the changes here have been reversed due to issue #32. A new fix has been included to address both issues with fewer changes.

@amshirif amshirif added the Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label label Jan 16, 2024
@amshirif
Copy link

Duplicate issue #36

@sherlock-admin2
Copy link
Contributor

1 comment(s) were left on this issue during the judging contest.

takarez commented:

valid because {The watson explained how minting a new token will be prevented after burning; its a dupp of 109 with the same underlying cause}

@sherlock-admin2 sherlock-admin2 changed the title Melodic Hazel Albatross - CouncilMember.sol :: Burning a NFT impossibilities minting new NFTs (DOS). IvanFitro - CouncilMember.sol :: Burning a NFT impossibilities minting new NFTs (DOS). Jan 29, 2024
@sherlock-admin2 sherlock-admin2 added the Reward A payout will be made for this issue label Jan 29, 2024
@sherlock-admin
Copy link
Contributor Author

The protocol team fixed this issue in PR/commit https://github.com/telcoin/telcoin-audit/pull/31.

@sherlock-admin
Copy link
Contributor Author

The Lead Senior Watson signed off on the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed
Projects
None yet
Development

No branches or pull requests

3 participants