[M-01] Allocation can start before registration ends. Which can break things in strategies
The timestamp validation in two smart contract strategies allows the allocation period to start before the registration period ends. An attacker (a pool member) could re-register a recipient during allocation, changing their status to pending and causing allocated funds to become permanently locked if the registration period ends before re-review.
Source: https://github.com/sherlock-audit/2023-09-Gitcoin-judging/issues/751
Found by
0xkaden, Kral01, WATCHPUG, ace13567, honeymewn, lemonmon, tnquanghuy0512
Allocation can start before registration ends. Which can break things in strategies. When using QVBaseStrategy and DonationVotingMerkleDistributionBaseStrategy .
Vulnerability Detail
The way that timestamps are set or specifically, validated right now allows Allocation to start before Registration ends. I havent git a clear answer from the protocol team regarding whether this is intended or not, but even if it is intended, this can potentially break some stuff in QVBaseStrategy and DonationVotingMerkleDistributionBaseStrategy.
If _registerRecipient is called while Allocation is active on both QVBaseStrategy and DonationVotingMerkleDistributionBaseStrategy This can completely modify the effects of reviewRecipients and rewrite the status of already 'reviewed' recipients. This can cause rewards being falsely distributed or even stuck as well.
Of course there is a check to see if the caller is a member of the pool. Since the members are 'trusted' then the likelihood is low, thus the impact will be medium, if those roles are not to be trusted, then impact can potentially be high.
Impact
Recipient statuses can be modified and altered causing funds to sent falsely or get stuck.
Code Snippet
This is the check to validate timestamps in both strategies. As we can see, it allows allocationStartTime to be less than registrationEndTime.
if (
block.timestamp > _registrationStartTime || _registrationStartTime > _registrationEndTime
|| _registrationStartTime > _allocationStartTime || _allocationStartTime > _allocationEndTime
|| _registrationEndTime > _allocationEndTime
) {//@audit I think we can start allocation before registration ends
revert INVALID();
Tool used
Manual Review
Recommendation
Consider adding check to revert if allocation can start before registration ends:
if (
block.timestamp > _registrationStartTime || _registrationStartTime > _registrationEndTime
|| _registrationStartTime > _allocationStartTime || _allocationStartTime > _allocationEndTime
|| _registrationEndTime > _allocationEndTime || _registrationEndTime > _allocationStartTime
) {
revert INVALID();
Discussion
thelostone-mc
It is intended to have the ability to register even after allocation has started. But the funds getting stuck for a recipient who has reapplied can be tricky. We could explore a fix this to ensure reapplications are not possible once the allocation has started
0xKurt
But the funds getting stuck for a recipient who has reapplied can be tricky.
We don't see a way how funds could get stuck in the contract.
thelostone-mc
Yup this doesn't seem to be an issue. This can be ignored as it works as intended
neeksec
Agree with sponsor.
kadenzipfel
Escalate This should be a valid medium. Locked funds can happen as follows:
- Recipient registers and is accepted
- Recipient receives allocation (possible because crossover of registration and allocation periods)
- Recipient re-registers (perhaps near the end of registration period)
- Recipient now has status of pending until a new review is processed
- Recipient still has allocated credits
- Registration period completes before recipient is re-reviewed (possible since
registerRecipientandreviewRecipientsboth areonlyActiveRegistration, so there may not be time for the recipient to be re-reviewed - Distribution can no longer be processed to re-registered recipient as they are no longer accepted revert
- No other way to withdraw allocated share of
poolAmountand thus the funds will be permanently locked in the contract
I've included a similar explanation in my submission which may better explain the finding: https://github.com/sherlock-audit/2023-09-Gitcoin-judging/issues/361
sherlock-admin2
Escalate This should be a valid medium. Locked funds can happen as follows:
- Recipient registers and is accepted
- Recipient receives allocation (possible because crossover of registration and allocation periods)
- Recipient re-registers (perhaps near the end of registration period)
- Recipient now has status of pending until a new review is processed
- Recipient still has allocated credits
- Registration period completes before recipient is re-reviewed (possible since
registerRecipientandreviewRecipientsboth areonlyActiveRegistration, so there may not be time for the recipient to be re-reviewed- Distribution can no longer be processed to re-registered recipient as they are no longer accepted revert
- No other way to withdraw allocated share of
poolAmountand thus the funds will be permanently locked in the contractI've included a similar explanation in my submission which may better explain the finding: https://github.com/sherlock-audit/2023-09-Gitcoin-judging/issues/361
You've created a valid escalation!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
neeksec
Suggest to keep invalid.
Sponsor said that "It is intended to have the ability to register even after allocation has started."
Accepted recipient re-register should be re-reviewed. They should know this risk.
If funds are not successfully distributed, pool manager should be able to withdraw them. Fixing #446 solves the locking problem.
kadenzipfel
Suggest to keep invalid.
Sponsor said that "It is intended to have the ability to register even after allocation has started."
Accepted recipient re-register should be re-reviewed. They should know this risk.
If funds are not successfully distributed, pool manager should be able to withdraw them. Fixing #446 solves the locking problem.
Disagree. While functionality may be inline with sponsor intent, the result of funds being locked under normal usage is clearly not intended. Recipients being aware of the risk of losing their own allocation is valid, but they shouldn't be aware of and responsible for this leading to funds being permanently locked.
The fact that the solution to https://github.com/sherlock-audit/2023-09-Gitcoin-judging/issues/446 happens to solve this should not invalidate the finding. If that were reasonable, then it would be equally reasonable to invalidate https://github.com/sherlock-audit/2023-09-Gitcoin-judging/issues/446 if the recommended mitigation to this issue solved https://github.com/sherlock-audit/2023-09-Gitcoin-judging/issues/446.
Note that this is issue was initially sponsor disputed because it was unclear how it would lead to funds being locked, which has since been clarified https://github.com/sherlock-audit/2023-09-Gitcoin-judging/issues/751#issuecomment-1763188537 and was already made clear in other issues, including https://github.com/sherlock-audit/2023-09-Gitcoin-judging/issues/361
Evert0x
@neeksec any follow up comment?
neeksec
Agree with @kadenzipfel on
the result of funds being locked under normal usage is clearly not intended
Agree with escalation that this should be medium.
Evert0x
Thanks. Planning to accept escalation and make medium
Evert0x
Result: Medium Has Duplicates
sherlock-admin2
Escalations have been resolved successfully!
Escalation status:
- kadenzipfel: accepted
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 timestamp validation logic does not enforce that registration ends before allocation starts, allowing overlapping periods.
Impact
Recipient statuses can be modified and altered causing funds to sent falsely or get stuck.
What the attacker needed
Caller is a pool member; recipient re-registers during allocation; registration ends before re-review
The fix
The text does not state a fix was applied; the recommendation is to add a check that reverts if allocation can start before registration ends.
How it was found
- Recipient registers and is accepted.
- Recipient receives allocation (possible because crossover of registration and allocation periods).
- Recipient re-registers (perhaps near the end of registration period).
- Recipient now has status of pending until a new review is processed.
- Recipient still has allocated credits.
- Registration period completes before recipient is re-reviewed (possible since `registerRecipient` and `reviewRecipients` both are `onlyActiveRegistration`, so there may not be time for the recipient to be re-reviewed.
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 a funding pool, there are two phases: registration (when people sign up to receive funds) and allocation (when funds are assigned). The code that checks the dates mistakenly allows allocation to begin before registration closes. This means someone who already received funds can sign up again during allocation, which resets their status and can lock the funds they were allocated.
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.