Skip to content
Business logic Audit finding Intermediate

when issuer set new winner by calling setTierWinner() code should reset invoice and supporting documents for that tier

When a bounty issuer changes the winner of a tier, the code does not reset the invoice and supporting document completion status for that tier. A new winner could then claim the prize without completing the required invoice phase.

unforgiven Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-02-openq-judging/issues/297

Found by

unforgiven

Summary

if invoice or supporting documents are required to receive the winning prize then tier winner should provide them. bounty issuer or oracle would set invoice and supporting document status of a tier by calling setInvoiceComplete() and setSupportingDocumentsComplete(). bounty issuer can set tier winners by calling setTierWinner() but code won't reset the status of the invoice and supporting documents when tier winner changes. a malicious winner can bypass invoice and supporting document check by this issue.

Vulnerability Detail

if bounty issuer set invoice and supporting documents as required for the bounty winners in the tiered bounty, then tier winner should provide those and bounty issuer or off-chain oracle would set the status of the invoice and documents for that tier. but if issuer wants to change a tier winner and calls setTierWinner() code would changes the tier winner but won't reset the status of the invoice and supporting documents for the new winner. This is the setTierWinner() code in OpenQV1 and TieredBountyCore:

Solidity
    function setTierWinner(
        string calldata _bountyId,
        uint256 _tier,
        string calldata _winner
    ) external {
        IBounty bounty = getBounty(_bountyId);
        require(msg.sender == bounty.issuer(), Errors.CALLER_NOT_ISSUER);
        bounty.setTierWinner(_winner, _tier);

        emit TierWinnerSelected(
            address(bounty),
            bounty.getTierWinners(),
            new bytes(0),
            VERSION_1
        );
    }

    function setTierWinner(string memory _winner, uint256 _tier)
        external
        onlyOpenQ
    {
        tierWinners[_tier] = _winner;
    }

As you can see code only sets the tierWinner[tier] and won't reset invoiceComplete[tier] or supportingDocumentsComplete[tier] to false. This would cause an issue when issuer wants to change the tier winner. these are the steps that makes the issue:

  1. UserA creates tiered Bounty1 and set invoice and supporting documents as required for winners to claim their funds.
  2. UserA would set User1 as winner of tier 1 and User1 completed the invoice and oracle would set invoiceComplete[1] = true.
  3. UserA would change tier winner to User2 because User1 didn't complete supporting documents phase. now User2 is winner of tier 1 and invoiceComplete[1] is true and User2 only required to complete supporting documents and User2 would receive the win prize without completing the invoice phase.

Impact

malicious winner can bypass invoice and supporting document check when they are required if he is replace as another person to be winner of a tier.

Code Snippet

https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/TieredBountyCore.sol#L59-L64

Tool used

Manual Review

Recommendation

set status of the invoiceComplete[tier] or supportingDocumentsComplete[tier] to false in setTierWinner() function.

Discussion

0xunforgiven

Escalate for 31 USDC

my issue is not duplicate of #425.

issue #425 is: "array lists invoiceCompleteClaimIds[] and supportingDocumentsCompleteClaimIds[] can contain claimIds that are incomplete". that is about those array list containing extra values and the issue has no serious impact because code checks mappings to check invoice and docuements status.

my issue explains that when a tier winner gets changed (Bounty issuer change tier1 winner from User1 to User2 for any reason) code doesn't reset the values in the mappings invoiceComplete[tier1] or supportingDocumentsComplete[tier1]. so values in those mappings would shoe wrong values for the new tier1 winner. the POC shows how the issue happens:

  1. UserA creates tiered Bounty1 and set invoice and supporting documents as required for winners to claim their funds.
  2. UserA would set User1 as winner of tier 1 and User1 completed the invoice and oracle would set invoiceComplete[1] = true.
  3. UserA would change tier winner to User2 because User1 didn't complete supporting documents phase. now User2 is winner of tier 1 and invoiceComplete[1] is true and User2 only required to complete supporting documents and User2 would receive the win prize without completing the invoice phase.

sherlock-admin

Escalate for 31 USDC

my issue is not duplicate of #425.

issue #425 is: "array lists invoiceCompleteClaimIds[] and supportingDocumentsCompleteClaimIds[] can contain claimIds that are incomplete". that is about those array list containing extra values and the issue has no serious impact because code checks mappings to check invoice and docuements status.

my issue explains that when a tier winner gets changed (Bounty issuer change tier1 winner from User1 to User2 for any reason) code doesn't reset the values in the mappings invoiceComplete[tier1] or supportingDocumentsComplete[tier1]. so values in those mappings would shoe wrong values for the new tier1 winner. the POC shows how the issue happens:

  1. UserA creates tiered Bounty1 and set invoice and supporting documents as required for winners to claim their funds.
  2. UserA would set User1 as winner of tier 1 and User1 completed the invoice and oracle would set invoiceComplete[1] = true.
  3. UserA would change tier winner to User2 because User1 didn't complete supporting documents phase. now User2 is winner of tier 1 and invoiceComplete[1] is true and User2 only required to complete supporting documents and User2 would receive the win prize without completing the invoice phase.

You've created a valid escalation for 31 USDC!

To remove the escalation from consideration: Delete your comment. To change the amount you've staked on this escalation: Edit your comment (do not create a new comment).

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

hrishibhat

Escalation accepted

Not a valid duplicate of #425 and a valid issue _eligibleToClaimAtomicBounty would end up validating a user without completing the invoice phase as shown.

sherlock-admin

Escalation accepted

Not a valid duplicate of #425 and a valid issue _eligibleToClaimAtomicBounty would end up validating a user without completing the invoice phase as shown.

This issue's escalations have been accepted!

Contestants' payouts and scores will be updated according to the changes made on this issue.

jacksanford1

Comment from Protocol Team:

I agree it would be better form to reset associated tiers documents + invoice to false if a tier winner is overwritten, but for now the bounty admin is a trusted party, and can always manually reset the tier afterwards.

I don't think this needs a fix at the moment

Classifying this issue as "Won't Fix."

The original report as published on Sherlock, by unforgiven. 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 setTierWinner function only updates the winner address and does not reset the invoiceComplete and supportingDocumentsComplete mappings for that tier.

Impact

A malicious winner could bypass the invoice and supporting document checks if they are made the winner of a tier, potentially receiving the prize without completing required steps.

What the attacker needed

Bounty issuer changes tier winner; invoice and supporting documents required; previous winner completed invoice

The fix

The setTierWinner function should reset the invoiceComplete and supportingDocumentsComplete status for the tier to false when the winner is changed.

How it was found

  1. UserA creates a tiered bounty and sets invoice and supporting documents as required.
  2. UserA sets User1 as winner of tier 1; User1 completes the invoice and the oracle sets invoiceComplete[1] to true.
  3. UserA changes the tier winner to User2 because User1 did not complete supporting documents.
  4. User2 becomes winner of tier 1 while invoiceComplete[1] remains true, so User2 only needs to complete supporting documents to receive the prize.

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 bug bounty, the person offering the reward (issuer) can set a winner for each tier. Winners must complete an invoice and supporting documents to get paid. The code tracks completion per tier, but when the issuer changes the winner, it forgets to clear those completion marks. So the new winner might get paid without doing the required paperwork.

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 by unforgiven

View all

50 more disclosed reports, best first.

More from OpenQ

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.