RFPSimpleStrategy milestones can be set multiple times
The setMilestones function in RFPSimpleStrategy could be called multiple times before the first distribution because the check relied on an index that only increments after distribution. An attacker could duplicate milestones, causing the total percentage to exceed 100%, potentially increasing payouts or breaking the pool state.
Source: https://github.com/sherlock-audit/2023-09-Gitcoin-judging/issues/176
Found by
GimelSec, HChang26, Martians, WATCHPUG, ace13567, fibonacci, jkoppel, lemonmon, osmanozdemir1
Until the first distribution is completed, it's possible to call setMilestones function multiple times. New milestones are added to the previous ones. The totalAmountPercentage of all milestones in this case will be greater than 100%. It also affects all the contracts that are inherited from RFPSimpleStrategy.
Vulnerability Detail
The setMilestones function in RFPSimpleStrategy contract checks if MILESTONES_ALREADY_SET or not by upcomingMilestone index.
if (upcomingMilestone != 0) revert MILESTONES_ALREADY_SET();
But upcomingMilestone increases only after distribution, and until this time will always be equal to 0.
Impact
It can accidentally break the pool state or be used with malicious intentions.
- Two managers accidentally set the same milestones. Milestones are duplicated and can't be reset, the pool needs to be recreated.
- The manager, in cahoots with the recipient, sets milestones one by one, thereby bypassing
totalAmountPercentagecheck and increasing the payout amount.
Code Snippet
Tool used
Manual Review
Recommendation
Fix condition if milestones should only be set once.
if (milestones.length > 0) revert MILESTONES_ALREADY_SET();
Or allow milestones to be reset while they are not in use.
if (milestones.length > 0) {
if (milestones[0].milestoneStatus != Status.None) revert MILESTONES_ALREADY_IN_USE();
delete milestones;
}
Discussion
sherlock-admin2
Escalate This is invalid. I cannot accept that a pool manager can be malicious
You've deleted an escalation for this issue.
jkoppel
#376 explains how this can cause an issue without a malicious pool owner.
MLON33
https://github.com/allo-protocol/allo-v2/pull/341
jack-the-pug
Fixed.
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 check for whether milestones were already set used the upcomingMilestone index, which remains zero until after the first distribution, so the check never triggered before that point.
Impact
This could accidentally break the pool state or be exploited by a malicious manager and recipient to bypass the totalAmountPercentage check and increase the payout amount.
What the attacker needed
Manager role in the pool; No distribution completed yet
The fix
The condition should check if milestones.length > 0 to prevent setting milestones more than once, or allow resetting only when milestones are not in use.
How it was found
- Call setMilestones before any distribution has occurred.
- Call setMilestones again with additional milestones.
- Observe that new milestones are appended and totalAmountPercentage exceeds 100%.
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 for managing project milestones allowed the manager to set milestones repeatedly before any payout. This meant the total percentage of funds allocated to milestones could go over 100%, which could lead to incorrect payouts or a broken contract.
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.