EasyFi Network Staking Smart Contract Security Audit by Halborn Security - June 2021
EasyFi Network Staking Smart Contract Security Audit by Halborn Security - June 2021
EasyFi Network Staking Smart Contract Security Audit by Halborn Security - June 2021
Contracts
Smart Contract Security Audit
Description 13
Code Location 13
Risk Level 13
Recommendations 13
Remediation Plan 13
Description 14
Code Location 14
Risk Level 14
Recommendations 14
Remediation Plan 14
Description 15
1
Code Location 15
Risk Level 16
Recommendation 16
Remediation Plan 17
Description 18
Code Location 18
Risk Level 19
Recommendation 19
Remediation Plan 20
Description 21
Risk Level 21
Recommendation 21
Remediation Plan 21
Description 22
Recommendation 22
Remediation Plan 22
4 AUTOMATED TESTING 23
4.1 STATIC ANALYSIS REPORT 24
Description 24
Results 24
4.2 AUTOMATED SECURITY SCAN 25
Description 25
Results 25
2
3
DOCUMENT REVISION HISTORY
CONTACTS
4
EXECUTIVE OVERVIEW
5
1.1 INTRODUCTION
stakingFactory is the staking implementation done by EasyFi. EasyFi
engaged Halborn to conduct a security audit on their stakingFactory smart
contract beginning on June 14th, 2021 and ending June 18th, 2021. The
security assessment was scoped to the smart contract provided in the
Github repository EasyFi Staking Smart Contract.
6
1.3 TEST APPROACH & METHODOLOGY
Halborn performed a combination of manual and automated security testing
to balance efficiency, timeliness, practicality, and accuracy in regard to
the scope of the smart contract audit.While manual testing is recommended
to uncover flaws in logic, process,and implementation; automated testing
techniques help enhance coverage of smart contracts and can quickly
identify items that do not follow security best practices. The following
phases and associated tools were used throughout the term of the audit:
RISK METHODOLOGY:
EXECUTIVE OVERVIEW
7
3 - Potential of a security incident in the long term.
2 - Low probability of an incident occurring.
1 - Very unlikely issue will cause an incident.
The risk level is then calculated using a sum of these two values, creating
a value of 10 to 1 with 10 being the highest level of security risk.
10 - CRITICAL
9 - 8 - HIGH
7 - 6 - MEDIUM
5 - 4 - LOW
3 - 1 - VERY LOW AND INFORMATIONAL
EXECUTIVE OVERVIEW
8
1.4 SCOPE
IN-SCOPE:
Code related to staking/stakingFactory.sol smart contract.
6d3548851c6499c2a1ea12f8a7393b0b4f34304d
e2b4cd89c75ce9171007bd241859aabf2adf633c
9
2. ASSESSMENT SUMMARY & FINDINGS
OVERVIEW
0 0 0 2 4
LIKELIHOOD
IMPACT
(HAL-01)
(HAL-02)
(HAL-03)
EXECUTIVE OVERVIEW
(HAL-04)
(HAL-05)
(HAL-06)
10
SECURITY ANALYSIS RISK LEVEL REMEDIATION DATE
11
FINDINGS & TECH
DETAILS
12
3.1 (HAL-01) PRAGMA VERSION
DEPRECATED - LOW
Description:
The current version in use for the contract is pragma ^0.5.16. While this
version is still functional, and most security issues safely implemented
by mitigating contracts with other utility contracts such as SafeMath.sol
and ReentrancyGuard.sol, the risk to the long-term sustainability and
integrity of the solidity code increases.
Code Location:
Risk Level:
Likelihood - 1
Impact - 3
Recommendations:
Remediation Plan:
13
3.2 (HAL-02) FLOATING PRAGMA - LOW
Description:
Code Location:
Risk Level:
Likelihood - 1
Impact - 3
Recommendations:
Remediation Plan:
14
3.3 (HAL-03) MISSING BOUND CHECK -
INFORMATIONAL
Description:
Code Location:
624
625 } else {
626
627 uint256 remaining = periodFinish . sub ( block . timestamp );
628
629 uint256 leftover = remaining . mul ( rewardRate ) ;
630
631 rewardRate = reward . add ( leftover ) . div ( rewardsDuration )
;
632
633 }
634
635
636
637 // Ensure the provided reward amount is not more than the
balance in the contract .
638
639 // This keeps the reward rate in the right range ,
preventing overflows due to
640
15
641 // very high values of rewardRate in the earned and
rewardsPerToken functions ;
642
643 // Reward + leftover must be less than 2^256 / 10^18 to
avoid overflow .
644
645 uint balance = rewardsToken . balanceOf ( address ( this ) ) ;
646
647 require ( rewardRate <= balance . div ( rewardsDuration ) , "
Provided reward too high ") ;
648
649
650
651 lastUpdateTime = block . timestamp ;
652
653 periodFinish = block . timestamp . add ( rewardsDuration ) ;
654
655 emit RewardAdded ( reward );
656
657 }
Risk Level:
FINDINGS & TECH DETAILS
Likelihood - 1
Impact - 2
Recommendation:
Listing 4
1 require ( reward >= rewardsDuration , " Reward is too small ") ;
Listing 5
1 require ( reward . add ( leftover ) >= rewardsDuration , " Reward is too
small ") ;
16
Remediation Plan:
17
3.4 (HAL-04) INTEGER OVERFLOW -
INFORMATIONAL
Description:
Code Location:
622
623 rewardRate = reward . div ( rewardsDuration );
624
625 } else {
626
627 uint256 remaining = periodFinish . sub ( block . timestamp );
628
629 uint256 leftover = remaining . mul ( rewardRate ) ;
630
631 rewardRate = reward . add ( leftover ) . div ( rewardsDuration )
;
632
633 }
634
635
636
637 // Ensure the provided reward amount is not more than the
balance in the contract .
638
18
639 // This keeps the reward rate in the right range ,
preventing overflows due to
640
641 // very high values of rewardRate in the earned and
rewardsPerToken functions ;
642
643 // Reward + leftover must be less than 2^256 / 10^18 to
avoid overflow .
644
645 uint balance = rewardsToken . balanceOf ( address ( this ) ) ;
646
647 require ( rewardRate <= balance . div ( rewardsDuration ) , "
Provided reward too high ") ;
648
649
650
651 lastUpdateTime = block . timestamp ;
652
653 periodFinish = block . timestamp . add ( rewardsDuration ) ;
654
655 emit RewardAdded ( reward );
656
657 }
FINDINGS & TECH DETAILS
Risk Level:
Likelihood - 1
Impact - 2
Recommendation:
Listing 7
1 require ( reward < uint ( -1) . div (1 e18 ) , " Reward overflow ") ;
19
Remediation Plan:
20
3.5 (HAL-05) NO TEST COVERAGE -
INFORMATIONAL
Description:
References:
https://github.com/mochajs/mocha
https://github.com/chaijs/chai
https://docs.openzeppelin.com/learn/writing-automated-tests
FINDINGS & TECH DETAILS
Risk Level:
Likelihood - 1
Impact - 2
Recommendation:
Remediation Plan:
21
3.6 (HAL-06) DOCUMENTATION -
INFORMATIONAL
Description:
Recommendation:
Remediation Plan:
FINDINGS & TECH DETAILS
22
AUTOMATED TESTING
23
4.1 STATIC ANALYSIS REPORT
Description:
Results:
24
4.2 AUTOMATED SECURITY SCAN
Description:
Results:
AUTOMATED TESTING
25
THANK YOU FOR CHOOSING