Introduction
We express our gratitude to the Gable Finance team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Gable is a protocol creating the liquidity market on Radix DLT. Users can borrow funds without collateral in the form of flash loans, as well as earn staking rewards and interest earnings from supplying their tokens to the protocol.
| title | content |
|---|---|
| Platform | Radix DLT |
| Language | Rust/Scrypto |
| Tags | Staking, Flashloans |
| Timeline | 03/10/2023 - 01/11/2023 |
| Methodology | https://hackenio.cc/sc_methodology→ |
Review Scope | |
|---|---|
| Repository | https://github.com/gable-finance/gable/tree/main/src/backend/scrypto/flashloan-pool/→ |
| Commit | afeb0343533798020630fcf45432abce7580b7e8 |
Review Scope
- Commit
- afeb0343533798020630fcf45432abce7580b7e8
Audit Summary
10/10
66.66%
10/10
10/10
The system users should acknowledge all the risks summed up in the risks section of the report
Document Information
This report may contain confidential information about IT systems and the intellectual property of the Customer, as well as information about potential vulnerabilities and methods of their exploitation.
The report can be disclosed publicly after prior consent by another Party. Any subsequent publication of this report shall be without mandatory consent.
Document | |
|---|---|
| Name | Smart Contract Code Review and Security Analysis Report for Gable Finance |
| Audited By | Hacken |
| Website | https://gable.finance/→ |
| Changelog | 10/10/2023 - Initial Review |
| 01/11/2023 - Second Review |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for Gable Finance
- Audited By
- Hacken
- Website
- https://gable.finance/→
- Changelog
- 10/10/2023 - Initial Review
- 01/11/2023 - Second Review
System Overview
Gable is a protocol creating the liquidity market on Radix DLT. Users can borrow funds without collateral in the form of flash loans, as well as earn staking rewards and interest earnings from supplying their tokens to the protocol.
Users that are staking XRD on the Gable validator receive liquid staking units (LSU tokens) that can be deposited in the flashloan pool to earn some interest.
Borrowers that take loans repay it with some interest that is then split 50-50 between the users that deposited LSU and the smart contract owner.
Privileged roles
The owner of the contract could perform multiple administrative changes, like changing interest rates, updating suppliers key value store, deposit and withdraw liquidity to the pool directly, depositing and withdrawing validator node ownership token, as well as perform unstaking and claiming operations.
The admin role can perform most of the owner’s actions, except from depositing and withdrawing liquidity and validator node ownership token.
Executive Summary
Documentation quality
The total Documentation quality score is 10 out of 10.
Functional and technical requirements were provided.
Technical description and diagrams were provided.
The code implements complex calculations logic with small amounts of descriptions and requirements.
Code quality
The total Code quality score is 10 out of 10.
The development environment is configured.
The code is readable and easy to digest.
Most of the methods are described with appropriate comments.
Test cases are well described with requirements.
Test coverage
Code coverage of the project could not be directly calculated with common tools likely due to the lack of support for Scrypto. Nevertheless, taking into account the functional coverage and the number of tests available in the code repository, the tests cover approximately 66.66% of the codebase.
Deployment and basic user interactions are covered with tests.
Negative cases coverage is missed.
Interaction with validator and methods associated with these operation are not covered
Security score
Upon auditing, the code was found to contain 0 critical, 1 high, 2 medium, and 5 low severity issues. Out of these, 8 issues have been addressed and resolved, leading to a Security score of 10 out of 10.
All identified issues are detailed in the “Findings” section of this report.
Summary
The comprehensive audit of the customer's smart contract yields an overall score of 8.7. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.
Risks
The smart contract could be upgraded and its functionality may be changed.
Centralization and the owner's ability to withdraw the whole liquidity from the pool might be dangerous, if his wallet/badge will be compromised.
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2023-0151 | Owner could withdraw more than he has deposited as owner_liquidity | fixed | High | |
| F-2023-0153 | Missing validations in multiple calculations could lead to unexpected state | fixed | Medium | |
| F-2023-0152 | Missing upper bound on interest rate change | fixed | Medium | |
| F-2023-0158 | Test functions should be removed | fixed | Low | |
| F-2023-0157 | Floating Language Version | fixed | Low | |
| F-2023-0156 | Wrong limit for the size of box | fixed | Low | |
| F-2023-0155 | Owner is able to unlock and update royalties for function calls | fixed | Low | |
| F-2023-0154 | Macros used for debugging should not be used in production code | fixed | Low | |
| I-2023-0042 | Former name is mentioned | fixed | Observation | |
| I-2023-0041 | Suggestions for idiomatic code style | fixed | Observation |
Appendix 1. Severity Definitions
When auditing smart contracts, Hacken is using a risk-based approach that considers Likelihood, Impact, Exploitability and Complexity metrics to evaluate findings and score severities.
Reference on how risk scoring is done is available through the repository in our Github organization:
Severity | Description |
|---|---|
Critical | Critical vulnerabilities are usually straightforward to exploit and can lead to the loss of user funds or contract state manipulation. |
High | High vulnerabilities are usually harder to exploit, requiring specific conditions, or have a more limited scope, but can still lead to the loss of user funds or contract state manipulation. |
Medium | Medium vulnerabilities are usually limited to state manipulations and, in most cases, cannot lead to asset loss. Contradictions and requirements violations. Major deviations from best practices are also in this category. |
Low | Major deviations from best practices or major Gas inefficiency. These issues will not have a significant impact on code execution, do not affect security score but can affect code quality score. |
Severity
- Critical
Description
- Critical vulnerabilities are usually straightforward to exploit and can lead to the loss of user funds or contract state manipulation.
Severity
- High
Description
- High vulnerabilities are usually harder to exploit, requiring specific conditions, or have a more limited scope, but can still lead to the loss of user funds or contract state manipulation.
Severity
- Medium
Description
- Medium vulnerabilities are usually limited to state manipulations and, in most cases, cannot lead to asset loss. Contradictions and requirements violations. Major deviations from best practices are also in this category.
Severity
- Low
Description
- Major deviations from best practices or major Gas inefficiency. These issues will not have a significant impact on code execution, do not affect security score but can affect code quality score.
Appendix 2. Scope
The scope of the project includes the following smart contracts from the provided repository:
Scope Details | |
|---|---|
| Repository | https://github.com/gable-finance/gable/tree/main/src/backend/scrypto/flashloan-pool/→ |
| Commit | afeb0343533798020630fcf45432abce7580b7e8 |
| Whitepaper | Provided→ |
| Requirements | Provided→ |
| Technical Requirements | Provided→ |