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` labelHighA valid High severity issueRewardA payout will be made for this issue
/// @notice Returns the amount of locked tokens (of a specific token) on a bounty address, only available for claims but not for refunds
/// @param _depositId The depositId that determines which token is being looked at
/// @return uint256
function getLockedFunds(address _depositId)
public
view
virtual
returns (uint256)
{
uint256 lockedFunds;
bytes32[] memory depList = this.getDeposits();
for (uint256 i = 0; i < depList.length; i++) {
if (
block.timestamp <
depositTime[depList[i]] + expiration[depList[i]] &&
tokenAddress[depList[i]] == _depositId
) {
lockedFunds += volume[depList[i]];
}
}
return lockedFunds;
}
this for loop needs to iterate over all result returned from getDeposits function.
/// @notice Returns an array of all deposits (ERC20, protocol token, and NFT) for this bounty/// @return deposits The array of deposits including ERC20, protocol token, and NFTfunction getDeposits() externalviewvirtualreturns (bytes32[] memory) {
return deposits;
}
The issue is the size of the deposit array can increase and grow in no upper limit. The size of the deposits array increase when receiveFund or receiveNFT is called:
An adversary can easiily spam and increase the size of the deposits array by keep depositing only 1 wei of fund and repeat the 1 wei deposit fundBounty transaction for maybe 100 times or 1000 times, which grows the size of the deposits.
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` labelHighA valid High severity issueRewardA payout will be made for this issue
ctf_sec
medium
Unbounded gas consumption When calling BountyCore#getLockedFunds
Summary
Unbounded gas consumption When calling BountyCore#getDeposits
Vulnerability Detail
In the current implementation, when request refund via DepositManager.sol, available fund need to be calculated.
note the function call:
Which calls bounty.getLockedFunds:
this for loop needs to iterate over all result returned from getDeposits function.
The issue is the size of the deposit array can increase and grow in no upper limit. The size of the deposits array increase when receiveFund or receiveNFT is called:
Basically when calling the function receiveFunds:
which is called by DepositManager#fundBountyToken
An adversary can easiily spam and increase the size of the deposits array by keep depositing only 1 wei of fund and repeat the 1 wei deposit fundBounty transaction for maybe 100 times or 1000 times, which grows the size of the deposits.
Impact
BountyCore#getDeposits can run out of gas.
Code Snippet
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/BountyCore.sol#L329-L352
Tool used
Manual Review
Recommendation
We recommend the protocol set minimum fund deposit threshold when fund the bounty contract.
Duplicate of #77
The text was updated successfully, but these errors were encountered: