You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 26, 2023. It is now read-only.
github-actionsbot opened this issue
Feb 21, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
function setPayoutScheduleFixed(
uint256[] calldata_payoutSchedule,
address_payoutTokenAddress
) external onlyOpenQ {
require(
bountyType == OpenQDefinitions.TIERED_FIXED,
Errors.NOT_A_FIXED_TIERED_BOUNTY
);
payoutSchedule = _payoutSchedule;
payoutTokenAddress = _payoutTokenAddress;
// Resize metadata arrays and copy current members to new array// NOTE: If resizing to fewer tiers than previously, the final indexes will be removedstring[] memory newTierWinners =newstring[](payoutSchedule.length);
bool[] memory newInvoiceComplete =newbool[](payoutSchedule.length);
bool[] memory newSupportingDocumentsCompleted =newbool[](
payoutSchedule.length
);
for (uint256 i =0; i < tierWinners.length; i++) {
newTierWinners[i] = tierWinners[i];
}
tierWinners = newTierWinners;
for (uint256 i =0; i < invoiceComplete.length; i++) {
newInvoiceComplete[i] = invoiceComplete[i];
}
invoiceComplete = newInvoiceComplete;
for (uint256 i =0; i < supportingDocumentsComplete.length; i++) {
newSupportingDocumentsCompleted[i] = supportingDocumentsComplete[i];
}
supportingDocumentsComplete = newSupportingDocumentsCompleted;
}
In case if new payoutSchedule is less than previous value(that was set on init), then this function will revert with array out of bounds error, because all loops are iterating using length of previous `payoutSchedule.
You will receive such error: Error: VM Exception while processing transaction: reverted with panic code 0x32 (Array accessed at an out-of-bounds or negative index)
Also same issue exists inside TieredPercentageBountyV1.setPayoutSchedule and i am not sure if i should create it as separate report or use only one.
Impact
It's not possible to decrease amount of tiers.
Code Snippet
Provided above
Tool used
Manual Review
Recommendation
Use _payoutSchedule.length to iterate through new arrays.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
rvierdiiev
medium
TieredFixedBountyV1.setPayoutScheduleFixed will fail in case issuer wants to make less amount of tiers
Summary
TieredFixedBountyV1.setPayoutScheduleFixed will fail in case issuer wants to make less amount of tiers
Vulnerability Detail
TieredFixedBountyV1.setPayoutScheduleFixed allows to provide new
_payoutSchedule
to the bounty. This should update values insidetierWinners
,invoiceComplete
,supportingDocumentsComplete
arrays.https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/TieredFixedBountyV1.sol#L138-L171
In case if new
payoutSchedule
is less than previous value(that was set on init), then this function will revert witharray out of bounds
error, because all loops are iterating using length of previous `payoutSchedule.Add this test to OpenQ.test.js
You will receive such error:
Error: VM Exception while processing transaction: reverted with panic code 0x32 (Array accessed at an out-of-bounds or negative index)
Also same issue exists inside
TieredPercentageBountyV1.setPayoutSchedule
and i am not sure if i should create it as separate report or use only one.Impact
It's not possible to decrease amount of tiers.
Code Snippet
Provided above
Tool used
Manual Review
Recommendation
Use
_payoutSchedule.length
to iterate through new arrays.Duplicate of #244
The text was updated successfully, but these errors were encountered: