Skip to content
Smart contracts Audit finding Intermediate

Status does not update inside the BlackGovernor leading to complete distribution of nudge functionality

The BlackGovernor contract's status variable is never updated because it is shadowed in the execute function, so the MinterUpgradeable's nudge function always reads the default status and sets tailEmissionRate to a constant value instead of adjusting it based on proposal outcome.

hakunamatata Follow with danzero, rashmor and 1 other

Originally disclosed on Code4rena

Submitted by hakunamatata, also found by danzero, rashmor, and rmrf480

https://github.com/code-423n4/2025-05-blackhole/blob/main/contracts/governance/Governor.sol#L308-L330

Finding description and impact

MinterUpgradeable has nudge function that is called by the BlackGovernor contract. The nudge function then check the status of the BlackGovernor and based on status, updates the tailEmissionRate of the contract; however, from analyzing the BlackGovernor contract (which means also analyzing contracts inside the Governor.sol ), we can see that the status variable DOES NOT CHANGE EVER. This leads to the fact that even though proposal has succeeded meaning the tailEmissionRate should be equal to PROPOSAL_INCREASE, it goes to else branch and tailEmissionRate never changes.

This is because the status variable inside BlackGovernor/Governor is SHADOWED in the execute function, which can be easily checked using even Solidity Visual Developer extension.

function  nudge() external {

address _epochGovernor = _gaugeManager.getBlackGovernor();

require(msg.sender == _epochGovernor, "NA");

//@audit STATUS NEVER GETS UPDATED !!!

IBlackGovernor.ProposalState _state = IBlackGovernor(_epochGovernor)

.status();

require(weekly < TAIL_START);

uint256 _period = active_period;

require(!proposals[_period]);

if (_state == IBlackGovernor.ProposalState.Succeeded) {

tailEmissionRate = PROPOSAL_INCREASE;

} else  if (_state == IBlackGovernor.ProposalState.Defeated) {

tailEmissionRate = PROPOSAL_DECREASE;

} else {

tailEmissionRate = 10000;

}

proposals[_period] = true;

}
function  execute(

address[] memory targets,

uint256[] memory values,

bytes[] memory calldatas,

bytes32 epochTimeHash

) public  payable virtual override returns (uint256) {

uint256 proposalId = hashProposal(

targets,

values,

calldatas,

epochTimeHash

);

//@audit variable is shadowed

ProposalState status = state(proposalId);

This vulnerability should be High severity, as the core functionality of the protocol is not working. The status is never updated leading to tailEmissionRate always being the same.

Recommended mitigation steps

Get rid of the shadowing and update the status variable.

Proof of Concept

This POC is written in foundry, in order to run it, one has to create foundry project, download dependencies, create remappings and change imports in some of the file to look inside the “src” folder.

The POC is the simple version of the finding, in order to run it one has to first change the code of the Governor, so that other vulnerability in the code is fixed, as without that change proposals DO NOT WORK. Look at the getVotes inside the BlackGovernor incorrectly provides block.number instead of block.timestamp, leading to complete DOS of proposal functionality finding.

Also to see what’s happening one might add console.logs to minter upgradeable and Governor contract that is used inside BlackGovernor. We can see that even though the state of the proposal should be X, the status variable is always default value.

pragma solidity ^0.8.13;

import {Test, console} from "forge-std/Test.sol";
import {Black} from "../src/Black.sol";
import {MinterUpgradeable} from "../src/MinterUpgradeable.sol";
import {RewardsDistributor} from "../src/RewardsDistributor.sol";
import {PermissionsRegistry} from "../src/PermissionsRegistry.sol";
import {TokenHandler} from "../src/TokenHandler.sol";
import {VoterV3} from "../src/VoterV3.sol";
import {VotingEscrow} from "../src/VotingEscrow.sol";
import {AutoVotingEscrowManager} from "../src/AVM/AutoVotingEscrowManager.sol";
import {GaugeManager} from "../src/GaugeManager.sol";
import {PairGenerator} from "../src/PairGenerator.sol";
import {GaugeFactory} from "../src/factories/GaugeFactory.sol";
import {PairFactory} from "../src/factories/PairFactory.sol";
import {GaugeFactoryCL} from "../src/AlgebraCLVe33/GaugeFactoryCL.sol";
import {BlackGovernor} from "../src/BlackGovernor.sol";
import {IBlackHoleVotes} from "../src/interfaces/IBlackHoleVotes.sol";
import {IMinter} from "../src/interfaces/IMinter.sol";
import {BlackTimeLibrary} from "../src/libraries/BlackTimeLibrary.sol";

contract GovernanceStatusNotUpdatingTest is Test {
    Black public black;
    RewardsDistributor public rewardsDistributor;
    MinterUpgradeable public minterUpgradeable;
    PermissionsRegistry public permissionsRegistry;
    TokenHandler public tokenHandler;
    AutoVotingEscrowManager public avm;
    VotingEscrow public votingEscrow;
    VoterV3 public voter;
    GaugeManager public gaugeManager;
    GaugeFactory public gaugeFactory;
    PairGenerator public pairGenerator;
    PairFactory public pairFactory_1;
    PairFactory public pairFactory_2CL;
    GaugeFactoryCL public gaugeFactoryCL;
    BlackGovernor public blackGovernor;
    address admin = address(0xAD);
    address protocol = address(0x1);
    address userA = address(0xA);
    address userB = address(0xB);
    function setUp() public {
        vm.startPrank(admin);

        black = new Black();
        permissionsRegistry = new PermissionsRegistry();
        string memory GARole = string(bytes("GAUGE_ADMIN"));
        permissionsRegistry.setRoleFor(admin, GARole);
        tokenHandler = new TokenHandler(address(permissionsRegistry));
        voter = new VoterV3();//needs to be initialized
        avm = new AutoVotingEscrowManager();//needs to be initialized
        votingEscrow = new VotingEscrow(address(black), address(0), address(avm));

        rewardsDistributor = new RewardsDistributor(address(votingEscrow));

        gaugeFactoryCL = new GaugeFactoryCL();
        gaugeFactoryCL.initialize(address(permissionsRegistry));

        gaugeFactory = new GaugeFactory();
        pairGenerator = new PairGenerator();
        pairFactory_1 = new PairFactory();
        pairFactory_1.initialize(address(pairGenerator));
        pairFactory_2CL = new PairFactory();
        pairFactory_2CL.initialize(address(pairGenerator));

gaugeManager = new GaugeManager();
        gaugeManager.initialize(address(votingEscrow), address(tokenHandler),address( gaugeFactory),address( gaugeFactoryCL), address(pairFactory_1), address(pairFactory_2CL), address(permissionsRegistry));

        avm.initialize(address(votingEscrow),address(voter), address(rewardsDistributor));

        minterUpgradeable = new MinterUpgradeable();
        minterUpgradeable.initialize(address(gaugeManager), address(votingEscrow), address(rewardsDistributor));

        blackGovernor = new BlackGovernor(IBlackHoleVotes(votingEscrow), address(minterUpgradeable));
        gaugeManager.setBlackGovernor(address(blackGovernor));

        voter = new VoterV3();
        voter.initialize(address(votingEscrow), address(tokenHandler), address(gaugeManager), address(permissionsRegistry));

rewardsDistributor.setDepositor(address(minterUpgradeable));
        gaugeManager.setVoter(address(voter));
        gaugeManager.setMinter(address(minterUpgradeable));
        black.mint(admin, 10_000_000e18);
        black.setMinter(address(minterUpgradeable));

vm.stopPrank();
    }

    function test_statusNotUpdatingVote() public {
        vm.startPrank(admin);
        address[] memory claimants;
        uint[] memory amounts;

        minterUpgradeable._initialize(claimants, amounts, 0);//zero % ownership of top protcols
        uint userABal = 1_000_000e18;
        black.transfer(userA, userABal);

        vm.stopPrank();
        vm.startPrank(userA);
        uint WEEK = 1800;

for(uint i = 0; i< 67; i++) {
           skip(WEEK);
            minterUpgradeable.update_period();
             uint currentEpoch = minterUpgradeable.epochCount();
            uint weekly = minterUpgradeable.weekly();
        }

         black.approve(address(votingEscrow), type(uint).max);
        votingEscrow.create_lock(userABal, 4 * 365 days, true);

        skip(3600);
        address[] memory targets = new address[](1);
        uint256[] memory values = new uint256[](1);
        bytes[] memory calldatas = new bytes[](1);
        targets[0] = address(minterUpgradeable);
        values[0] = 0;
        calldatas[0] = abi.encodeWithSelector(IMinter.nudge.selector);
        bytes32 epochTimehash = bytes32(BlackTimeLibrary.epochNext(block.timestamp));
        uint proposalId = blackGovernor.propose(
            targets,
            values,
            calldatas,
            "Nudge proposal"
        );

        skip(blackGovernor.votingDelay()+1);

        blackGovernor.castVote(proposalId, 1);

        (
            uint256 againstVotes,
            uint256 forVotes,
            uint256 abstainVotes
        )= blackGovernor.proposalVotes(proposalId);

        console.log("Against Votes: ", againstVotes);
        console.log("For Votes: ", forVotes);
        console.log("Abstain Votes: ", abstainVotes);
        skip(blackGovernor.votingPeriod() + 1);

        blackGovernor.execute(targets, values, calldatas, epochTimehash);
        //Look at the logs and status of the Governor

    }
}

Blackhole mitigated

Status: Mitigation confirmed. Full details in reports from rayss, lonelybones and maxvzuvex.


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

Likely a local variable named status in the execute function shadows the contract-level status variable, preventing the contract-level variable from being updated.

Impact

The core functionality of the protocol is broken because tailEmissionRate never changes based on proposal outcomes, always remaining at a constant value.

What the attacker needed

Access to deploy and interact with contracts; a proposal to call nudge; voting power to pass proposal

The fix

The shadowing should be removed and the contract-level status variable should be updated.

How it was found

  1. Deploy the contracts and set up the governance system.
  2. Create a proposal to call the nudge function.
  3. Vote on the proposal and execute it.
  4. Observe that the status variable remains at its default value and tailEmissionRate does not change as expected.

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 Solidity, a variable declared inside a function can hide (shadow) a variable with the same name declared at contract level. Here, the contract's status variable is never assigned, so it stays at its default value. When another contract reads it, it always gets that default, so the intended logic never runs.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by hakunamatata

View all

7 more disclosed reports, best first.

More from Blackhole

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.