It is possible to steal the unallocated part of every delegation period budget
The standard funding mechanism allowed any proposal with a non-negative funding vote to be included in the final slate, even with zero votes. An attacker could submit a proposal to transfer the unallocated remainder of a low-activity period to themselves and vote for it with a dust amount, stealing those funds.
hyh Follow with mrpathfindr, bytes032 and 4 others
Originally disclosed on Code4rena
Submitted by hyh, also found by mrpathfindr, bytes032, circlelooper, Jiamin, Juntao, and aashar
Attacker can monitor the standard proposals distribution and routinely steal each low activity period remainder by submitting a transfer to self proposal and voting a dust amount for it.
Since the criteria for the final slate update is that any increase in total funding votes casted is enough, the attacker’s costs are negligible, while the remainder funds during some periods can be substantial enough for the attacker to setup such a monitoring. I.e. as funds are constant share of the treasury, while activity can differ drastically, a situation when there are less viable proposals then funds can routinely happen over time.
The assumption of the current logic is that such unallocated funds will be returned to the treasury, but it will not be the case as the cost of stealing such funds is close to zero.
Impact
A part of treasury funds can be stolen each period and will not be available for ecosystem funding.
Proof of Concept
Schematic POC:
- Bob monitors the end of each screening period and, whenever it is cheap enough, submits a proposal to send the remainder funds to self via proposeStandard()
- Bob votes for it with fundingVote() with the dust votes he have. Since it is low activity period there are room, and it is included to
_topTenProposals - Bob updates the top slate with updateSlate(), repeating current top slate with his proposal added. Since other proposals cumulatively do not allocate full budget and Bob’s proposal have positive funding vote attached, it is included to the slate
This way Bob obtained the remainder funds nearly for free.
Core issue here looks to be the absence of the proposal votes threshold, which allows an attacker to claim the remained without any barrier to entry, i.e. having at hand only dust amount of governance tokens.
Even proposal with zero funding votes can be executed, it is only controlled to be non-negative:
function _validateSlate(uint24 distributionId_, uint256 endBlock, uint256 distributionPeriodFundsAvailable_, uint256[] calldata proposalIds_, uint256 numProposalsInSlate_) internal view returns (uint256 sum_) {
// check that the function is being called within the challenge period
if (block.number <= endBlock || block.number > _getChallengeStageEndBlock(endBlock)) {
revert InvalidProposalSlate();
}
// check that the slate has no duplicates
if (_hasDuplicates(proposalIds_)) revert InvalidProposalSlate();
uint256 gbc = distributionPeriodFundsAvailable_;
uint256 totalTokensRequested = 0;
// check each proposal in the slate is valid
for (uint i = 0; i < numProposalsInSlate_; ) {
Proposal memory proposal = _standardFundingProposals[proposalIds_[i]];
// check if Proposal is in the topTenProposals list
if (_findProposalIndex(proposalIds_[i], _topTenProposals[distributionId_]) == -1) revert InvalidProposalSlate();
// account for fundingVotesReceived possibly being negative
>> if (proposal.fundingVotesReceived < 0) revert InvalidProposalSlate();
The only criteria for state update is greater sum of the funding votes:
// check if slate of proposals is better than the existing slate, and is thus the new top slate
newTopSlate_ = currentSlateHash == 0 ||
>> (currentSlateHash!= 0 && sum > _sumProposalFundingVotes(_fundedProposalSlates[currentSlateHash]));
I.e. when the activity is low enough attacker can always maximize the totalTokensRequested to be exactly gbc * 9 / 10, claiming the difference to itself (i.e. the dust vote supplied proposal is to transfer unallocated part to attacker’s account in this case):
totalTokensRequested += proposal.tokensRequested;
// check if slate of proposals exceeded budget constraint ( 90% of GBC )
>> if (totalTokensRequested > (gbc * 9 / 10)) {
revert InvalidProposalSlate();
}
Recommended Mitigation Steps
Consider introducing the minimum accepted vote power for any proposal to be included in the final slate, as an example:
function _validateSlate(uint24 distributionId_, uint256 endBlock, uint256 distributionPeriodFundsAvailable_, uint256[] calldata proposalIds_, uint256 numProposalsInSlate_) internal view returns (uint256 sum_) {
...
+ // using 0.1% of the total vote power used as a minimum for any winning proposal
+ uint minFundingVotePower = _distributions[distributionId_].fundingVotePowerCast / 1000;
// check each proposal in the slate is valid
for (uint i = 0; i < numProposalsInSlate_; ) {
Proposal memory proposal = _standardFundingProposals[proposalIds_[i]];
// check if Proposal is in the topTenProposals list
if (_findProposalIndex(proposalIds_[i], _topTenProposals[distributionId_]) == -1) revert InvalidProposalSlate();
// account for fundingVotesReceived possibly being negative
- if (proposal.fundingVotesReceived < 0) revert InvalidProposalSlate();
+ if (proposal.fundingVotesReceived < 0 || Maths.wpow(SafeCast.toUint256(Maths.abs(proposal.fundingVotesReceived)), 2) < minFundingVotePower) revert InvalidProposalSlate();
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 absence of a minimum vote threshold for proposals to be included in the final slate, allowing proposals with negligible or zero funding votes to be executed.
Impact
A portion of treasury funds could be stolen each period and would not be available for ecosystem funding.
What the attacker needed
Low activity period with unallocated funds; attacker holds a dust amount of governance tokens; attacker can submit proposals and vote
The fix
The project should introduce a minimum accepted vote power for any proposal to be included in the final slate.
How it was found
- Monitor the end of each screening period and, when activity is low, submit a proposal to send the remainder funds to self via proposeStandard().
- Vote for the proposal with a dust amount using fundingVote(), ensuring it enters the top ten proposals.
- Update the top slate with updateSlate(), adding the attacker's proposal to the current top slate.
- The attacker's proposal is included in the slate because other proposals do not allocate the full budget and the attacker's proposal has a positive funding vote.
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 this funding system, each period has a budget, and if not all of it is allocated to proposals, the leftover is supposed to go back to the treasury. However, the rules for updating the final list of funded proposals only required that a proposal have a non-negative number of votes, so even a proposal with almost no votes could be included. An attacker could create a proposal to send the leftover money to themselves, vote for it with a tiny amount, and get it approved, effectively stealing the leftover funds.
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.