iosiro was commissioned by Synthetix to conduct a smart contract audit of their Alpheratz Release, which included the following components:
This report is organized into the following sections.
The information in this report should be used to understand the smart contracts' risk exposure better and as a guide to improving the security posture of the smart contracts by remediating issues identified. The results of this audit reflect the in-scope source code reviewed at the time of the audit.
The purpose of this audit was to achieve the following:
Assessing the off-chain functionality associated with the contracts, for example, backend web application code, was outside of the scope of this audit.
Due to the unregulated nature and ease of transfer of cryptocurrencies, operations that store or interact with these assets are considered high risk from cyber attacks. As such, the highest level of security should be observed when interacting with these assets. This requires a forward-thinking approach, which takes into account the new and experimental nature of blockchain technologies. Strategies that should be used to encourage secure code development include:
This report presents the findings of a smart contract audit performed by iosiro of Synthetix's Alpheratz release.
SIP-148 introduced a new liquidation mechanism that made the system more resistant to cascading liquidations. The new design redistributes the liquidated debt and collateral to system stakers without requiring the liquidator to burn synths. This allowed collateral to remain in the system as escrowed rewards and mitigated the risk of SNX flooding the market during a cascading liquidation, further dropping the price. Liquidatable accounts can either be self-liquidated by the account owner or can be flagged by a keeper bot. If a flagged account can still be liquidated after some period of time, the account becomes open for liquidation. Flaggers and liquidators earn a fixed SCCP-configurable fee for performing these actions.
One medium-risk issue and two informational issues were identified during the audit; the high-risk issue was closed during the assessment. The code of this system underwent significant changes over the course of the audit, which both simplified the code and improved its quality. The code was of a high standard by the end of the audit.
SIP-236 corrected exchange logic to use the post-settlement amounts when performing exchange calculations.
No issues were identified in SIP-236.
The source code considered in-scope for the assessment is described below. Code from all other files was considered to be out-of-scope. Out-of-scope code that interacts with in-scope code was assumed to function as intended and not introduce any functional or security vulnerabilities for the purposes of this audit.
Project Name: Synthetix
Initial commit: 61321b8
Final commit: 02f6845
Files: contracts/Liquidator.sol, contracts/LiquidatorRewards.sol, contracts/Issuer.sol, contracts/BaseSynthetix.sol, contracts/MixinSystemSettings.sol, contracts/SystemSettings.sol, contracts/SystemSettingsLib.sol
Project Name: Synthetix
Initial commit: 2f46009
Final commit: 2f46009
Files: contracts/Exchanger.sol, contracts/ExchangerWithFeeRecAlternatives.sol
A variety of techniques were used in order to perform the audit. These techniques are briefly described below.
The source code was manually inspected to identify potential security flaws. Code review is a useful approach for detecting security flaws, discrepancies between the specification and implementation, design improvements, and high-risk areas of the system.
The contracts were compiled, deployed, and tested in a test environment, both manually and through the test suite provided. Manual analysis was used to confirm that the code was functional and to identify security issues that could be exploited.
Tools were used to automatically detect the presence of several types of security vulnerabilities, including reentrancy, timestamp dependency bugs, and transaction-ordering dependency bugs. Static analysis results were reviewed manually and any false positives were removed. Any true positive results are included in this report.
Static analysis tools commonly used include Slither, Securify, and MythX. Tools such as the Remix IDE, compilation output, and linters could also be used to identify potential areas of concern.
Each issue identified during the audit has been assigned a risk rating. The rating is determined based on the criteria outlined below.
The following section outlines the intended functionality of the system at a high level.
The specification of SIP-148 was based on commit hash 180f4d3.
The specification of SIP-236 was based on commit hash 46938e7.
The following section includes in-depth descriptions of the findings of the audit.
No high-risk issues identified during the audit were present at the conclusion of the audit.
No medium-risk issues identified during the audit were present at the conclusion of the audit.
No low-risk issues identified during the audit were present at the conclusion of the audit.
SIP-148
When the total redeemed amount from a liquidation is less than the sum of the flagger and liquidator fees, the system sends all the redeemed SNX to the stakers and does not pay the flagger or liquidator. This approach does not adequately incentivize liquidators to perform liquidations against small positions, which would leave them open. These small positions could accumulate as bad debt and jeopardize system health. It should be considered that the system should rather prioritize paying the liquidator and flagger fees, instead of the stakers. In this case, liquidator fees can be given preference as it is the more expensive action.
SIP-148
When attempting to liquidate a flagged account that is currently healthy, the flag should be removed instead of reverting to prevent other liquidators from trying to liquidate the account. This will also reset the liquidation timer for the account to avoid the account becoming immediately liquidatable in the future.
SIP-148 Issuer.sol#L672
During liquidation, the system incorrectly subtracted the liquidated debt from the debt cache, misrepresenting the system value on that layer. This discrepancy would be corrected during the next debt snapshot.
Removed in 152b6df.