iosiro
blockchain security

Dala Token Sale

Audit Results


1. Disclaimer

This is a limited report on our findings based on our analysis, in accordance with good industry practice as at the date of this report, in relation to: (i) cybersecurity vulnerabilities and issues in the smart contract source code analysed, the details of which are set out in this report, (Source Code); and (ii) the Source Code compiling, deploying and performing the intended functions. In order to get a full view of our findings and the scope of our analysis, it is crucial for you to read the full report. While we have done our best in conducting our analysis and producing this report, it is important to note that you should not rely on this report and cannot claim against us on the basis of what it says or doesn’t say, or how we produced it, and it is important for you to conduct your own independent investigations before making any decisions. We go into more detail on this in the below disclaimer below – please make sure to read it in full.

DISCLAIMER: By reading this report or any part of it, you agree to the terms of this disclaimer. If you do not agree to the terms, then please immediately cease reading this report, and delete and destroy any and all copies of this report downloaded and/or printed by you. This report is provided for information purposes only and on a non-reliance basis, and does not constitute investment advice. No one shall have any right to rely on the report or its contents, and Zenoic Proprietary Limited trading as Iosiro and its affiliates (including holding companies, shareholders, subsidiaries, employees, directors, officers and other representatives) (Iosiro) owe no duty of care towards you or any other person, nor does Iosiro make any warranty or representation to any person on the accuracy or completeness of the report. The report is provided "as is", without any conditions, warranties or other terms of any kind except as set out in this disclaimer, and Iosiro hereby excludes all representations, warranties, conditions and other terms (including, without limitation, the warranties implied by law of satisfactory quality, fitness for purpose and the use of reasonable care and skill) which, but for this clause, might have effect in relation to the report. Except and only to the extent that it is prohibited by law, Iosiro hereby excludes all liability and responsibility, and neither you nor any other person shall have any claim against Iosiro, for any amount or kind of loss or damage that may result to you or any other person (including without limitation, any direct, indirect, special, punitive, consequential or pure economic loss or damages, or any loss of income, profits, goodwill, data, contracts, use of money, or business interruption, and whether in delict, tort (including without limitation negligence), contract, breach of statutory duty, misrepresentation (whether innocent or negligent) or otherwise under any claim of any nature whatsoever in any jurisdiction) in any way arising from or connected with this report and the use, inability to use or the results of use of this report, and any reliance on this report.


2. Introduction

Iosiro was commissioned by Newtown Partners to perform an audit of the Dala token sale. The test was conducted between 05 October 2017 and 13 October 2017 .

The Dala token allows free banking and remittances for emerging market consumers. It is a general-purpose, open-source ERC-20 crypto-token. More information on the Dala token can be found in the whitepaper here .

The report is organized into the following sections.

  • Section 3 - Executive Summary: A high-level description of the findings of the audit.
  • Section 4 - Detailed Scope: A list of the files used in the audit and a description of the methodology.
  • Section 5 - Smart Contract Descriptions: An account of the functionality of the smart contracts.
  • Section 6 - Differential Analysis: An overview of notable differences found during the differential analysis.
  • Section 7 - Detailed Findings:  The full descriptions of the findings of the audit.

The  information in this report should be used to understand the risk exposure of the smart contracts, and as a guide to improve the security posture of the smart contracts by remediating the issues that were identified. The results of this audit are  only a reflection of the source code reviewed at the time of the audit and of the source code that was determined to be in scope.


3. Executive Summary

This report presents the findings of an audit performed by Iosiro on the Dala token sale. The purpose of the audit was to achieve the following.

  • Ensure that the smart contracts function as intended.
  • Identify potential security issues with the smart contracts.

Due to the unregulated nature and ease of transfer of cryptocurrencies, operations that store or interact with these assets are considered very high risk with regards to 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 th e new and experimental nature of blockchain technologies . There are a number of techniques that can help to achieve this, some of which are described below.

  • Security should be integrated into the development lifecycle.
  • Defensive programming should be employed to account for unforeseen circumstances.
  • Current best practices should be followed wherever possible.

The difficulty of maintaining smart contracts further complicates the task of securing them. Upgrade mechanisms that would allow contracts to be maintained and enhanced are an active but contentious area of research. The ability to upgrade contracts introduces the need for third party trust, into an otherwise trustless system. Furthermore, defensive techniques, such as upgrade mechanisms and pausing fail-safes can increase the attack surface of contracts, by introducing additional functionality that could potentially be exploited.

The smart contracts used in the Dala token sale implementation were largely developed using previously audited projects, including projects by TokenMarket and OpenZeppelin. A full list of files and commit versions can be found in Section 4.

At the client’s request, a differential analysis was used to reduce the time  required to conduct  the audit. This approach comes at the expense of also reducing the scope of the audit  to focus on previously unaudited code. A differential analysis allows one to identify code that has been introduced from a prior version of audited code. Testing of unaltered code was limited to a high-level functional verification, where the code was verified to operate as intended. Code that was altered for the specific implementation of the Dala token sale was fully audited.

The audit identified a number of points of interest. The code was well commented, modularized logically, and did not contain unnecessarily complex functions. At a high-level, both of the smart contracts operated as intended. No high or medium risk findings were identified during the audit. The low risk finding titled Pausing Functionality has a Single Point of Failure, could potentially have a high impact on the token. However, due to the difficulty of exploitation and trade off of the complexity of the proposed remedial actions, the findings were limited to low risk.

Unfortunately, at the time of testing the production Truffle framework migrations were not available. As such, specific production parameters could not be recorded, such as the ether cap or the price of the tokens.

The risk posed by the smart contracts can be further mitigated by using the following  controls prior to releasing the contracts to a production environment.

  • Develop a test suite with close to complete test coverage.
  • Perform additional audits, through different vendors.
  • Launch a bug bounty program on a public test network to crowdsource the detection of potential vulnerabilities.

In summary, the smart contracts were found to be exposed to a low degree of risk.


4. Detailed Scope

4.1 Audited Source Code

The audited source code is detailed below. Only the Solidity files were audited, as the production Truffle framework migrations were not available at the time of the audit.

4.1.1 Dala Corporation

Project Name: dala-smart-contracts

Commit: 175138b ( link )

Files: AllocatedCrowdsale.sol, CentrallyIssuedToken.sol, Crowdsale.sol, DefaultFinalizeAgent.sol, FinalizeAgent.sol, FlatPricing.sol, FractionalERC20.sol, Haltable.sol, MultiSigWallet.sol, MultiSigWalletWithDailyLimit.sol, NullFinalizeAgent.sol, PausableToken.sol, PricingStrategy.sol, ReleasableToken.sol, StandardToken.sol, UpgradeAgent.sol, UpgradeableToken.sol

4.2 Original Codebases

The following codebases were used to construct the audited source code. The original codebases were used in the differential analysis to detect changes.

4.2.1 TokenMarket

Project Name: ico
Commit: fa7feed ( link )

Files: AllocatedCrowdsale.sol, CentrallyIssuedToken.sol, Crowdsale.sol, DefaultFinalizeAgent.sol, FinalizeAgent.sol, FlatPricing.sol, FractionalERC20.sol, Haltable.sol, NullFinalizeAgent.sol, PricingStrategy.sol, ReleasableToken.sol, StandardToken.sol, UpgradeAgent.sol, UpgradeableToken.sol

4.2.2 Gnosis

Project Name: MultiSigWallet

Commit: b7f01af ( link )

Files: MultiSigWallet.sol, MultiSigWalletWithDailyLimit.sol

4.2.3 OpenZeppelin

Project Name: zeppelin-solidity

Commit: 6331dd1 ( link )

Files: PausableToken.sol

Migrations .sol was included in the source files provided, but was excluded from the scope. This file only manages migrations for the Truffle framework and was not used by the Dala token sale smart contracts.

4.3 Methodology

The audit was conducted using a variety of techniques. These are outlined below.

4.3.1 Differential Analysis

Code that was unchanged from the previously audited code was determined to be out-of-scope for the security audit. It should be noted that this process does not inherently verify whether these contracts are secure. The purpose of a differential analysis is simply to check whether potentially vulnerable code was introduced into the contracts.

4.3.2 Dynamic Analysis

The contracts were compiled, deployed, and tested using both Truffle tests and manually. A number of pre-existing tests were included in the project. The results of the tests and the coverage can be found in Appendix I. The testsuite was extended by the review team during the audit to include additional attack paths.

4.3.3 Code Review

Source code was manually reviewed to identify potential security flaws. This type of analysis is useful for detecting business logic flaws and edge-cases that may not be detected through dynamic or static analysis.

4.3.4 Automated Analysis

A number of tools were used to automatically detect the presence of potential vulnerabilities. Static analysis was conducted using both proprietary tools, as well as public tools, such as the Remix IDE and Oyente . Compilation and linter outputs were also used to detect potential vulnerabilities. The compilation output can be found in Appendix II and the linter output can be found in Appendix IV.


5. Smart Contract Descriptions

5.1 Dala Token Sale

The Dala token sale was implemented using the standard AllocatedCrowdsale from the TokenMarket implementation, which imported Crowdsale and PricingStrategy.

At a high level, the crowdsale would issue Dala tokens to addresses that sent it ether under the right circumstances. Notable design decisions regarding the crowdsale smart contracts are outlined below.

5.1.1 Cap

The crowdsale was limited to a specific number of Dala tokens and a price was given to each Dala token. This resulted in an effective ether hard cap for the crowdsale. If this cap was reached, further attempts to send ether to the contract would fail and the crowdsale could then be finalized. The ether cap was not available at the time of the audit.

5.1.2 Whitelist

Participants had to manually be whitelisted by the owner of the contract before they could participate in the crowdsale. This was implemented as the organizers required participants to submit KYC data to a registration website to be manually vetted and approved, prior to participating in the event.

The registration website can be found here .

5.1.3 Daily Ether Cap

The crowdsale enforced a daily ether cap per participant, which would prohibit participants from purchasing Dala tokens worth more than a specified number of ether per day. The cap was used to allow a fair amount of time for all participants to purchase Dala tokens. The algorithm for calculating the cap is given below.

dailyEtherCap = baseEtherCap * (2 daysSinceStart + 1-1)

For example, with a baseEtherCap of 15 ether, the dailyEtherCap would be 15 on the first day, 45 on the second day, 105 on the third day and so forth.

The daily cap was not available at the time of the audit.

5.1.4 FlatPricing

The crowdsale made use of a flat pricing strategy. Flat pricing results in all participants paying the same price for tokens throughout the duration of the crowdsale.

5.1.5 Finalizable

The crowdsale could manually be finalized by the owner of the contract after the cap was reached or the crowdsale end date passed. After the crowdsale was finalized the tokens became transferable.

5.1.6 Haltable

The contract inherited from TokenMarket’s Haltable contract. This would allow the owner to halt the crowdsale in the event of an emergency, which would prevent both the issuance of new tokens and the ability to finalize the crowdsale.

5.2 Dala Token

The Dala token was implemented using the standard CentrallyIssuedToken from the TokenMarket implementation. The token inherited from ReleasableToken, UpgradeableToken, and PausableToken. The OpenZeppelin PausableToken contract was used. The token included the following functionality.

5.2.1 Releasable

Used to enforce a lockup period of the tokens until the crowdsale finishes. Releasable tokens can only be transferred after a release command is sent to the contract. The command needs to be issued by the release agent that is set by the owner of the contract. Addresses can be whitelisted to perform transactions prior to becoming releasable by setting the address as transfer agents.

5.2.2 Upgradable

Tokens can be upgraded through an opt-in process. Users would need to send tokens to the upgrade function, which would then issue the appropriate number of tokens on the newly issued token. This function provides the ability to upgrade the contract due to added functionality or security improvements.

5.2.3 Pausable

The tokens can be paused. This functionality allows the owner of the contract to prevent the transfer of all Dala tokens. Pause functionality can be useful if the contract becomes compromised in any way. In the event of a compromise, the owner can enforce a pause of the token, at which time users could upgrade their tokens to a newly patched contract.

5.3 Wallets

5.3.1 MultiSigWallet

In order to store the funds of the crowdsale safely, the crowdsale made use of a Gnosis multi-signature wallet to deposit the funds. A 2-of-3 signatures configuration with hardware wallets securing the private keys of the signing accounts was used.



6. Differential Analysis

The source code that was used to develop these smart contracts was largely used from codebases published by TokenMarket and OpenZeppelin. The code has been tested, audited and used by a number of projects. The TokenMarket ICO code has supported Civic, Storj , and Monaco. The OpenZeppelin code has supported Golem, Firstblood, and Signatura.

6 .1 Notable Differences

A description of notable differences between the audited codebase and the original codebases is given below. A more complete analysis of the differences is given in Appendix V.

6.1.1 Crowdsale.sol

Added baseEthCap Functionality

An ether cap was implemented to restrict the number of tokens that could be purchased each day. The functionality operated as intended and no vulnerabilities were identified.

The functionality made use of block timestamps, which can be slightly altered by miners. The potential for exploitation seemed inconsequential, as it would only allow some miners to purchase their daily cap seconds before everyone else.

Added Whitelist Functionality

Functionality was added to limit participants to people who had previously registered and been accepted through a registration portal. This functionality operated as intended and no vulnerabilities were identified.

Fallback Function Changed from throw to buy()

The fallback function of Crowdsale.sol was changed from simply performing a throw to calling the buy() function. This would allow participants to send ether directly to the contract address to purchase their tokens. The functionality operated as intended and no vulnerabilities were identified.

In the unlikely event that the function was ever intended to be called directly from send() or transfer() the gas stipend of 2300 would be insufficient to purchase the token.

6.1.2 CentrallyIssuedToken.sol

Changed Token Inheritance

The inheritance of the token was changed to remove the burnable feature, and added the ability to release and pause it. The added features operated as intended and no vulnerabilities were identified.

Changing the files that are inherited or the order of inheritance can have unexpected effects. The Solidity compiler uses C3 linearization to force a specific order in the DAG of base classes. As such, without a good understanding of the functionality being used, it may be possible to introduce bugs through superclass calls. CentrallyIssuedToken was not found to be vulnerable to this style of attack. An example of this type of attack can be found here .

6.1.3 PausableToken.sol

No notable differences were noted on PausableToken.sol .

However, it was found that an outdated version was being used at the time of testing. The newer version had seen minor patches, including setting uint256 in place of uint , and explicitly setting visibility on functions. These changes were done to follow best practice.

6.1.4 OpenZeppelin SafeMath

The original codebase used used SafeMath in a contract form, whereas the altered code used the library form. In newer versions of the original codebase, the intention appears to be to migrate across to the library form as well. There are some differences in the way that functions are called, but otherwise no noteworthy differences were found.


7. Detailed Findings

The following section outlines the findings of the testing that was performed.

7.1 High Risk

No high risk findings were identified.

7.2 Medium Risk

No medium risk findings were identified.

7.3 Low Risk

7.3.1 Pausing Functionality has a Single Point of Failure

PausableToken.sol and Haltable.sol

The pausing functionality that is available to the crowdsale and the Dala token smart contracts are both invoked through a single owner of the contract. As such, there is a single point of failure if the owner account is either compromised or is lost due to unforeseen circumstances. This could result in a situation where a contract is effectively paused indefinitely. The risk of indefinite pausing is mitigated with the Dala tokens, as an indefinite pause could theoretically be circumvented by a contract upgrade issued through an upgrade agent.

It is recommended that the functionality follows a multisignature behavior , where for example 2-of-3 accounts are used to pause or halt a contract. The additional code complexity would likely increase the attack surface, which presents a tradeoff that needs to be considered.

7.4.2 Low Coverage of Tests

General

Tests can provide some form of assurance that the code is performing as expected. In this instance, the tests were Truffle framework tests that would deploy and execute the code locally via testrpc. The coverage of the tests can be seen in Appendix I.

The coverage was low for a number of the files, as ideally one would have complete coverage across all the files used. While testing should not be used as the only measure of functionality, it can be helpful in identifying faults in logic, both at a data flow and business level.

7.4 Informational

7.4.1 Multisignature Wallet Expands Attack Surface

MultiSigWallet.sol and MultiSigWalletWithDailyLimit.sol

The Gnosis multisignature wallet was used to store the funds received during the crowdsale. The wallet was implemented through the use of a smart contract. If any vulnerabilities are found within the implementation of the wallet, it could lead to a compromise of the funds raised during the crowdsale. An example of this threat was when the Parity wallet was hacked through the multisignature functionality that led to the loss of approximately $30,000,000 USD.

The security advantages of using a multisignature wallet seem to outweigh the increased attack surface, thus this finding is simply listed for completeness.

7.4.2 Token Upgrade can be Required through Pause

PausableToken.sol

While the token upgrade functionality is theoretically an opt-in process for users, the owner of the token contract could require users to upgrade by placing an indefinite pause on the original token. This would prevent users from being able to transfer their original tokens. The only way they would be able to access their original tokens would be by upgrading their original tokens to the new token.

7.4.3 Unmarked Visibility on Functions and State Variables

General

There were a number of instances where functions and state variables had no visibility set. An example of both of these issues can be found in PausableToken.sol . Best practice specifies that visibility should be set explicitly. The intention of this is to avoid confusion and potential mistakes that could occur as a result of incorrect usage.

7.4.4 Inexact and Inconsistent Solidity Compiler Version

General

The pragma version varied throughout the contracts and was not fixed on a specific version. The majority of the contracts were listed as ^0.4.15 , which would result in using the highest non-breaking version (highest version below 0.5.0 ).

According to best practice, where possible, all contracts should use the same compiler version, which should be fixed to a specific version.

7.4.5 Using Undocumented Solidity Behavior

SafeMath.sol

SafeMath currently relies on the undocumented behavior of overflows in Solidity. There is potential for this functionality to change in future revisions, which could render the result of SafeMath incorrect, or break entirely. The likelihood of this seems low, and in the event that it did happen, it would only affect newly compiled code. Compilers would also likely warn of this issue, which further mitigates the risk.

7.4.6 Errors and Warnings

General

A number of errors and warnings were presented during compilation, by linter tools, and by static analysis tools. These were investigated manually to determine the potential for security risk.

No risks were identified on this basis. The output of the compilation can be found in Appendix II, the static analysis results can be found in Appendix III, and the output of the linter tool can be found in Appendix IV.


Appendix I: Test Coverage

The results of the test coverage generated using solidity-coverage can be found here.


Appendix II: Compilation Output

The compilation output is available here.

Appendix III: Static Analysis Results

Iosiro’s Proprietary Static Analysis Tool

The tool did not report any vulnerabilities.

Remix IDE

The output of the Remix IDE static analysis can be found here.

Oyente

The output of the Oyente tool can be found here

Appendix IV: Linter Results

The following table outlines the summary of the results of the solium linter. The full output of the linter tool can be found here .

Filename

Summary of Linter Output

AllocatedCrowdsale.sol

1 error, 16 warnings found.

CentrallyIssuedToken.sol

7 warnings found.

Crowdsale.sol

123 warnings found.

DefaultFinalizeAgent.sol

10 warnings found.

FinalizeAgent.sol

5 warnings found.

FlatPricing.sol

8 warnings found.

FractionalERC20.sol

2 warnings found.

Haltable.sol

3 errors, 12 warnings found.

MultiSigWallet.sol

14 errors, 23 warnings found.

MultiSigWalletWithDailyLimit.sol

1 error found.

NullFinalizeAgent.sol

8 warnings found.

PausableToken.sol

5 warnings found.

PricingStrategy.sol

9 warnings found.

ReleasableToken.sol

23 warnings found.

StandardToken.sol

17 warnings found.

UpgradeAgent.sol

5 warnings found.

UpgradeableToken.sol

12 errors, 25 warnings found.

Appendix V: Differential Analysis Results

Screenshots showing the results of the differential analysis can be found here .

A high-level analysis of the findings of the differential analysis can be found here.

Appendix VI: Max Ether Cap Functionality Added

Commit hash f9fbafc
03 November 2017

Description

Functionality was added to the crowdsale smart contracts to allow an absolute cap to be set on the amount of ether that an address could purchase during the crowdsale.

The audit revealed that all of the added functionality operated as intended. The cap would limit the amount of ether that participants could send to the crowdsale. The limit could be changed through the setter function, which would then enforce the new limit.

No security issues were identified in the added code.

Changes

AllocatedCrowdsale.sol

  • The constructor now has a parameter for the maximum participation amount cap per address.

Crowdsale.sol

  • Added setMaxEthPerAddress(uint _maxEthPerAddress), a setter function that could be used to change the maximum participation cap.
  • Added an event, MaxEthPerAddressChanged(uint newMaxEthPerAddress), to indicate that the max ether cap had changed.
  • The getCurrentEthCap() function was changed to take the max ether cap into account when calculating the dynamic cap.