Skip to content

Instantly share code, notes, and snippets.

@RideSolo
Last active January 3, 2019 20:20
Show Gist options
  • Save RideSolo/3c473e3f5a3978599c86c11d7e6d3cbf to your computer and use it in GitHub Desktop.
Save RideSolo/3c473e3f5a3978599c86c11d7e6d3cbf to your computer and use it in GitHub Desktop.

OPNPlatform Project Audit Report.

1. Summary

This document is a security audit report performed by RideSolo, where OPNPlatform project has been reviewed.

2. In scope

  • Crowdsale.sol github commit hash 5cfd2fc9b3642cf2a20a95b51dc2a0497f939519.
  • Escrow.sol github commit hash 5cfd2fc9b3642cf2a20a95b51dc2a0497f939519.
  • TimeLock.sol github commit hash 51d4bffb4c109e2a6a1c11a383e57724b1625d7e.
  • Token.sol github commit hash d2b3b15e9f5cfebc3d2825151fc9220581f2e7ed.

3. Findings

10 issues were reported including:

  • 1 medium severity issues.

  • 7 low severity issues.

  • 2 minor remark.

3.1. Insufficient Balance

Severity: medium

Description

Before adding tokens to user balance using addTokens function member of TokenTimeLock contract, a condition should be added where the token balance of the contract has to be sufficient to pay the users.

Code snippet

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/TimeLock.sol#L143#L150

3.2. Tokens Amount Computation

Severity: low

Description

To compute tokens that a user bought, the _weiAmount in _getTokenAmount is first divided by tokenPriceInWei then multiplied by 10**decimals (1 ether in the contract).

If the devs intention was to set a minimum buy threshold of tokenPriceInWei or a multiple of it, this operation can be considered as correct.

Code snippet

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Crowdsale.sol#L366#L398

3.3. Crowdsale Stages

Severity: low

Description

Stages of the Crowdsale contract are set after deploying the contract, additional stages can be added while the ICO has started extending the ICO phase. investors have to be informed.

Code snippet

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Crowdsale.sol#L261#L271

3.4. Oraclize Balance

Severity: low

Description

Sufficient balance has to be available to execute oraclize queries, if the contract owner call withdrawBalance() and empty the contract balance, oraclize callback won't execute the required query to update the exchange rate using updatePrice. This issue does not represent a risk since updatePrice can be called manually.

Code snippet

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Crowdsale.sol#L249#L258

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Crowdsale.sol#L484#L486

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Crowdsale.sol#L489#L492

Recommendation

  • updatePrice is payable, msg.value should be added to oraclizeBalance, same as in addBalanceForOraclize.
  • When withdrawBalance() is called the remaining contract balance should be equal to oraclizeBalance.
  • At each call of updatePrice, the query price has to be deducted from oraclizeBalance.

3.5. Escrow Race Condition

Severity: low

Description

If a user sends ether to the escrow contract using multiple transactions and a manager call getETH between two ethers transfer, startBalance will be set to the previous contract balance value making the withdrawal stages applicable only for that value. to withdraw the ether left in the contract either the owner has to call transferETH or the manager has to wait untill stopDay is reached.

Code snippet

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Escrow.sol#L147#L149

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Escrow.sol#L161#L172

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Escrow.sol#L182#L185

3.6. Pausable Token Contract

Severity: low

Description

pause function member of Pausable contract can still be called even after ICO end (following the contracts logic the pause mechanism is used to prevent token trading while the ICO is ongoing), therefore pausing the token transfer.

Code snippet

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Token.sol#L141#L144

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Token.sol#L119

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Crowdsale.sol#L465

Recommendation

The devs should consider to implement a mechanism where this procedure is automated to protecet the token contract from any possible issue like hack of owner private key.

3.7. Multiple Declaration

Severity: low

Description

Multiple declaration of delOwner member of Escrow. replace the fundtion name with delManager.

Code snippet

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Escrow.sol#L89#L93

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Escrow.sol#L102#L106

3.8. Oraclize Call in Constructor

Severity: minor

Description

The Crowdsale contract constructor should be payable in order to successfully execute updatePrice inside the constructor and update the exchange rate.

Code snippet

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Crowdsale.sol#L222

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Crowdsale.sol#L250

3.9. ICO Address

Severity: minor

Description

ICOAddress is not set in the contract constructor of Ownable contract. however, the address can be set using setICOAddress.

Code snippet

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Token.sol#L55

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Token.sol#L67#L69

https://github.com/OPNAG/contracts/blob/51d4bffb4c109e2a6a1c11a383e57724b1625d7e/Token.sol#L104#L107

3.10. Known Issues of ERC20 Standard

Severity: low

Description

ERC20 Tokens have some well-known issues (listed bellow), This is just a reminder for the contract developers.

  • Approve + transferFrom mechanism allows double Withdrawal attack (use increaseApproval or decreaseApproval to change the allowance value).
  • Lack of transaction handling.

The above mentioned issues are well documented, a basic search can help to get more information.

4. Conclusion

The audited smart contracts do not contain any high severity issues, however the above described issues have to be taken into consideration to avoid any possible error or misunderstanding with the investors.

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