This repository has been archived by the owner on May 26, 2023. It is now read-only.
TrungOre - Function BountyCore.receiveFunds
forget checking msg.value > 0
when tokenAddress == address(0)
#176
Labels
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
Escalation Resolved
This issue's escalations have been approved/rejected
High
A valid High severity issue
Reward
A payout will be made for this issue
TrungOre
high
Function
BountyCore.receiveFunds
forget checkingmsg.value > 0
whentokenAddress == address(0)
Summary
Attacker can call
BountyCore.receiveFunds()
with_tokenAddress = address(0)
,volume > 0
andmsg.value = 0
which can incur some issues for the users.Vulnerability Detail
Function
BounttyCore.receiveFunds()
have a check whether_volume > 0
to make sure no1 can call this function without contributing any tokens into the bounty. Unfortunately this check will be true with normal ERC20 tokens not with the native one since the implementation doesn't require themsg.value == volume
.So users can call this function without paying anything by using the parameter as follows:
msg.value = 0
_volume = x > 0
_tokenAddress = address(0)
With this flaw, attacker can:
BountyCore.deposits[]
array grow massively. This will make the functionBountyCore.getLockedFunds()
out-of-gas to call which will incur the DDOS when funder try to callDepositManagerV1.refundDeposit()
to claim their deposits back.BountyCore.getLockedFunds()
is out-of-gas because it loops through the entiredeposits[]
array which is very largeDepositManagerV1.refundDeposit()
is DDOS because it calls to functionBountyCore.getLockedFunds()
to get the total locked funds.openQTokenWhitelist.TOKEN_ADDRESS_LIMIT() == 1
, attacker can front-run to take a slot of ETH inBountyCore.tokenAddresses[]
. In case the issuer of bounty wants to fund the competitor with non-whitelisted token, (s)he can't do that because when he callDepositManagerV1.fundBountyToken()
it will revert since the token addresses limit is reached.Impact
Code Snippet
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/BountyCore.sol#L34
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/BountyCore.sol#L41-L42
Tool used
Manual review
Recommendation
Modify
BountyCore.receiveFunds()
as follows:Duplicate of #77
The text was updated successfully, but these errors were encountered: