Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yuriy77k/8918a74d8cd0f8bf0309867d25a2a632 to your computer and use it in GitHub Desktop.
Save yuriy77k/8918a74d8cd0f8bf0309867d25a2a632 to your computer and use it in GitHub Desktop.
Lottereum security audit

Lottereum smart contract security audit report

Summary

This is the report from a security audit performed on Lottereum by gorbunovperm.

In scope

  1. smart contract

Findings

In total, 5 issues were reported including:

  • 3 high severity issue.

  • 0 medium severity issues.

  • 2 low severity issues.

  • 0 minor observations.

Security issues

1. Known vulnerabilities of ERC-20 token

Severity: low

Code snippet

Description

It is possible to re-approve attack. More details here

Recommendation

The approval of a new amount must be made only when allowance is 0.

2. It is possible to lose owner rights occasionally.

Severity: low

Code snippet

Description

transferOwnership function doesn't have zero address check. And if the parameters of this function will not be added then owners rights will be transfered to 0x0 address.

Recommendation

Use require(newOwner != address(0)).

3. The lottery will paused when buying an each 1000th ticket.

Severity: high

Code snippet

if (amountOfTicketsForEthereumLotteryPurchased == 1000)
  playLotteryByEthereum();

Description

The lottery will blocked when buying a 1000th ticket and while the administrator does not call playLotteryBy... function it will be impossible to purchase new tickets. The reason is that playLotteryByEthereum and playLotteryByToken functions may be called only by admin or owner.

Recommendation

Mark this functions as internal. And make another functions like startLotteryByTokenManually with onlyAdministrator rights.

4. Anyone can add themselves as a participant without paying a commission.

Severity: high

Code snippet

function addParticipiant(address partAddress, LotteryType typeLot) {
  if(typeLot == LotteryType.Token) {
    if(numPartToken == participientsTokenLottery.length) {
      participientsTokenLottery.length += 1;
    }
    participientsTokenLottery[numPartToken++] = partAddress;
  }

  if(typeLot == LotteryType.Ethereum) {
    if(numPartEthereum == participientsEthereumLottery.length) {
      participientsEthereumLottery.length += 1;
    }
    participientsEthereumLottery[numPartEthereum++] = partAddress;
  }
}

Description

addParticipiant function is called from participateInTokenLottery with preliminary checks and commission paying. But also this function may be called by anyone.

Recommendation

Mark addParticipiant function as internal.

5. Highly unsafe ways to determine the winners.

Severity: high

Code snippet

Description

Rules for determining winners are very unsafe. The number of the last ticket is possible to view in storage. An attacker can buy a ticket at the right time and become a winner.

Recommendation

Look at here.

Conclusion

Several serious vulnerabilities have been found and further audit of the contract is terminated. It is necessary to fix it.

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