Skip to content
Business logic Audit finding Intermediate

grantFunds will revert after a DAO upgrade.

When the DAO contract is upgraded via moveDao, the Reserve contract's stored DAO address is not updated, so its onlyGrantor check rejects the new DAO. As a result, grantFunds calls from the upgraded DAO revert and grants cannot be paid out.

gpersoon Follow

Originally disclosed on Code4rena

Submitted by gpersoon

When the DAO is upgraded via moveDao, it also updates the DAO address in BASE. However it doesn’t update the DAO address in the Reserve.sol contract. This could be done with the function setIncentiveAddresses(..)

Now the next time grantFunds of DAO.sol is called, its tries to call _RESERVE.grantFunds(...)

The grantFunds of Reserve.sol has the modifier onlyGrantor(), which checks the msg.sender == DAO. However in the mean time, the DAO has been updated and Reserve.sol doesn’t know about it and thus the modifier will not allow access to the function. Thus grantFunds will revert.

Dao.sol L452

function moveDao(uint _proposalID) internal {
    address _proposedAddress = mapPID_address[_proposalID]; // Get the proposed new address
    require(_proposedAddress != address(0), "!address"); // Proposed address must be valid
    DAO = _proposedAddress; // Change the DAO to point to the new DAO address
    iBASE(BASE).changeDAO(_proposedAddress); // Change the BASE contract to point to the new DAO address
    daoHasMoved = true; // Set status of this old DAO
    completeProposal(_proposalID); // Finalise the proposal
}

function grantFunds(uint _proposalID) internal {
    uint256 _proposedAmount = mapPID_param[_proposalID]; // Get the proposed SPARTA grant amount
    address _proposedAddress = mapPID_address[_proposalID]; // Get the proposed SPARTA grant recipient
    require(_proposedAmount != 0, "!param"); // Proposed grant amount must be valid
    require(_proposedAddress != address(0), "!address"); // Proposed recipient must be valid
    _RESERVE.grantFunds(_proposedAmount, _proposedAddress); // Grant the funds to the recipient
    completeProposal(_proposalID); // Finalise the proposal
}

Reserve.sol L17

modifier onlyGrantor() {
    require(msg.sender == DAO || msg.sender == ROUTER || msg.sender == DEPLOYER || msg.sender == LEND || msg.sender == SYNTHVAULT, "!DAO");
    _;
}

function grantFunds(uint amount, address to) external onlyGrantor {
    ....
}

function setIncentiveAddresses(address _router, address _lend, address _synthVault, address _Dao) external onlyGrantor {
    ROUTER = _router;
    LEND = _lend;
    SYNTHVAULT = _synthVault;
    DAO = _Dao;
}

Recommend calling setIncentiveAddresses(..) when a DAO upgrade is done.

verifyfirst (Spartan) confirmed:

Non critical, however this will be implemented to future proof the protocol

The original report as published on Code4rena, by gpersoon. 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 the DAO upgrade path updates the BASE contract's DAO pointer but never calls setIncentiveAddresses on Reserve, leaving a stale trusted address.

Impact

After a DAO upgrade, grant payments through grantFunds would revert until Reserve's addresses are manually corrected.

What the attacker needed

DAO upgrade via moveDao has occurred

The fix

The DAO upgrade should also call setIncentiveAddresses on Reserve to update its stored DAO address; the team said this would be implemented.

How it was found

  1. Upgrade the DAO by calling moveDao, which changes the DAO address in BASE.
  2. Note that Reserve still holds the old DAO address.
  3. Call grantFunds on the new DAO, which forwards to Reserve.grantFunds.
  4. Observe the onlyGrantor check fail and the call revert.

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.

A smart contract can store the address of another contract it trusts. Here the Reserve contract kept the old DAO address after the DAO was replaced, so it no longer recognised the new DAO as allowed to call it. Any attempt to send a grant then failed because the permission check said no.

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 gpersoon

View all

47 more disclosed reports, best first.

More from Spartan Protocol Contest

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.