Skip to content
Access control Audit finding Intermediate

Public ContributionNft::mint leads to cascading issues / loss of funds

YouCrossTheLineAlfie Follow with axelot, DarkeEEandMe and 4 others

Originally disclosed on Code4rena

Submitted by YouCrossTheLineAlfie, also found by axelot, DarkeEEandMe, Legend, mbuba666, RaOne, and sergei2340

The contributors are supposed to submit their proposals via frontend and it is assumed from the docs, that the frontend calls the ContributionNft::mint function to mint as per the proposed proposal.

Contribution Process: Contributors submit their proposals through our frontend, utilizing the modular consensus framework. Each proposal generates a contribution NFT regardless of acceptance, authenticating the submission's origin.

However, the ContributionNft::mint is un-gaurded, allowing proposers to mint their own NFTs.

    function mint(
        address to,
        uint256 virtualId,
        uint8 coreId,
        string memory newTokenURI,
        uint256 proposalId,
        uint256 parentId,
        bool isModel_,
        uint256 datasetId
    ) external returns (uint256) {
        IGovernor personaDAO = getAgentDAO(virtualId);
        require(
            msg.sender == personaDAO.proposalProposer(proposalId),
            "Only proposal proposer can mint Contribution NFT"
        );
        require(parentId != proposalId, "Cannot be parent of itself");

An issue arises here when these proposers are able to pass in incorrect/bogus values of incorrect coreId, newTokenURI, parentId, isModel_ and datasetId.

Impact

  1. Incorrect cores and model values inside the ServiceNft::mint function, leading to incorrect serviceNFT mint:
    function mint(uint256 virtualId, bytes32 descHash) public returns (uint256) {
        // . . . Rest of the code . . .
        uint256 proposalId = personaDAO.hashProposal(targets, values, calldatas, descHash);
        _mint(info.tba, proposalId);
        _cores[proposalId] = IContributionNft(contributionNft).getCore(proposalId);     <<@ -- // Incorrect core set
        // Calculate maturity
        _maturities[proposalId] = IAgentDAO(info.dao).getMaturity(proposalId);

        bool isModel = IContributionNft(contributionNft).isModel(proposalId);               <<@ -- // Incorrect model
        if (isModel) {
            emit CoreServiceUpdated(virtualId, _cores[proposalId], proposalId);
            updateImpact(virtualId, proposalId);
            _coreServices[virtualId][_cores[proposalId]] = proposalId;
        } else {
            _coreDatasets[virtualId][_cores[proposalId]].push(proposalId);
        }
        // . . . Rest of the code . . .
    }
  1. Incorrect datasetId would overwrite someone else’s values as well as incorrect _impacts calculated for both proposalId and datasetId can be seen inside the ServiceNft::updateImpact:
    function updateImpact(uint256 virtualId, uint256 proposalId) public {

       // . . . Rest of the code . . .

        uint256 datasetId = IContributionNft(contributionNft).getDatasetId(proposalId);     <<@ -- // Incorrect datasetId

        _impacts[proposalId] = rawImpact;
        if (datasetId > 0) {
            _impacts[datasetId] = (rawImpact * datasetImpactWeight) / 10000;                <<@ -- // Incorrect impact calculated
            _impacts[proposalId] = rawImpact - _impacts[datasetId];                         <<@ -- // Incorrect impact calculated
            emit SetServiceScore(datasetId, _maturities[proposalId], _impacts[datasetId]);
            _maturities[datasetId] = _maturities[proposalId];
        }

       // . . . Rest of the code . . .
    }

This clearly breaks three functionalities:

  1. The AgentRewardV2::_distributeContributorRewards uses ServiceNft::getImpact call for calculating rewards; hence, allowing to gain higher rewards or provide lesser rewards to the rest.
    function _distributeContributorRewards(
        uint256 amount,
        uint256 virtualId,
        RewardSettingsCheckpoints.RewardSettings memory settings
    ) private {
       // . . . Rest of the code . . .
        for (uint i = 0; i < services.length; i++) {
            serviceId = services[i];
            impact = serviceNftContract.getImpact(serviceId);           <<@ -- // Uses getImpact
            if (impact == 0) {
                continue;
            }

            ServiceReward storage serviceReward = _serviceRewards[serviceId];
            if (serviceReward.impact == 0) {
                serviceReward.impact = impact;
            }
            _rewardImpacts[reward.id][serviceNftContract.getCore(serviceId)] += impact;
        }

        // . . . Rest of the code . . .
    }
  1. The Minter::mint uses the ServiceNft::getImpact call to transfer tokens; hence, leading to excess or lower funds being transferred.
    function mint(uint256 nftId) public noReentrant {

        // . . . Rest of the code . . .

        uint256 finalImpactMultiplier = _getImpactMultiplier(virtualId);
        uint256 datasetId = contribution.getDatasetId(nftId);
        uint256 impact = IServiceNft(serviceNft).getImpact(nftId);          <<@ -- // Uses getImpact
        if (impact > maxImpact) {
            impact = maxImpact;
        }
        uint256 amount = (impact * finalImpactMultiplier * 10 ** 18) / DENOM;
        uint256 dataAmount = datasetId > 0
            ? (IServiceNft(serviceNft).getImpact(datasetId) * finalImpactMultiplier * 10 ** 18) / DENOM
            : 0;

        // . . . Rest of the code . . .
    }
  1. AgentDAO::_calcMaturity uses ContributionNft::getCore which would calculate incorrect core allowing to manipulate coreService:
    function _calcMaturity(uint256 proposalId, uint8[] memory votes) internal view returns (uint256) {
        address contributionNft = IAgentNft(_agentNft).getContributionNft();
        address serviceNft = IAgentNft(_agentNft).getServiceNft();
        uint256 virtualId = IContributionNft(contributionNft).tokenVirtualId(proposalId);
        uint8 core = IContributionNft(contributionNft).getCore(proposalId);                 <<@ -- // Hence, calculating incorrect core.
        uint256 coreService = IServiceNft(serviceNft).getCoreService(virtualId, core);
        // All services start with 100 maturity
        uint256 maturity = 100;
        if (coreService > 0) {
            maturity = IServiceNft(serviceNft).getMaturity(coreService);
            maturity = IEloCalculator(IAgentNft(_agentNft).getEloCalculator()).battleElo(maturity, votes);
        }

        return maturity;
    }

Recommended mitigation steps

Due to lack of documentation, from my personal understanding the comment helps in inferring that the function was meant to be guarded:

    address private _admin; // Admin is able to create contribution proposal without votes

Allowing only an operator or admin to call the ContributionNft::mint should mitigate the issue:

require(_msgSender() == _admin, "Only admin can set elo calculator");
    function mint(
        address to,
        uint256 virtualId,
        uint8 coreId,
        string memory newTokenURI,
        uint256 proposalId,
        uint256 parentId,
        bool isModel_,
        uint256 datasetId
    ) external returns (uint256) {
+       require(_msgSender() == _admin, "Only admin can mint tokens");
        IGovernor personaDAO = getAgentDAO(virtualId);

Virtuals marked as informative


The original report as published on Code4rena, by YouCrossTheLineAlfie. 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.

What is known

A high-severity access control bug in Virtuals Protocol. Code4rena made it public on 4 August 2025. Found in the 2025-04-virtuals-protocol audit contest (finding H-04), also found by 6 other wardens.

About 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.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

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.

More by YouCrossTheLineAlfie

View all

10 more disclosed reports, best first.

More from Virtuals Protocol

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.