Skip to content

Instantly share code, notes, and snippets.

@RideSolo
Last active August 9, 2018 15:14
Show Gist options
  • Save RideSolo/55e07505b231f1cab7454d21ca8f8dc3 to your computer and use it in GitHub Desktop.
Save RideSolo/55e07505b231f1cab7454d21ca8f8dc3 to your computer and use it in GitHub Desktop.

GIGZI Project Audit Report.

1. Summary

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

GIGZI project promess to issue regulated tokens (GZS silver, GZG gold, GZP platinum) backed by precious metals and also one non-regulated token GZB black. Round of rewards will be distributed to the holders of GZB tokens on their accounts in the form of regulated tokens following the project funding. GZB distribution is performed by ICO.

2. In scope

  • GigBlack.sol github commit hash ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8.
  • GigSilver.sol github commit hash ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8.
  • GigGold.sol github commit hash ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8.
  • GigPlatinum.sol github commit hash ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8.
  • GigCrowdsale.sol github commit hash ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8.
  • FeeableToken.sol github commit hash ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8.
  • Migrations.sol github commit hash ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8.

2.1. Excluded

  • The OpenZeppelin contracts inherited by the project are excluded from the audit report, however the usage of this contracts were analyzed and errors due to their misuse were highlighted.
  • MessageHelper.sol contained in the project repository is part of OpenZeppelin-solidity framework therefore omitted from the audit report.

3. Findings

8 issues were reported including:

  • 1 high severity issues.

  • 4 medium severity issues.

  • 2 low severity issues.

  • 1 minor remark.

3.1. Fees Avoidance

Severity: high

Description

FeeableToken contract inherit from ERC827Token, therefore any user can call transferFromAndCall or transferAndCall implemented in openzepplin ERC827Token to transfer token without fee collection, both functions call super.tranferFrom and super.transfer, hence calling the next base contract functions defined in StandardToken contract instead of the functions defined in FeeableToken therefore avoiding to pay the fees or possible manipulation of the reward since it the reward won't be updated.

This issue is applicable for GigBlack, GigSilver, GigGold, GigPlatinum Tokens contracts.

Code snippet

https://github.com/OpenZeppelin/openzeppelin-solidity/blob/dc1e352cc49565ba0a33c346006655cf63681ff5/contracts/token/ERC827/ERC827Token.sol#L59#L75

https://github.com/OpenZeppelin/openzeppelin-solidity/blob/dc1e352cc49565ba0a33c346006655cf63681ff5/contracts/token/ERC827/ERC827Token.sol#L86#L101

Recommendation

Reimplement transferFromAndCall and transferAndCall to override the inherited base contracts functions.

3.2. Lost Tokens

Severity: medium

Description

FeeableToken contract reimplement transfer and transferFrom methods, if a user direclty call these functions to transfer tokens, it can lead to lost tokens issue. Please note that even without reimplementation of the inherited functions, the ERC827 standard raise the same issue.

A user can send token to a contract address, where that contract doesn't implement any function to handle tokens.

This issue is applicable for GigBlack, GigSilver, GigGold, GigPlatinum Tokens contracts.

Code snippet

https://github.com/GigziProject/GigziContracts/blob/ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8/contracts/FeeableToken.sol#L78#L84

https://github.com/GigziProject/GigziContracts/blob/ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8/contracts/FeeableToken.sol#L89#L97

Recommendation

The oppenzepplin ERC827 implement function to avoid lost tokens issue but keep the previously inherited function of the ERC20 standard, developers should read in depth the ERC827 standard to be aware of its weaknesses.

3.3. Reserved Account of Fee Collector Address not updated

Sevirity: low

Description

The function setTxFeeCollector member of FeeableToken re-assign fee collector address but do not reset the reserved account old address to avoid fee collection, however addReservedAccount can be used but at the price of extending accountsReserved dynamic array.

Code snippet

https://github.com/GigziProject/GigziContracts/blob/ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8/contracts/FeeableToken.sol#L65#L68

3.4. Account Reward Update Error when Burning Tokens

Severity: medium

Description

The account reward is updated following the time that a user hold its tokens balance untill the next transfer or commit from the GIGZI team. In the reimplmented function burn member of GigBlack contract, updateAccountReward is called after substracting the burned tokens which doesn't follow the same pattern previously used in processTransfer.

Code snippet

https://github.com/GigziProject/GigziContracts/blob/ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8/contracts/GigBlack.sol#L216#L231

https://github.com/GigziProject/GigziContracts/blob/ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8/contracts/GigBlack.sol#L228

Recommendation

Call updateAccountReward before substracting the burned tokens.

3.5. Estimation Account Reward in Percent Error

Severity: medium

Description

this table is filled supposing that the previous described error (Account Reward Update Error when Burning Tokens) recommendation are took into account. this error is applicable even if the previously recommendation are not applied.

please note that this is an illustrative table, the number presented are proportional to the computation done in GigBlack contract, to show the problem 100 tokens will be burned at block 5.

block 0 1 2 3 4 5 Account Reward
balance user 1 1000 1000 1000 1000 1000 1000 1000 * 5
balance user 2 1000 1000 1000 1000 800 800 1000 * 3 + 800 * 2
balance user 3 0 0 0 0 200 100 200 * 1 + 100 * 1
Total sup 2000 2000 2000 2000 2000 1900

When calling getAccountReward member of GigBlack after that tokens where burned and after the last comit the reward estimation will be wrong, let's use the previous table as example:

	(Total users accounts rewards) / (supplyTimeTotal) = 1
	(1000 * 5 + 1000 * 3 + 800 * 2 + 200 * 1 + 100 * 1) / (1900 * 5) = 1.042

Instead of 1 we get 1.042.

Code snippet

https://github.com/GigziProject/GigziContracts/blob/ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8/contracts/GigBlack.sol#L132#L156

https://github.com/GigziProject/GigziContracts/blob/ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8/contracts/GigBlack.sol#L150

Recommendation

supplyTimeTotal should be set as state variable and updated almost the same way as a user account reward but only when tokens are burned, so we will get:

	(Total users accounts rewards) / (supplyTimeTotal)     = 1
	(1000 * 5 + 1000 * 3 + 800 * 2 + 200 * 1 + 100 * 1) / (2000 * 4 + 1900 * 1) = 1

3.6. Account Reward (txFeeCollector)

Sevirity: low

Description

The reward of txFeeCollector address is updated at each call of processTransfer member of GigBlack contract, adding more gas consumption to user transaction when this address probably belongs to Gigzi team, no reason is advanced for this extra computation.

Code snippet

https://github.com/GigziProject/GigziContracts/blob/ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8/contracts/GigBlack.sol#L199#L211

https://github.com/GigziProject/GigziContracts/blob/ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8/contracts/GigBlack.sol#L207#L208

3.7. Gas Consumption

Severity: medium

Description

This issue is marked as medium due to the recurent way that it appears. Gas consumption optimization is an important step in contract development, many optimization can be performed on GigBlack and FeeableToken contracts to save users gas at excution time. We strongly advise the developers to review their code to optimize gas usage following gas comsumption rules.

3.8. Migration Contract

Severity: minor remark

Description

The purpose of the Migration contract is unclear, no direct errors were found.

Code snippet

https://github.com/GigziProject/GigziContracts/blob/ffe57bdaf1b0d1fb29d182cd03c1890b3be50ac8/contracts/Migrations.sol#L1#L25

4. Conclusion

one critical issues has been found that need to be fixed to avoid possible loss for the project, other medium issues were also highlighted This contract has some logical errors that need to be fixed before launch of the ICO. The current version of the project cannot be used in live net.

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