Skip to content

Instantly share code, notes, and snippets.

@danbogd
Last active March 20, 2019 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danbogd/3d3f5c273f74bd521a8d68f17392cd9e to your computer and use it in GitHub Desktop.
Save danbogd/3d3f5c273f74bd521a8d68f17392cd9e to your computer and use it in GitHub Desktop.

BNB Token audit report.

1. Summary

This document is a security audit report performed by danbogd, where BNB Token has been reviewed.

2. In scope

3. Findings

In total, 7 issues were reported including:

  • 2 medium severity issues.
  • 2 low severity issues.
  • 3 minor observation.

3.1. Fallback Function

Severity: medium

Description

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.

Code snippet

https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L144

3.2. Allowance Approval

Severity: medium

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. Do not throw in case if (_value <= 0) throw;

Code snippet

https://gist.github.com/danbogd/8b2b6c6e79fcf234534d894c349ced4a#file-bnb-sol-L90

3.3. ERC20 Compliance.

Severity: low

Description

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.

Code snippet

https://gist.github.com/yuriy77k/7612e9b1f915f169542e711dd6a29166#file-bnb-sol-L68

3.4. 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 into a function transfer(address _to, ... ) following code:

require( _to != address(this) );

3.5. Consider using latest version of solidity.

Severity: minor observation

Description

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.

3.6. Implicit visibility level.

Severity: minor observation

Description

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.

Code snippet

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

3.7. Deprecated constructions.

Severity: minor observation

Description

Use revert() instead of throw. Use constructor.

Code snippet

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

4. Conclusion

The review did not show any critical issues, some of medium and low severity issues were found.

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