EthereumCommonwealth / Auditing

Ethereum Commonwealth Security Department conducted over 400 security audits since 2018. Not even a single contract that we audited was hacked. You can access our audit reports in the ISSUES of this repo. We are accepting new audit requests.
https://audits.callisto.network/
GNU General Public License v3.0
133 stars 34 forks source link

OmiseGO (OMG) Token #192

Closed yuriy77k closed 5 years ago

yuriy77k commented 5 years ago

Audit request

Audit Top 200 CoinMarketCap tokens.

OmiseGO OMG
Circulating Supply 140 245 398
Total Supply 140 245 398

https://omisego.network/

Deployed at https://etherscan.io/address/0xd26114cd6EE289AccF82350c8d8487fedB8A0C07#code

Source code

https://gist.github.com/yuriy77k/d52b7674ca7cf9b221a819db168fb645

Disclosure policy

Public

Platform

ETH

Number of lines

185

MrCrambo commented 5 years ago

Auditing time 1 day

yuriy77k commented 5 years ago

@MrCrambo assigned

danbogd commented 5 years ago

Auditing time: ~ 2 days.

yuriy77k commented 5 years ago

@danbogd assigned

danbogd commented 5 years ago

My report is finished.

gorbunovperm commented 5 years ago

Estimated auditing time is 2 days.

yuriy77k commented 5 years ago

@gorbunovperm assigned

gorbunovperm commented 5 years ago

My report is finished.

yuriy77k commented 5 years ago

Security Audit Report

1. Summary

OmiseGO (OMG) Token smart contract security audit report performed by Callisto Security Audit Department

2. In scope

3. Findings

In total, 9 issues were reported including:

No critical security issues were found.

3.1. Known vulnerabilities of ERC-20 token

Severity: low

Description

  1. It is possible to double withdrawal attack. More details here.

  2. Lack of transaction handling mechanism issue. WARNING! This is a very common issue and it already caused millions of dollars losses for lots of token users! More details here.

Recommendation

Add the following code to the transfer(_to address, ...) function:

require( _to != address(this) );

3.2. Allowance Approval

Severity: low

Description

Following ERC-20 final description:

"NOTE: To prevent attack vectors like the one described here and discussed here, clients SHOULD make sure to create user interfaces in such a way that they set the allowance first to 0 before setting it to another value for the same spender. THOUGH The contract itself shouldn't enforce it, to allow backwards compatibility with contracts deployed before.

The implemented approve function:

Do not preserve backwards compatibility since it enforces the allowance values to be set.

Do not throw in case if the following condition is true if (_value != 0 && allowed[msg.sender][_spender] != 0) and return false, users might not notice that the changes didn't occur, and external contract calls to this function will highlight many other issues.

Code snippet

https://gist.github.com/yuriy77k/d52b7674ca7cf9b221a819db168fb645#file-omgtoken-sol-L164

Recommendation

Do not try to mitigate the issue and implement increaseApproval and decreaseApproval functions instead.

3.3. No checking for zero address.

Severity: low

Description

Transfer, transferFrom, mint, TokenTimelock functions do not prevent from sending tokens to address 0x0.

Recommendation

Add zero address checking

solidity
require(to != address(0));

3.4. Poor workaround of Short Address Attack

Severity: low

Description

onlyPayloadSize modifier is workaround to avoid the Short Address Attack. But it doesn't work properly.

  1. This method failed to execute when it was called from Parity multisignature wallet. The EVM pads call from this multisignature wallet, making the total 96 bytes instead of the expected 68.

  2. If transfer and transferFrom are used by a subcontract function with fewer arguments, the onlyPayloadSize check will fail. It is not possible to adapt the workaround to prevent this issue.

More details here.

Code snippet

https://gist.github.com/yuriy77k/d52b7674ca7cf9b221a819db168fb645#file-omgtoken-sol-L81-L86

Recommendation

Remove this workaround.

3.5. Owner Privileges

Severity: low

Description

The contract owner allow himself to pause functions of contract (transfer, transferFrom), mint any value of tokens.

The contract is managed manually by the owner which is not good for investors.

3.6. ERC20 Compliance — event missing

Severity: low

Description

The mint function should emit the Transfer event.

Code snippet

https://gist.github.com/yuriy77k/d52b7674ca7cf9b221a819db168fb645#file-omgtoken-sol-L254

3.7. Discrepancy with the ERC20 standard

Severity: minor observation

Description

In OMGToken.sol, according to the ERC20 standard, the variable decimals should be declared as uint8.

Code snippet

https://gist.github.com/yuriy77k/d52b7674ca7cf9b221a819db168fb645#file-omgtoken-sol-L382

3.8. It is required to limit the maximum of _releaseTime argument.

Severity: minor observation

Description

For various reasons (accident, vulnerability on the caller smart contract), _releaseTime variable may have a large value which can lead to overflow and that is more critical to blocking tokens for many many years. We can not rely on the correct input data and should check it in this contract.

Code snippet

https://gist.github.com/yuriy77k/d52b7674ca7cf9b221a819db168fb645#file-omgtoken-sol-L355

3.9. There is no minting cap

Severity: minor observation

Description

Owner could mint any amount he wants and there is no hard cap.

Code snippet

https://gist.github.com/yuriy77k/d52b7674ca7cf9b221a819db168fb645#file-omgtoken-sol-L251

4. Conclusion

The audited smart contract can be deployed. Only low severity issues were found during the audit.

5. Revealing audit reports

https://gist.github.com/yuriy77k/5f84f69befd3f6681f8b5445e24bdb53

https://gist.github.com/yuriy77k/960e5a709d35522a5deb3f35c4ba15b3

https://gist.github.com/yuriy77k/9d28025ce4468a986c8c469a33f34172

MillianoConti commented 5 years ago

Reddit announcement