Skip to content

Instantly share code, notes, and snippets.

@danbogd
Created July 21, 2019 11:57
Show Gist options
  • Select an option

  • Save danbogd/a0bf9ea41d89b97a177446ac528ecd12 to your computer and use it in GitHub Desktop.

Select an option

Save danbogd/a0bf9ea41d89b97a177446ac528ecd12 to your computer and use it in GitHub Desktop.

APO1 token audit report.

1. Summary

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

2. In scope

Сommit hash 7b18c7689fc90bbbb5fa092c02ae9fd75e1074d7.

3. Findings

In total, 5 issues were reported including:

  • 1 medium severity issues
  • 4 low severity issues
  • 0 owner privileges (ability of owner to manipulate contract, may be risky for investors).
  • 0 notes.

No critical security issues were found.

3.1. Out of gas.

Severity: medium

Description

There is no upper limit on receivers.length, it increments each time a new transaction is registered. Eventually, as the count of transactions increases, gas cost of smart contract calls will raise, until reaching an "Out of Gas" error or a "Block Gas Limit" in the worst scenario.

Code snippet

https://github.com/geomad/APO/blob/7b18c7689fc90bbbb5fa092c02ae9fd75e1074d7/apo.sol#L154

3.2. 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.

Code snippet

https://github.com/geomad/APO/blob/7b18c7689fc90bbbb5fa092c02ae9fd75e1074d7/apo.sol#L113

3.3. Multi Transfer arrays length check.

Severity: low

Description

There are two input arrays, but no check for the same length. In this case it is possible to skip some recipient or token amount and to transfer wrong amount to wrong recipient.

Code snippet

https://github.com/geomad/APO/blob/7b18c7689fc90bbbb5fa092c02ae9fd75e1074d7/apo.sol#L154

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. Approval Decrease

Severity: low

Description

decreaseAllowance function revert if the value to be decreased from the total allowed is higher than the allowance (most implementations set the value to zero in this case), a racing condition can occur in this case between the spender and approver and the approver can lose tokens under some specific cases.

Code snippet

https://github.com/geomad/APO/blob/7b18c7689fc90bbbb5fa092c02ae9fd75e1074d7/apo.sol#L200

Recommendation

Set the value of the allowance to zero if the amount to be decreased is higher than the remaining allowance.

uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); }

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