iosiro was commissioned by Penta Security Systems to conduct an audit on their token and crowdsale smart contracts for their AMO ICO. The audit was performed between 18 April 2018 and 23 April 2018. On 26 April 2018, a review was conducted to confirm that issues raised in this report had been sufficiently addressed.
This report is organized into the following sections.
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.
This report presents the findings of an audit performed by iosiro on the AMO token and crowdsale smart contracts. The purpose of the audit was to achieve the following.
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 the 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.
By the conclusion of the audit, only one informational issue remained open. This issue related to design recommendations that would more strictly implement expected behaviour and best practice recommendations. During the initial audit, one medium risk vulnerability was identified that allowed accounts to withdraw locked tokens. This issue was fixed at the time of the review.
The code was generally well designed and clearly written. It separated token and crowdsale logic and made use of commonly used libraries, where reasonable. A comprehensive test suite was also provided by the development team.
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.
The source code considered in-scope for the assessment is described below. Code from any other files are considered to be out-of-scope.
Project Name: AMO-Contracts
Files: AMOCoin.sol, AMOCoinSale.sol
A variety of techniques were used to perform the audit, these are outlined below.
The contracts were compiled, deployed, and tested using both Truffle tests and manually on a local test network. A number of pre-existing tests were included in the project.
Tools were used to automatically detect the presence of potential vulnerabilities, such as reentrancy, timestamp dependency bugs, transaction-ordering dependency bugs, and so on. Static analysis was conducted using Mythril and Oyente. Additional tools, such as the Remix IDE, compilation output and linters were used to identify potential security flaws.
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.
Each Issue identified during the audit is assigned a risk rating. The rating is dependent on the criteria outlined below..
The following section outlines the intended functionality of the smart contracts.
The AMO Coin token is described below.
The token implements the ERC20 standard.
It is possible to place a lock on an address. This prohibits a token holder from withdrawing more than a specified number of tokens.
It is possible to stop the transfer of tokens entirely, except for the admin account and token sale addresses. The default state is paused.
It is possible to remove tokens from the total supply.
The AMO Coin crowdsale is described below.
There are three distinct rounds:
Each round has three stages these are described below.
Participants need to be whitelisted before being able to contribute funds to the crowdsale.
During the early investment round, it is possible for the crowdsale owner to send tokens to participants without requiring ether in exchange.
The following section includes in depth descriptions of the findings of the audit.
No high risk issues were present at the conclusion of the audit.
No medium risk issues were present at the conclusion of the audit.
No low risk issues were present at the conclusion of the audit.
The following describes possible actions to improve the functionality and readability of the codebase.
It was possible to call the endSale function, ending the crowdsale, at any stage during the
Started stage. It is recommended that assertions are used to ensure that now is larger than
endTime or that the
weiRaised round variable is used to determine whether the round hard cap has been reached. In this way, participants can be assured that the crowdsale will last the expected duration.
It was possible to call the
setUpSale function with the same round multiple times. While this does not impact on the functionality of the code, it can lead to unintuitive outcomes. For example, it may be possible to have multiple presale rounds. Unless this is desired functionality, it is recommended that the round is automatically incremented when
endSale is called, ensuring that only the expected rounds are used.
A number of state variable were found to have a
private visibility set. As all information on the Ethereum blockchain is visible, it is still possible to access variables marked as private. The
private visibility simply prohibits other contracts from accessing the variable. It is recommended that the following changes are made:
From a developer’s perspective, marking a variable as private complicates the process of ensuring that variables have been correctly assigned, and offers little to no security benefit.
The emit keyword was found to be missing before events. This style has been deprecated, so it is recommended that the
emit keyword is added before each event, e.g.
The pragma version was not fixed to a specific version, as it specified
^0.4.18, 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. This helps to ensure that contracts do not accidentally get deployed using an alternative compiler, which may pose the risk of unidentified bugs. An explicit version also helps with code reuse, as users would be able to see the author’s intended compiler version. It is recommended that the pragma version is changed to a fixed value, for example
now keyword (an alias for
block.timestamp) is used to determine the current time. This value can be marginally affected by miners (by up to 900 seconds), so a common best practice is to rather use block.number to determine the time. However, the risk posed in this circumstance is inconsequential, and it is simply listed for completeness. No action is necessary.
AMOCoin.sol: lines 153 - 160
It was found that the token lock enforced by the smart contract could be bypassed, allowing an address to transfer all of their tokens at any stage. This vulnerability stemmed from the fact that the
transferFrom function did have the same modifiers as the transfer function.
In order to exploit this attack, an account with locked tokens would simply need to call the approve function, allowing an address that they controlled to withdraw tokens on their behalf. As the
onlyAllowedAmount modifier was not used on the
transferFrom function, the tokens would be transferred out of the locked address into one that had no lock.
It is recommended that the
onlyAllowedAmount(from, value) modifier is used in the transferFrom function to correctly lock the funds. While the transfer function uses
onlyAllowedAmount(msg.sender, value), it is important that in the case of
transferFrom that the from value is used rather than
msg.sender, as the
msg.sender would appear to be an unlocked account.
Fixed in 2ccc569.
AMOCoin.sol contained comments that outlined permissions for different addresses. However, the table did not accurately reflect the permissions. The comments suggested that the following permissions were enforced:
While the table accurately reflected which functions would need to be used by each address at the relevant stage, it did not reflect the actual permissions of the users. The permissions table should have been:
v: true, x: false
Fixed in 51b4412. Adjusted the table as per the recommendation.
Interested in getting your smart contracts audited? Request a Quote
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.