Skip to content

Instantly share code, notes, and snippets.

@yuriy77k
Forked from RideSolo/ETH_MagicChain_report.md
Created April 12, 2019 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuriy77k/59b32c7b7b5ef9227b0aff0b6aac1bc3 to your computer and use it in GitHub Desktop.
Save yuriy77k/59b32c7b7b5ef9227b0aff0b6aac1bc3 to your computer and use it in GitHub Desktop.

MagicChain Token Audit Report.

1. Summary

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

Token desription:

Symbol      : MAGI
Name        : MagicChain
Total supply: 42,000,000
Decimals    : 6
Standard    : ERC223

2. In scope

3. Findings

3 issues were reported:

  • 2 medium severity issues.
  • 1 minor remark.

3.1. ERC-223 Compliance

Severity: medium

Description

ERC-223 standard do not implement a transferFrom function, however the audited code contains a transferFrom function that share the same code (_transfer) as transfer function, knowing that many contract use transferFrom to handle approved token the audited implementation will cause backward compatibility issues with many deployed and probably future deployed contracts.

For example if an address approve tokens to a contract address and the contract address try to call transferFrom to transfer the tokens to itself to be able to execute any logic and knowing that most contract do not implement tokenFallback function the transaction will throw.

ERC223 is intended to fix issues for direct transfer using transfer function only not transferFrom.

For more information check here.

Code snippet

https://github.com/RideSolo/magicchain-blockchain/blob/master/smartcontracts/MagicChain223.sol#L178

https://github.com/RideSolo/magicchain-blockchain/blob/master/smartcontracts/MagicChain223.sol#L190#L213

3.2. Wrong Condition Value

Severity: medium

Description

unfreezed compute the unfreezed value of tokens since _firstBlock, however the condition in that function is used to limit the unfreezed token to a maximum of _totalSupplyLimit which is wrong since half of the total supply is assigned to the owner in the constructor.

code snippet

https://github.com/RideSolo/magicchain-blockchain/blob/master/smartcontracts/MagicChain223.sol#L217#L218

Recommendation

The condition should limit the unfreezed token to half of _totalSupplyLimit otherwise the total supply will be equal to 63M not to 42M, when totalSupply function will return 42M. Please note that balanceOf cold storage address will throw when _coldStorageOutwill be higher than _initialSupply.

3.3. TransferFrom Reentrancy

Severity: minor remark

Description

transferFrom function calls _transfer where an external call is made using tokenFallback, if the _to address is a contract a reentrancy scheme is possible since _approve is reseting the value after the call to _transfer but with no impact since SafeMath will throw.

code snippet

https://github.com/RideSolo/magicchain-blockchain/blob/master/smartcontracts/MagicChain223.sol#L178#L179

Recommendation

Always check and set the variables before making any external call.

Conclusion

The audited contract contains compatibility issues with contracts that implement ERC20 approve and call mechanism, all the highlighted issues should be solved before deployment.

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