This document is a security audit report performed by danbogd, where BNB Token has been reviewed.
In total, 7 issues were reported including:
- 2 medium severity issues.
- 2 low severity issues.
- 3 minor observation.
Any ether sent directly to the contract through the fallback function will not result in an automatic buy of tokens but instead is directly sent to the contract balance.
https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L144
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. Do not throw in case if (_value <= 0) throw;
https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L90
Accroding to ERC20 standard, when initializing a token contract if any token value is set to any given address a transfer event should be emited. An event isn't emited when assigning the initial supply to the msg.sender.
https://gist.github.com/yuriy77k/7612e9b1f915f169542e711dd6a29166#file-bnb-sol-L68
-
It is possible to double withdrawal attack. More details here.
-
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.
Add into a function transfer(address _to, ... )
following code:
require( _to != address(this) );
The contracts use solidity version 0.4.8. It is suggested to use the latest version and fix all compiler warnings that arise. Compiler version should be fixed to avoid any potential discrepancies in smart contract behavior caused by different versions of compiler.
The default function visibility level in contracts is public, in interfaces - external, state variable default visibility level is internal. In contracts, the fallback function can be external or public. In interfaces, all the functions should be declared as external. Explicitly define function visibility to prevent confusion.
https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L62 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L77 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L88 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L97 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L110 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L119 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L128 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L138 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L144
Use revert() instead of throw. Use constructor.
https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L62 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L78-L79 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L90 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L98-L102 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L111-L112 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L120-L121 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L129-L130 https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L139
The review did not show any critical issues, some of medium and low severity issues were found.