This repository has been archived by the owner on May 26, 2023. It is now read-only.
CodeFoxInc - Refund during claiming process can cause malfunction #397
Labels
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
High
A valid High severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
CodeFoxInc
high
Refund during claiming process can cause malfunction
Summary
The
fundingTotals
are calculated at the time of the first claim, so if adepositRefund
occurs after that, there will be insufficient funds for claiming. It means people who should get the bounty cannot get it. The protocol breaks.In the worst case scenario, all of the original funds can be removed without the permission of the claimants.
Vulnerability Detail
There are several scenarios in this situation. And I would like to explain them.
Normal case
The function
claimTiered
inTieredPercentageBountyV1
is called for each Tier, but the value offundingTotals
used in its calculation is save as a fixed value at the first claim. Therefore, if a deposit refund is made after the first claim, subsequent users will not receive the appropriate amount of rewards and suffer.Advanced case
With
permissionedClaimTieredBounty()
, the timing of claiming is arbitrary to the user, so it is considered possible to claim first. Also, if you use the overflow attack, which I have in #5, you can be sure to be the first to claim, even if you are in a lower position tier.Furthermore, if a large amount of token is funded just before the first claim, the first person to make a claim can take advantage of the calculation and take away all of the funds that were originally deposited. He can get this part of deposit which is not supposed to belong to him.
The worst-case scenario story goes like this(please check with the attacking script):
fundBountyToken
function to deposit 9,000 token. And he sets theexpiration
to be 1. (The total amount becomes 10,000)claimBounty
function. He managed to get 10 times of the reward he deserved to get.depositRefund
function to refund all the token he had deposited, which is 9,000 token.As a result of this:
Impact
Funds deposited in the bounty can be taken over by attacker. Also, other tier winners may not receive the rewards they deserved.
Attacking script
To regenerate the attack, please put this test script into the test file
ClaimManager.test.js
after this line of code.Code Snippet
These require statements are not sufficient.
BountyCore.sol#L64-L74
Tool used
Manual Review
Recommendation
We recommend that the expiration of the deposit be set fixed to give enough period of time for the tier winner to make a claim.
Alternatively, after close competition, it is possible to set up a flag that prevents refunds for a certain period of time.
Duplicate of #266
The text was updated successfully, but these errors were encountered: