This repository has been archived by the owner on May 26, 2023. It is now read-only.
jkoppel - Can steal funds from other winners in a tiered percentage bounty by sandwhiching closeCompetition with deposit/refund #99
Labels
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
Escalation Resolved
This issue's escalations have been approved/rejected
High
A valid High severity issue
Reward
A payout will be made for this issue
jkoppel
high
Can steal funds from other winners in a tiered percentage bounty by sandwhiching closeCompetition with deposit/refund
Summary
A winner of a tier in a tiered percentage bounty can inflate their winnings by depositing a large sum right before contest close, and withdrawing it right after.
Vulnerability Detail
Suppose there is a tiered percentage bounty where first place wins 90% and second place wins 10%. Suppose the bounty has 1000 tokens in it.
The second-place winner can front-run the call to
closeCompetition
by depositing 9000 tokens. The contract now has 10000 tokens of funding, and the second prize winner gets 10%, or 1000. The second prize winner then immediately claims their 1000 and refunds their deposit. On net, the second-place winner gets all 1000 tokens, and the first-place winner gets nothing.If the second-place winner already has their KYC and invoice and whatnot set up so that they can call
permissionedClaimTieredBounty
, and the first-place winner does not, this can be done relatively safely.Impact
This permits winners of a single tier in a tiered-percentage bounty contest to claim the entirety of the contest instead of their fair share.
Code Snippet
Claims are awarded based on fundingTotals computed during a call to closeCompetition.
From https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/TieredPercentageBountyV1.sol#L134
Here's how it gets paid out. From https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/TieredPercentageBountyV1.sol#LL113C67-L118C71
Nothing prevents refunds from occurring after the end of a contest.
Here is a modified test exhibiting this problem:
Tool used
Manual Review
Recommendation
Unclear. One idea is to block refunds for a set period after the contest closes.
Duplicate of #275
The text was updated successfully, but these errors were encountered: