Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yuriy77k/361d9fb7a15964108df074693c1111cd to your computer and use it in GitHub Desktop.
Save yuriy77k/361d9fb7a15964108df074693c1111cd to your computer and use it in GitHub Desktop.

Token and Crowdsale Audit Report

1. Summary

This document is a security audit report performed by RideSolo, where multiple smart contracts have been reviewed.

The audited smart contracts allow users to create ICO with five stages crowdsale with a custom ERC20 compatible token contract.

2. In scope

  • Crowdsale.sol github commit hash b0bf48ad75c6767d03acaf1e62b82af34901872d
  • ERC20Token.sol github commit hash b0bf48ad75c6767d03acaf1e62b82af34901872d
  • Ownable.sol github commit hash b0bf48ad75c6767d03acaf1e62b82af34901872d
  • SafeMath.sol github commit hash b0bf48ad75c6767d03acaf1e62b82af34901872d

2.1. Excluded

  • ERC20Interface.sol This is the ERC20 Token Standard Interface defined by the ethereum community.

3. Findings

5 issues were reported including:

  • 1 high severity issues.

  • 1 medium severity issues.

  • 1 low severity issues.

  • 2 minor remarks.

3.1. Address 0x0

Severity: High

Description

The function totalSupply member of ERC20Token contract, return balances[address(0)] substracted from _totalSupply, address(0) is probably used to burn tokens for deflationary purpose by sending tokens using transfer or transferFrom to address(0) since this two functions doesn't prevent sending token to address(0).

This logic can be a risk for users since they can by mistake send tokens to it.

Code snippet

https://github.com/SamueleA/ERC20andCrowdsale/blob/b0bf48ad75c6767d03acaf1e62b82af34901872d/ERC20Token.sol#L53#L55

Recommendation

  • Implement a dedicated burn function to avoid a possible user mistake.

  • Add require(tokenReceiver!=address(0)) to transfer and transferFrom to prevent users from sending tokens to address(0).

3.2. Lost Tokens

Sevirity: medium

Description

transfer and transferFrom members of ERC20Tokencontract allow users to send tokens to contract addresses. If the contract isn't ERC20 compatible the tokens can be lost. However the contract ERC20Token implement approveAndCall to be used with contracts who implement receiveApproval function but this does not prevent from users mistakes while calling transfer and transferFrom.

This is a well known issue of ERC20 token.

Code snippet

https://github.com/SamueleA/ERC20andCrowdsale/blob/b0bf48ad75c6767d03acaf1e62b82af34901872d/ERC20Token.sol#L71#L776

https://github.com/SamueleA/ERC20andCrowdsale/blob/b0bf48ad75c6767d03acaf1e62b82af34901872d/ERC20Token.sol#L103#L109

Code snippet

3.3. Investment Limit

Sevirity: low

Description

minAmount and maxAmount members of Crowdsale contract reresent the min and max transacation value to be sent to the crowdsale contract not the investment limit per individual or address as commented. The transactions will revert if the user buy more or less than the limits. any user can make a new transaction to buy more tokens.

Code snippet

https://github.com/SamueleA/ERC20andCrowdsale/blob/b0bf48ad75c6767d03acaf1e62b82af34901872d/Crowdsale.sol#L30

3.4. Confusing Contract Name

Severity: minor remark

Description

ERC20Token contract is a token compatible with ERC20 standard but with more functionalities. The contract name can lead users to confusion.

3.5. Call to Empty Functions

Sevirity: minor remark

Description

_postValidatePurchase and _updatePurchasingState members of Crowdsale contract are empty functions and yet they are called in buyTokens function.

Code snippet

https://github.com/SamueleA/ERC20andCrowdsale/blob/b0bf48ad75c6767d03acaf1e62b82af34901872d/Crowdsale.sol#L122

https://github.com/SamueleA/ERC20andCrowdsale/blob/b0bf48ad75c6767d03acaf1e62b82af34901872d/Crowdsale.sol#L125

4. Conclusion

The reviewed contracts contain issues with diffrent security level severity that need to be fixed. The actual version of the contracts may cause users tokens loss, the issues need to be fixed before deployment in live network.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment