Open code423n4 opened 1 year ago
Seems Low severity to me as it is an edge case and the suggested tie breakers are arbitrary as well
Picodes marked the issue as primary issue
Picodes marked issue #129 as primary and marked this issue as a duplicate of 129
Picodes changed the severity to QA (Quality Assurance)
Lines of code
https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-grants/src/grants/base/StandardFunding.sol#L300-L340 https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-grants/src/grants/base/StandardFunding.sol#L421-L454 https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-grants/src/grants/base/StandardFunding.sol#L488-L497
Vulnerability details
Impact
During the challenge phase, the following
StandardFunding.updateSlate
function can be called, which further calls theStandardFunding._validateSlate
function below. Since theStandardFunding._validateSlate
function executesif (totalTokensRequested > (gbc * 9 / 10)) {revert InvalidProposalSlate();}
, the total number of tokens requested by all proposals to be added to_fundedProposalSlates[newSlateHash]
cannot exceedgbc * 9 / 10
. Moreover, because theStandardFunding.updateSlate
function executesnewTopSlate_ = currentSlateHash == 0 || (currentSlateHash!= 0 && sum > _sumProposalFundingVotes(_fundedProposalSlates[currentSlateHash]))
, the sum offundingVotesReceived
for all proposals to be added to_fundedProposalSlates[newSlateHash]
must be higher than that for the current slate's proposals for winning the challenge and updating the slate.After the funding phase, it is possible that not all of the top ten proposals can be executed because their total number of requested tokens can exceed
gbc * 9 / 10
and some of these top ten proposals have equalfundingVotesReceived
. For example,fundingVotesReceived
of the top 9th and 10th proposals can be equal, and thegbc * 9 / 10
limit on the total number of requested tokens can only allow the top 9th or 10th proposal to be added to_fundedProposalSlates[newSlateHash]
along with the other eight top proposals. The proposer of the top 9th proposal can call theStandardFunding.updateSlate
function for adding the other top eight proposals and the top 9th proposal to_fundedProposalSlates[newSlateHash]
. After noticing this transaction of the top 9th proposal's proposer in the mempool, the proposer of the top 10th proposal or someone who does not support the top 9th proposal can frontrun such transaction by calling theStandardFunding.updateSlate
function for adding the other top eight proposals and the top 10th proposal to_fundedProposalSlates[newSlateHash]
. After the frontrunning, the other top eight proposals and the top 10th proposal are added to_fundedProposalSlates[newSlateHash]
, and thensum > _sumProposalFundingVotes(_fundedProposalSlates[currentSlateHash])
andnewTopSlate_
would become false when executing the transaction of the top 9th proposal's proposer. BecausenewTopSlate_
is false, the top 9th proposal cannot be added to_fundedProposalSlates[newSlateHash]
and thus cannot be executed even though it should be if such frontrunning can be prevented, which is unfair to the top 9th proposal.https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-grants/src/grants/base/StandardFunding.sol#L300-L340
https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-grants/src/grants/base/StandardFunding.sol#L421-L454
https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-grants/src/grants/base/StandardFunding.sol#L488-L497
Proof of Concept
The following steps can occur for the described scenario.
fundingVotesReceived
. Thegbc * 9 / 10
limit on the total number of requested tokens only allows the other top eight proposals and Alice or Bob's proposal to be added to_fundedProposalSlates[newSlateHash]
.StandardFunding.updateSlate
function for adding the other top eight proposals and her proposal to_fundedProposalSlates[newSlateHash]
.StandardFunding.updateSlate
function for adding the other top eight proposals and his proposal to_fundedProposalSlates[newSlateHash]
._fundedProposalSlates[newSlateHash]
and can be executed after the challenge phase is ended but Alice's proposal cannot be added to_fundedProposalSlates[newSlateHash]
and cannot be executed after the challenge phase is over, which is unexpected and unfair to Alice.Tools Used
VSCode
Recommended Mitigation Steps
A tie breaker can be added to determine the priorities among the proposals that have equal
fundingVotesReceived
after the funding phase is ended. Such tie breaker can be the time when the proposals were created, the number of tokens requested by the proposals, etc. or a combination of these factors. TheStandardFunding.updateSlate
function can then be updated to allow the proposal with the higher priority to replace the proposal with the lower priority in_fundedProposalSlates[newSlateHash]
when both proposals have equalfundingVotesReceived
.Assessed type
DoS