Skip to content
Business logic Audit finding Intermediate

`QVBaseStrategy` contract : recipient `reviewStatus` is not reset upon re-registration

The QVBaseStrategy contract keeps a per-recipient tally of review votes but does not clear it when a recipient re-registers, so old votes carry over into the new application. A re-registered recipient could therefore reach the review threshold and be accepted with fewer fresh votes than intended.

ArmedGoose Follow with WATCHPUG, ast3ros and 2 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-09-Gitcoin-judging/issues/729

Found by

ArmedGoose, WATCHPUG, ast3ros, hals, honeymewn QVBaseStrategy contract : the reviewStatus of the recipient is not reset (set to zero) when he re-registres again.

Vulnerability Detail

  • In QVBaseStrategy strategy contract: when the user first registers; his status is updated from None to Pending.

  • Then the pool manager can review recipients (via reviewRecipients function) and update their statuses from Pending to Accepted and from Accepted to Pending only (not updating to Rejected or Appealed) if these recipients statuses got votes equal to reviewThreshold:

    QVBaseStrategy::reviewRecipients /L275-280

    Solidity
                if (reviewsByStatus[recipientId][recipientStatus] >= reviewThreshold) {
                    Recipient storage recipient = recipients[recipientId];
                    recipient.recipientStatus = recipientStatus;
    
                    emit RecipientStatusUpdated(recipientId, recipientStatus, address(0));
                }
    
  • The strategy contract allows registered recipients to re-register again with new terms; and when doing so, their statuses are updated from Accepted ==> Pending or from Rejected to Appealed:

    QVBaseStrategy::_registerRecipient /L275-280

    Solidity
    if (currentStatus == Status.None) {
              // recipient registering new application
              recipient.recipientStatus = Status.Pending;
              emit Registered(recipientId, _data, _sender);
          } else {
              if (currentStatus == Status.Accepted) {
                  // recipient updating accepted application
                  recipient.recipientStatus = Status.Pending;
              } else if (currentStatus == Status.Rejected) {
                  // recipient updating rejected application
                  recipient.recipientStatus = Status.Appealed;
              }
    
              // emit the new status with the '_data' that was passed in
              emit UpdatedRegistration(recipientId, _data, _sender, recipient.recipientStatus);
          }
    

Impact

But as can be noticed; the reviewRecipient status of the re-registered recipient is not reset which will result in this re-registered recipient getting Accepted status on their new registration in the next review round/rounds with lesser votes to reach reviewThreshold.

Code Snippet

QVBaseStrategy::_registerRecipient /L275-280

Solidity
if (currentStatus == Status.None) {
          // recipient registering new application
          recipient.recipientStatus = Status.Pending;
          emit Registered(recipientId, _data, _sender);
      } else {
          if (currentStatus == Status.Accepted) {
              // recipient updating accepted application
              recipient.recipientStatus = Status.Pending;
          } else if (currentStatus == Status.Rejected) {
              // recipient updating rejected application
              recipient.recipientStatus = Status.Appealed;
          }

          // emit the new status with the '_data' that was passed in
          emit UpdatedRegistration(recipientId, _data, _sender, recipient.recipientStatus);
      }

QVBaseStrategy::reviewRecipients

Solidity
  function reviewRecipients(address[] calldata _recipientIds, Status[] calldata _recipientStatuses)
      external
      virtual
      onlyPoolManager(msg.sender)
      onlyActiveRegistration
  {
      // make sure the arrays are the same length
      uint256 recipientLength = _recipientIds.length;
      if (recipientLength != _recipientStatuses.length) revert INVALID();

      for (uint256 i; i < recipientLength;) {
          Status recipientStatus = _recipientStatuses[i];
          address recipientId = _recipientIds[i];

          // if the status is none or appealed then revert
          if (recipientStatus == Status.None || recipientStatus == Status.Appealed) {
              revert RECIPIENT_ERROR(recipientId);
          }

          reviewsByStatus[recipientId][recipientStatus]++;

          if (reviewsByStatus[recipientId][recipientStatus] >= reviewThreshold) {
              Recipient storage recipient = recipients[recipientId];
              recipient.recipientStatus = recipientStatus;

              emit RecipientStatusUpdated(recipientId, recipientStatus, address(0));
          }

          emit Reviewed(recipientId, recipientStatus, msg.sender);

          unchecked {
              ++i;
          }
      }
  }

Tool used

Manual Review

Recommendation

Update _registerRecipient function to reset reviewsByStatus[recipientId][recipientStatus] when the recipient re-registers:

Diff
if (currentStatus == Status.None) {
          // recipient registering new application
          recipient.recipientStatus = Status.Pending;
          emit Registered(recipientId, _data, _sender);
      } else {
          if (currentStatus == Status.Accepted) {
              // recipient updating accepted application
              recipient.recipientStatus = Status.Pending;
+             reviewsByStatus[recipientId][Status.Accepted]=0;
          } else if (currentStatus == Status.Rejected) {
              // recipient updating rejected application
              recipient.recipientStatus = Status.Appealed;
          }

          // emit the new status with the '_data' that was passed in
          emit UpdatedRegistration(recipientId, _data, _sender, recipient.recipientStatus);
      }

Discussion

codenamejason

A related issue -> https://github.com/sherlock-audit/2023-09-Gitcoin-judging/issues/699

jacksanford1

https://github.com/allo-protocol/allo-v2/pull/349

jack-the-pug

Not fixed. See also the recommendation of https://github.com/sherlock-audit/2023-09-Gitcoin-judging/issues/680

The original report as published on Sherlock, by ArmedGoose. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 re-registration path updates the recipient's status but leaves the stored review counts untouched, so votes from the earlier application persist.

Impact

A re-registered recipient could be accepted in a later review round with fewer votes than the threshold requires, weakening the review process.

What the attacker needed

Recipient already reviewed once; recipient re-registers; pool manager runs a review round

The fix

The recommendation is to reset the stored review count for the relevant status inside the re-registration path; the linked pull request did not fix it according to the discussion.

How it was found

  1. A recipient registers and their status becomes Pending.
  2. The pool manager reviews recipients and, once votes reach the review threshold, the status becomes Accepted.
  3. The recipient re-registers with new terms, which moves the status back to Pending.
  4. The old review votes remain stored, so in the next review round fewer new votes are needed to reach the threshold.

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 is a program that runs on a blockchain. This one lets people apply for funding and lets a manager approve or reject each applicant after enough reviewers vote. The vote counter for an applicant was never cleared when they applied again, so votes from the previous application still counted towards the new one.

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.

More from Allo V2

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.