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.
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
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
- Upgrade the DAO by calling moveDao, which changes the DAO address in BASE.
- Note that Reserve still holds the old DAO address.
- Call grantFunds on the new DAO, which forwards to Reserve.grantFunds.
- 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.