fix h01: address issue in recoverErc20 function #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
H-01 Anyone can prevent stakers from getting their rewards
The recoverErc20 function is meant to facilitate the recovery of any ERC20 tokens that maybe mistakenly sent to the AcceleratingDistributor contract. As this is a public function
with no modifiers, anyone can call this function to transfer an ERC20 token from the AcceleratingDistributor contract to the owner of AcceleratingDistributor . The
only ERC20 tokens that are explicitly disallowed from being recovered are stakedToken that have already been initialized in the system.
However, it is currently possible to recover the ERC20 rewardToken using the recoverErc20 function. Doing so would transfer some specified amount of rewardToken
from the AcceleratingDistributor contract to the contract's owner. This would, subsequently, prevent stakers from being able to access their rewards because
AcceleratingDistributor could be left with an insufficient balance of rewardToken s.
Even if the owner were to send rewardToken s back to the AcceleratingDistributor
contract, a malicious actor could immediately transfer all of the rewardTokens back to the
owner. Redeployment would be necessary to fix the issue.
Solution:
An additional modifier was added to check the
tokenAddress
in therecoverErc20
method is not the reward token. Tests were also updated