VE3DRewardPool
and VE3DLocker
adds to an unbounded array which may potentially lock all rewards in the contract
#136
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
disagree with severity
Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments)
Lines of code
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L102-L112
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DLocker.sol#L145-L172
Vulnerability details
Impact
The function
addReward()
allows the owner to add a new reward token to the listrewardTokens
.However, this is an unbounded list that when appended to cannot be shortened. The impact is it is possible to reach a state where the list is so long it cannot be iterated through due to the gas cost being larger than the block gas limit. This would cause a state where all transactions which iterate over this list will revert.
Since the modifier
updateReward()
iterates over this list it is possible that there will reach a state where the we are unable to call any functions with this modifier. The list includesstake()
stakeAll()
stakeFor()
withdraw()
withdrawAll()
getReward()
notifyRewardAmount()
As a result it would therefore be impossible to withdraw any rewards from this contract.
The same issue exists in
VE3DLocker
. Where rewards can be added by eitherBooster
or the owner.Proof of Concept
Recommended Mitigation Steps
Consider having some method for removing old reward tokens which are no longer in use.
Alternatively set a hard limit on the number of reward tokens that can be added.
A different option is too allow rewards to be iterated and distributed on a per token bases rather than all tokens at once.
The text was updated successfully, but these errors were encountered: