Skip to content
Business logic Audit finding Intermediate

Adversary can permanently break reward distribution for percentage tier bounties by funding bounty then refunding after competition closes

The TieredPercentageBountyV1 contract takes a snapshot of token balances when a competition closes to calculate payouts, but allows deposits to be refunded afterwards. An attacker can deposit a token (especially native MATIC) with a short expiration, then refund after closing, leaving the contract unable to pay winners and causing claims to revert permanently.

8olidity Follow with 0x52, HonorLt and 16 others

Originally disclosed on Sherlock

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

Found by

8olidity, 0x52, HonorLt, unforgiven, chainNue, 0xbepresent, libratus, CodeFoxInc, XKET, Ruhum, seyni, Robert, ltyu, jkoppel, holyhansss, TrungOre, yixxas, ctf_sec, cccz

Summary

When closeCompetition is called for TieredPercentageBountyV1 it takes a snapshot of the current token balance. Afterwards it uses this number to calculate the payouts. When a deposit is refunded after the competition is closed then the contract won't have enough funds to pay users.

To exploit this an adversary can make a deposit for a token that has a current balance of zero using a expiration of 1 second. After the competition closes they refund their deposit. Now when the contract tries to give payouts to the winners it will try to payout a token that it no longer has any of, causing it to revert anytime someone tries to claim a payout.

Vulnerability Detail

https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/TieredPercentageBountyV1.sol#L123-L136

TieredPercentageBountyV1#closeCompetition set the final fundingTotals for each token.

https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/TieredPercentageBountyV1.sol#L104-L120

For each token in tokenAddresses it will send the claimedBalance to the claimant. If a deposit is refunded after the competition is closed then the contract won't have enough funds to pay users.

An adversary can exploit this by making a deposit of 100 for some token with and _expiration of 1 (second). After the competition has been closed they can refund their deposit causing the contract to be short on funds. If the user makes a deposit with an ERC20 token payouts can be re-enabled by donating to make the contract whole. The user can permanently break payouts by using native MATIC as the deposit. All bounty contracts have their receive function disabled which means the contract can't just be funded, which permanently breaks payouts.

Submitting as high because it can be combined with methods for breaking refunds to lock user funds permanently.

Impact

Adversary can permanently break TieredPercentageBounty payouts

Code Snippet

Tool used

Manual Review

Recommendation

Since TieredPercentageBounty is designed to distribute all deposits present at closing, refunds should be disabled after the competition is closed.

Discussion

FlacoJones

Valid. Will fix by removing this contract for now.

FlacoJones

https://github.com/OpenQDev/OpenQ-Contracts/pull/112

jacksanford1

Lead Senior Watson comment on PR #112:

Looks like you got everything. Will keep my eye out when reviewing the rest of the PRs for anything that might have been missed.

The original report as published on Sherlock, by 8olidity. 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

The contract calculates payouts based on a balance snapshot at competition close but does not prevent deposits from being refunded after that point.

Impact

An adversary can permanently break TieredPercentageBounty payouts, especially by using native MATIC, as the contract cannot be refunded.

What the attacker needed

Ability to make a deposit; competition must close; deposit must be refundable after close

The fix

Refunds should be disabled after the competition is closed.

How it was found

  1. Make a deposit of a token with an expiration of 1 second.
  2. Wait for the competition to close.
  3. Refund the deposit after the competition is closed.
  4. When winners try to claim payouts, the contract lacks sufficient funds and reverts.

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 bounties records how much money it holds when a competition ends, then uses that amount to pay winners. But it still lets people take back their deposits after the end, so the recorded amount can become wrong. An attacker can exploit this to make the contract unable to pay anyone.

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 8olidity

View all

9 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.