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
Refund a Deposit will failed because of unbounded deposits array.
Summary
Refund a deposit will failed because of unbounded deposit array.
Vulnerability Detail
OpenQ is permissionless, anyone can fund a contest. When someone deposit a fund to the bounty, they will call fundBountyToken in DepositManager then calling receiveFunds on the Bounty contract. This call will eventually increase the deposits array length.
(deposits.push(depositId);)
Any malicious actor can just send a dust amount of valid (whitelisted) ERC20 token to increase this deposits array (for example 0.000001 USDC). Moreover, the attacker can just use the native coin (ETH) (by providing zero as token address) and send the msg.value to 0, (since the msg.value is not being checked if it's > 0), therefore the attack cost is really cheap. (ignoring the transaction fee).
If the deposits array length is large enough, at some point the getLockedFunds function will be reverted because out of gas, because a for loop with length is depList.length (deposits length).
this getLockedFunds is being called by refundDeposit function, so any refund will be failed.
Impact
User can't refund their deposit, locked on the contract, loss asset.
To battle this issue, it's best to limit the deposits array length to some max length, just like NFT deposit but make it larger, for example 100 deposits or 500 deposits.
Moreover, prevent the deposit if the msg.value = 0 or at least set the minimum deposit value so any small / dust token amount should be rejected.
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
chainNue
high
Refund a Deposit will failed because of unbounded
deposits
array.Summary
Refund a deposit will failed because of unbounded deposit array.
Vulnerability Detail
OpenQ is permissionless, anyone can fund a contest. When someone deposit a fund to the bounty, they will call
fundBountyToken
inDepositManager
then callingreceiveFunds
on theBounty
contract. This call will eventually increase thedeposits
array length.(
deposits.push(depositId);
)Any malicious actor can just send a dust amount of valid (whitelisted) ERC20 token to increase this
deposits
array (for example 0.000001 USDC). Moreover, the attacker can just use the native coin (ETH) (by providing zero as token address) and send themsg.value
to 0, (since themsg.value
is not being checked if it's > 0), therefore the attack cost is really cheap. (ignoring the transaction fee).If the
deposits
array length is large enough, at some point thegetLockedFunds
function will be reverted because out of gas, because a for loop with length isdepList.length
(deposits length).this
getLockedFunds
is being called byrefundDeposit
function, so any refund will be failed.Impact
User can't refund their deposit, locked on the contract, loss asset.
Code Snippet
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/DepositManager/Implementations/DepositManagerV1.sol#L172
Tool used
Manual Review
Recommendation
To battle this issue, it's best to limit the deposits array length to some max length, just like NFT deposit but make it larger, for example 100 deposits or 500 deposits.
Moreover, prevent the deposit if the msg.value = 0 or at least set the minimum deposit value so any small / dust token amount should be rejected.
Duplicate of #77
The text was updated successfully, but these errors were encountered: