background
logo

Security Audit Report for Ref Finance's Burrowland, Ref-Dcl, Ref-Exchange

DESCRIPTION

The target of this audit is the private code repository of Burrowland, Ref-Dcl, Ref-Exchange of Ref Finance. Note that, we did NOT audit all the modules in the repository. Specifically, the files covered in this audit include: 1 burrowland/contracts/contract/src/upgrade.rs 2 burrowland/contracts/contract/src/events.rs 3 burrowland/contracts/contract/src/price_receiver.rs 4 burrowland/contracts/contract/src/legacy.rs 5 burrowland/contracts/contract/src/config.rs 6 burrowland/contracts/contract/src/lib.rs 7 burrowland/contracts/contract/src/account_view.rs 8 burrowland/contracts/contract/src/margin_actions.rs 9 burrowland/contracts/contract/src/margin_trading.rs 10 burrowland/contracts/contract/src/margin_pyth.rs 11 burrowland/contracts/contract/src/margin_config.rs 12 burrowland/contracts/contract/src/fungible_token.rs 13 burrowland/contracts/contract/src/big_decimal.rs 14 burrowland/contracts/contract/src/margin_accounts.rs 15 burrowland/contracts/contract/src/asset_config.rs 16 burrowland/contracts/contract/src/account.rs 17 burrowland/contracts/contract/src/asset_view.rs 18 burrowland/contracts/contract/src/pyth.rs 19 burrowland/contracts/contract/src/prices.rs 20 burrowland/contracts/contract/src/storage.rs 21 burrowland/contracts/contract/src/shadow_actions.rs 22 burrowland/contracts/contract/src/margin_position.rs 23 burrowland/contracts/contract/src/utils.rs 24 burrowland/contracts/contract/src/margin_base_token_limit.rs 25 burrowland/contracts/contract/src/protocol_debts.rs 26 burrowland/contracts/contract/src/storage_keys.rs 27 burrowland/contracts/contract/src/booster_staking.rs 28 burrowland/contracts/contract/src/actions.rs 29 burrowland/contracts/contract/src/client_echo.rs 30 31 ref-contracts/ref-exchange/src/account_deposit.rs 32 ref-contracts/ref-exchange/src/token_receiver.rs 1https://github.com/burrowHQ/burrowland/tree/margin_trading 2https://github.com/rhea-finance/burrowland-fix/tree/fix 3https://github.com/ref-finance/ref-dcl/tree/margin_trading 4https://github.com/ref-finance/ref-contracts/tree/margin_trading

Please refer to the report for the detailed audit scope.

Our audit methodology employs automated vulnerability scans, manual verification, and business logic analysis to uncover potential security issues coupled with gas and code quality optimization recommendations.

In summary, we have found that the codebase contains 6 high-risk issues that require prompt attention. In addition, we have identified other non-critical issues as well as recommendations and notes that should be considered. The Burrowland, Ref-Dcl, Ref-Exchange team has addressed these issues promptly. It is important to note that our audit covers only the final reported versions of the codebase. Any subsequent updates would require a re-evaluation.

KEY FINDINGS

In total, we find 14 potential issues in the smart contract. We also have 5 recommendations and 2 notes, as follows:

High Risk: 6
Medium Risk: 1
Low Risk: 7
Recommendation: 5
Note: 2
ID Severity Description Status
1 Low Failure to remove position timestamp from position_latest_actions Fixed
2 High Lack of sender account check when handling SwapReference message Fixed
3 High Lack of lock when decreasing collateral Fixed
4 High Incorrect enumeration of tokens requiring price feeds Fixed
5 Low Unreasonable pos_id design Fixed
6 Low Lack of reasonable configuration check Fixed
7 High Potential panic during handling message SwapReference Fixed
8 Low Unreasonable check of reserves Fixed
9 Low Potential sandwich attack in force close position token swap Confirmed
10 Medium Unreasonable leverage rate computation Fixed
11 Low Potential gas waste due to improper fee validation Fixed
12 High Lack of account lock check in withdrawal and collateral operations Fixed
13 Low Potential underflow in function internal_storage_balance_of() after forced storage adjustment Fixed
14 High Incorrect aggregation of intermediate swap outputs Fixed
15 - Automatically construct swap indication from the token information Confirmed
16 - Use UnorderedMap for margin_positions instead of HashMap Fixed
17 - Incorrect error message in get_token_out() Fixed
18 - Lack of check in function update_asset() Fixed
19 - Remove redundant code in function internal_decrease_collateral_for_gap() Fixed
20 - Potential centralization risks -
21 - Collateral tracking approximation due to legacy asset accounting -

More details are provided in the audit report.

Take the first step towards a secure future

Reach out now for BlockSec's expert code audit services, elevate the security of your protocol before it goes live!