deBridge_Cross_Chain_Forwarder_Update_Smart_Contract_Security_Audit
deBridge_Cross_Chain_Forwarder_Update_Smart_Contract_Security_Audit
CrosschainForwarder
Update
Smart Contract Security Audit
3.1 (HAL-01) LOW LEVEL CALLS WITH SOLIDITY VERSION 0.8.7 CAN RESULT
IN OPTIMIZER BUG - LOW 13
Description 13
Code Location 13
Risk Level 13
Recommendation 13
Remediation Plan 13
Description 14
Risk Level 14
Code Location 14
Recommendation 14
Remediation Plan 15
Description 16
1
Code Location 16
TO-DO 16
Risk Level 16
Recommendation 16
Remediation Plan 16
Description 17
Risk Level 17
Recommendation 17
Remediation Plan 17
Description 18
Risk Level 18
Code Location 18
Recommendation 18
Remediation Plan 18
Description 19
Risk Level 19
Code Location 19
Recommendation 19
Remediation Plan 20
Description 21
Risk Level 21
2
Code Location 21
Recommendation 22
Remediation Plan 22
3
DOCUMENT REVISION HISTORY
CONTACTS
4
EXECUTIVE OVERVIEW
5
1.1 INTRODUCTION
deBridge engaged Halborn to conduct a security assessment on their smart
contract update beginning on July 17th, 2022 and ending July 25th, 2022.
deBridge a cross-chain interoperability and liquidity transfer proto-
col that allows truly decentralized transfer of assets between various
blockchains. deBridge is a cross-chain interoperability and liquidity
transfer protocol that allows decentralized transfer of assets between
blockchains.
6
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:
7
4 - May cause a significant level of impact or loss.
3 - May cause a partial impact or loss to many.
2 - May cause temporary impact or loss.
1 - May cause minimal or un-noticeable impact.
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
The review was scoped to only changes applied to the contracts/Cross-
chainForwarder.sol:
Commit
Smart contracts:
• CrossChainForwarder.sol
9
2. ASSESSMENT SUMMARY & FINDINGS
OVERVIEW
0 0 0 1 6
LIKELIHOOD
IMPACT
(HAL-01)
(HAL-02)
EXECUTIVE OVERVIEW
(HAL-03)
(HAL-04)
(HAL-05)
(HAL-06)
(HAL-07)
10
SECURITY ANALYSIS RISK LEVEL REMEDIATION DATE
11
FINDINGS & TECH
DETAILS
12
3.1 (HAL-01) LOW LEVEL CALLS WITH
SOLIDITY VERSION 0.8.7 CAN RESULT
IN OPTIMIZER BUG - LOW
Description:
Using low-level calls with solidity version 0.8.7 which can result in
optimizer bug. The bug can detail can be seen from the following LINK
Code Location:
Listing 1
1 pragma solidity 0.8.7;
Risk Level:
FINDINGS & TECH DETAILS
Likelihood - 1
Impact - 3
Recommendation:
Remediation Plan:
RISK ACCEPTED: The deBridge team accepted the risk of this finding.
13
3.2 (HAL-02) USE
DISABLEINITIALIZERS IN THE
UPGRADABLE CONTRACTS -
INFORMATIONAL
Description:
Risk Level:
Likelihood - 1
Impact - 2
FINDINGS & TECH DETAILS
Code Location:
Location
Listing 2: CrosschainForwarder.sol
39 function initialize ( IDeBridgeGate _deBridgeGate ) external
ë initializer {
40 ForwarderBase . initializeBase () ;
41 deBridgeGate = _deBridgeGate ;
42 }
Recommendation:
14
front-runner is not directly benefiting from executing the transaction
itself. For future, consider calling OZ’s _disableInitializers() in
the implementation contract’s constructor. Use the same name for both
arguments.
Remediation Plan:
15
3.3 (HAL-03) OPEN TODOs -
INFORMATIONAL
Description:
Code Location:
TO-DO:
Risk Level:
Likelihood - 1
Impact - 1
Recommendation:
Remediation Plan:
16
3.4 (HAL-04) LACK OF PAUSE/UNPAUSE
FUNCTIONALITY - INFORMATIONAL
Description:
Risk Level:
Likelihood - 1
Impact - 1
FINDINGS & TECH DETAILS
Recommendation:
Pause functionality on the contract would have helped secure the funds
quickly.
Remediation Plan:
17
3.5 (HAL-05) OPTIMIZE UNSIGNED
INTEGER COMPARISON - INFORMATIONAL
Description:
The check != 0 costs less gas compared to > 0 for unsigned integers in
require statements with the optimizer enabled. While it may seem that
> 0 is cheaper than !=0, this is only true without the optimizer enabled
and outside a require statement. If the optimizer is enabled at 10k and
It is in a require statement, that would be more gas efficient.
Risk Level:
Likelihood - 1
Impact - 1
Code Location:
FINDINGS & TECH DETAILS
Location
Listing 4: CrosschainForwarder.sol
140 if ( _affiliateFeeAmount > 0 && _affiliateFeeRecipient !=
ë address (0) ) {
141 ...
Recommendation:
Remediation Plan:
18
3.6 (HAL-06) GATEPARAMS ARE NOT
VALIDATED - INFORMATIONAL
Description:
During the new commit review, It has been observed that GateParams has been
given as a function parameter on the bridge functionalities. However, in
the CrossChainForwarder contract, chainId and other parameters are not
validated.
Risk Level:
Likelihood - 1
Impact - 1
Code Location:
Location
FINDINGS & TECH DETAILS
Listing 5: ICrossChainForwarder.sol
1 struct GateParams {
2 uint256 chainId ;
3 address receiver ;
4 bool useAssetFee ;
5 uint32 referralCode ;
6 bytes autoParams ;
7 }
8
Recommendation:
19
Remediation Plan:
20
3.7 (HAL-07) OUT OF DATE
OPENZEPPELIN PACKAGES -
INFORMATIONAL
Description:
Risk Level:
Likelihood - 1
Impact - 1
FINDINGS & TECH DETAILS
Code Location:
Location
Listing 6: package.json
1 " dependencies ": {
2 " @openzeppelin / contracts " : " ^4.4.2 " ,
3 " @openzeppelin / contracts - upgradeable ": " ^4.4.2 " ,
4 " @openzeppelin / hardhat - upgrades ": " ^1.14.0 " ,
5 " dotenv " : " ^15.0.0 " ,
6 " hardhat ": " ^2.8.3 " ,
7 " hardhat - deploy " : " ^0.11.0 " ,
8 " node - fetch ": " ^2.6.7 " ,
9 " prettier " : " ^2.5.1 " ,
10 " prettier - plugin - solidity ": " ^1.0.0 - beta .19 " ,
11 " solhint ": " ^3.3.6 "
12 },
21
Recommendation:
Remediation Plan:
22
THANK YOU FOR CHOOSING