This repository has been archived by the owner on May 26, 2023. It is now read-only.
ctf_sec - Bounty Claim can revert in error insufficient balance #189
Labels
Disagree With Severity
The sponsor disputed the severity of this issue
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
Low/Info
A valid Low/Informational severity issue
Non-Reward
This issue will not receive a payout
Will Fix
The sponsor confirmed this issue will be fixed
ctf_sec
medium
Bounty Claim can revert in error insufficient balance
Summary
Bounty Claim can revert in error insufficient balance
Vulnerability Detail
In the current implementation, the bounty issue can call the function below setPayout to change payout token and payout volume.
However, the ongoing bounty claim and ongoing bounty refund can be impacted.
When the claim function is called on OngoingBoutyV1.sol
note the line:
_transferToken(payoutTokenAddress, payoutVolume, _payoutAddress);
For example, in the beginning, the bounty issuer set payout token to USDC and payout volume to 100 USDC.
A bounty funder fund the onGoingBounty contract with 300 USDC.
Two developers claim the bounty from ongoing bounty via ClaimManager.sol and claim total 200 USDC.
Then the bounty issuer changes the payout volume to 60 USDC.
Another developer claim 60 USDC from the contract, at this time, there are 40 USDC left in the contract, but if another developer wants to claim 60 USDC, the transaction reverts because there is an insufficient balance left in the bounty contract.
The same issue happens when claiming TieredFixedBounty and TieredPercentageBounty
In TieredFixedBounty, if the contract balance belows the “claimedBalance”, transaction revert in insufficient balance. And adjusting payoutSchedule of the tier can impact the claim function to make the transaction revert in insufficient balance.
In TieredPercentageBountV1.sol. if the contract balance belows the “claimedBalance”, transaction revert in insufficient balance. And adjusting payoutSchedule of the tier can impact the claim function to make the transaction revert in insufficient balance.
Impact
Bounty Claim can revert in error insufficient balance because adjustment of the payout volume and payout schedule impact the ongoing bounty claim.
Code Snippet
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/OngoingBountyV1.sol#L91-L113
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/TieredFixedBountyV1.sol#L87-L108
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/TieredPercentageBountyV1.sol#L98-L121
Tool used
Manual Review
Recommendation
We recommend the protocol map the claim id to the eligible claim amount.
For example, mapping claim id 1 to payout volume 100 USDC.
If there are 60 USDC in the bounty contract, let the developer claim the 60 USDC and decrease and update the mapping: now the eligible amount for developer using claim id 100 USDC (payout volume) - 60 USDC (claimed amount) = 40 USDC, then next time the developer can use the claim id to claim 40 USDC (or less than 40 USDC).
Duplicate of #272
The text was updated successfully, but these errors were encountered: