chore(contracts): fixed critical security issues #59
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.
Security Fix
Reentrancy Attack Vulnerability
The
claimReward()
function calls an external contractrewardToken.transfer()
, which may cause a reentrancy attack if the external contract is malicious or vulnerable. An attacker can exploit this vulnerability to re-enter the vulnerable function before the execution is complete, and therefore manipulate the contract state.Denial of Service (DoS) Vulnerability
The
isEpochFunded()
function may cause a denial of service vulnerability since it loops through all the past epochs to calculate whether the current epoch is funded or not. If the number of past epochs becomes very large, the function may consume an excessive amount of gas and fail to execute, thereby preventing other legitimate functions from executing.The
removePriority()
function has been improved by adding a mechanism to prevent the removal of priorities during a voting period, which could potentially lead to vote manipulation.The onlyOwner modifier has also been omitted, I think we can add the one from OpenZeppelin.
How Has This Been Tested?
Sector#3 Contribution