Playnance - Audit 2

CertiKFiles named in the report

CertiK reviewed Playnance (Playnance - Audit 2) on 19 Jun 2024: 17 findings, 0 critical; 4 marked fixed, 13 open.

No open critical findings
Open the reportOpen Playnance’s security record

Report hosted on skynet.certik.com.

Trustblock does not review code.

Findings17

Statuses are the security firm’s own, from its report.

SeverityOpenAcknowledgedFixed
Critical000
High400
Medium000
Low904
HighAny User Can Burn TokensOpen

The USDP tokens is meant to be a stable coin and should only be burnable by the contract's owner, as seen from the way that the `ERC20Burnable.burn()` function is overwritten: ```solidity=31 function burn(uint256 amount) public override onlyOwner { super._burn(owner(), amount); } ``` However, the function `ERC20Burnable.burnFrom()` is not overwritten, allowing any user to burn their own tokens by first giving themself an allowance and then calling `burnFrom()`. As the USDP token is meant to be a stable coin, its supply is incredibly important for its tokenomics. Allowing arbitrary users to burn the stable coin causes the token to be at risk of depegging.

HighBets May Be Taken From Other PoolsOpen

When distributing winnings, winnings are distributed to all winners and then the fee and remaining tokens in the contract are distributed to the fee address. In the case of multiple pools, these remaining tokens may consist of bets made to other pools. ```solidity=420 if (winners.distributedCount == winners.bets.length) { sendToken( feeAddress, ((dist.fee + dist.totalMinusFee) * feePercentage) / 100 ); sendToken( feeJackpotAddress, ((dist.feeJackpot + dist.totalMinusJackpotFee) * feeJackpotPercentage) / 100 ); //Send leftovers to fee address sendToken(feeAddress, getContractTokenBalance()); ``` As such, these leftover tokens that were supposed to be used as bets for another pool are stolen by the fee address.

HighCentralization Related RisksOpen

In the contract `USDP` the role `_owner` has authority over the functions shown in the diagram below. Any compromise to the `_owner` account may allow the hacker to take advantage of this authority and mint stable coins to themself, take taxes for themself, or greatly increase taxes. ![](https://accelerator-tasks-prod.acc.corp.certik.com/11ef-0bd0-984a1630-9ea9-3118e42f544a/diagrams/centralization_usd-USDP-_owner.svg) --- In the contract `UpVsDownGameV8`, the role `_owner` has authority over the following functions: - `changeGameControllerAddress`: changes the address of the `gameController` role - `changeGameFeePercentage`: changes the fee rate - `changeGameFeeJackpotPercentage`: changes the jackpot fee rate - `changeGameFeeAddress`: changes the address that fees are sent to - `changeGameFeeJackpotAddress`: changes the address that jackpot fees are sent to - `stopGame`: stops the game from running, preventing the start of rounds and bets - `startGame`: starts the game, allowing the start of rounds and bets - `allowContract`: whitelists a contract to make bets - `removeContract`: removes a contract from the whitelist Additionally, the role `gameController` has authority over the following functions: - `createPool`: starts a new pool - `trigger`: starts or ends a round - `distribute`: returns bets or transfers bet winnings Any compromise to either of the above roles allows a hacker to disrupt the game and decide how a game will end.

HighCentralized Balance ManipulationOpen

In the contract `USDP`, the role `owner` has the authority to mint tokens to an arbitrary account without any restrictions. Any compromise to the `owner` account may allow a hacker to take advantage of this authority and manipulate users' balances. Since `USDP` is meant to be a stable coin, a hacker with access to the `owner` account would be able to acquire a large number of `USDP` stable coins or greatly manipulate the price of `USDP`.

LowIncorrect Upper Bound on Tax RateOpen

The documentation and comments state that the maximum tax rate is 1%. ```solidity=65 require(newTaxRate <= 1000, "Tax rate cannot exceed 1%"); ``` However, the tax rate is out of 10000, meaning the maximum tax rate is 1000/10000 = 10%. ```solidity=47 taxAmount = (amount * _taxRate) / 10000; ```

LowMints and Burns are TaxedOpen

The ERC20 `_update` function has been overwritten to apply taxes if the tax rate is positive. ```solidity=46 if (!_whitelist[from] && !_whitelist[to] && _taxRate > 0) { taxAmount = (amount * _taxRate) / 10000; require(taxAmount > 0, "Tax amount too low"); super._update(from, _taxWallet, taxAmount); //Send the tax amount to tax wallet } ``` In particular, mints and burns are by default taxed as the `_mint` and `_burn` functions use `_update`. ```solidity function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } ``` ```solidity function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } ``` However, it does not make sense for these operations to be taxed.

LowMissing Emit EventsOpen

It is important to emit events for sensitive actions, particularly those that can be executed by centralized roles or administrators. This ensures transparency and enables tracking of critical changes, which is essential for security and trust in the system. Missing event logs can indeed result in a lack of visibility and potential information loss.

LowMissing Zero Address ValidationOpen

Addresses are not validated before assignment or external calls, potentially allowing the use of zero addresses and leading to unexpected behavior or vulnerabilities. For example, transferring tokens to a zero address can result in a permanent loss of those tokens. ```solidity=23 _taxWallet = taxWallet; ``` - `taxWallet` is not zero-checked before being used. --- ```solidity=154 gameController = newGameController; ``` - `newGameController` is not zero-checked before being used.

LowNot Compliant With the EIP20 StandardOpen

When transferring tokens, a possible tax is taken on the amount transferred: ```solidity=46 if (!_whitelist[from] && !_whitelist[to] && _taxRate > 0) { taxAmount = (amount * _taxRate) / 10000; require(taxAmount > 0, "Tax amount too low"); super._update(from, _taxWallet, taxAmount); //Send the tax amount to tax wallet } ``` If the tax amount is 0, then the transfer fails. In particular, when transferring 0 tokens, the transfer will always fail as the tax amount will be 0 in this situation. This is not compliant with the EIP20 standard, as transfers of 0 tokens are expected to succeed: https://eips.ethereum.org/EIPS/eip-20. In addition, this creates an issue with interoperability. Smart contracts wishing to interact with the USDP contract would need to handle the situation when transferring 0 tokens, which is not the standard.

LowPotential Denial-of-Service AttackOpen

When returning bets or distributing winnings, a loop occurs where tokens are sent to the bettors for each iteration of the loop. ```solidity=297 for (uint i = group.distributedCount; i < to; i++) { sendToken(group.addresses[i], group.bets[i]); ``` Depending on the token used, such as tokens with hooks or callbacks, it may be possible for a malicious better to cause a transfer of tokens to fail, resulting in the entire loop reverting. As there are no other ways for bettors to receive their funds, their tokens will be locked in the contract.

Show 3 more
LowPotential Divide by ZeroOpen

Performing division by zero would raise an error and revert the transaction. ```solidity=393 uint256 winnings = ((winners.bets[i] * dist.totalFees * 100) / winners.total / ``` The expression `(winners.bets[i] * dist.totalFees * 100) / winners.total` may divide by zero. Note that this is only possible if the minimum bet is 0.

LowPotential Reentrancy Attack (Sending Tokens)Open

A reentrancy attack can occur when the contract creates a function that makes an external call to another untrusted contract before resolving any effects. If the attacker can control the untrusted contract, they can make a recursive call back to the original function, repeating interactions that would have otherwise not run after the external call resolved the effects. ### External call(s) ```solidity=298 sendToken(group.addresses[i], group.bets[i]); ``` * This function call executes the following external call(s). * In `UpVsDownGameV7.sendToken`, * `sent = token.transfer(to,amount)` ### State variables written after the call(s) ```solidity=307 group.distributedCount = to; ``` --- ### External call(s) ```solidity=330 returnBets(poolId, returnGroupUp, batchSize); ``` * This function call executes the following external call(s). * In `UpVsDownGameV7.sendToken`, * `sent = token.transfer(to,amount)` ```solidity=331 returnBets(poolId, returnGroupDown, batchSize); ``` ### State variables written after the call(s) ```solidity=354 clearPool(poolId); ``` * This function call executes the following assignment(s). * In `UpVsDownGameV7.clearPool`, * `delete pools[poolId].upBetGroup` * In `UpVsDownGameV7.clearPool`, * `delete pools[poolId].downBetGroup` * In `UpVsDownGameV7.clearPool`, * `delete pools[poolId].startPrice` * In `UpVsDownGameV7.clearPool`, * `delete pools[poolId].endPrice` ```solidity=331 returnBets(poolId, returnGroupDown, batchSize); ``` * This function call executes the following assignment(s). * In `UpVsDownGameV7.returnBets`, * `group.distributedCount = to` --- ### External call(s) ```solidity=363 returnBets(poolId, returnGroup, batchSize); ``` * This function call executes the following external call(s). * In `UpVsDownGameV7.sendToken`, * `sent = token.transfer(to,amount)` ### State variables written after the call(s) ```solidity=373 clearPool(poolId); ``` * This function call executes the following assignment(s). * In `UpVsDownGameV7.clearPool`, * `delete pools[poolId].upBetGroup` * In `UpVsDownGameV7.clearPool`, * `delete pools[poolId].downBetGroup` * In `UpVsDownGameV7.clearPool`, * `delete pools[poolId].startPrice` * In `UpVsDownGameV7.clearPool`, * `delete pools[poolId].endPrice` --- ### External call(s) ```solidity=397 sendToken(winners.addresses[i], winnings + winners.bets[i]); ``` * This function call executes the following external call(s). * In `UpVsDownGameV7.sendToken`, * `sent = token.transfer(to,amount)` ### State variables written after the call(s) ```solidity=408 winners.totalDistributed = winners.totalDistributed + winnings; ``` ```solidity=419 winners.distributedCount = to; ``` ```solidity=392 for (uint i = winners.distributedCount; i < to; i++) { ``` --- ### External call(s) ```solidity=397 sendToken(winners.addresses[i], winnings + winners.bets[i]); ``` * This function call executes the following external call(s). * In `UpVsDownGameV7.sendToken`, * `sent = token.transfer(to,amount)` ```solidity=421 sendToken( feeAddress, ((dist.fee + dist.totalMinusFee) * feePercentage) / 100 ); ``` ```solidity=425 sendToken( feeJackpotAddress, ((dist.feeJackpot + dist.totalMinusJackpotFee) * feeJackpotPercentage) / 100 ); ``` ```solidity=431 sendToken(feeAddress, getContractBalance()); ``` ### State variables written after the call(s) ```solidity=433 clearPool(poolId); ``` * This function call executes the following assignment(s). * In `UpVsDownGameV7.clearPool`, * `delete pools[poolId].upBetGroup` * In `UpVsDownGameV7.clearPool`, * `delete pools[poolId].downBetGroup` * In `UpVsDownGameV7.clearPool`, * `delete pools[poolId].startPrice` * In `UpVsDownGameV7.clearPool`, * `delete pools[poolId].endPrice` --- ### External call(s) ```solidity=561 token.transferFrom(_msgSender(), address(this), userTrade.amount); ``` ### State variables written after the call(s) ```solidity=563 newTotal = addBet( betGroup, _msgSender(), userTrade.amount, userTrade.avatarUrl, userTrade.countryCode, userTrade.whiteLabelId ); ``` * This function call executes the following assignment(s). * In `UpVsDownGameV7.addBet`, * `betGroup.bets.push(amount)` * In `UpVsDownGameV7.addBet`, * `betGroup.addresses.push(signer)` * In `UpVsDownGameV7.addBet`, * `betGroup.avatars.push(avatar)` * In `UpVsDownGameV7.addBet`, * `betGroup.countries.push(countryCode)` * In `UpVsDownGameV7.addBet`, * `betGroup.whiteLabelIds.push(whiteLabelId)` * In `UpVsDownGameV7.addBet`, * `betGroup.total += amount`

LowUnchecked ERC-20 `transfer()`/`transferFrom()` CaOpen

The return values of the `transfer()` and `transferFrom()` calls in the smart contract are not checked. Some ERC-20 tokens' transfer functions return no values, while others return a bool value, they should be handled with care. If a function returns `false` instead of reverting upon failure, an unchecked failed transfer could be mistakenly considered successful in the contract. ```solidity=561 token.transferFrom(_msgSender(), address(this), userTrade.amount); ```

Contracts in scope

No deployed address is recorded for this audit.

The report names a repository or files. Open the report to see its scope.

Repository and files the report names (2)

  • UpVsDownGameV8.sol
  • Game%20Token/usd.sol

Part of Playnance’s security record

Playnance
Audits2 audits by 1 firmLast audit Jun 2024, by CertiK.
Critical findings1 open critical findingReported in “UpVsDown” by CertiK, Sep 2023. Not marked fixed in that report.
Open Playnance’s security record

Security firm

CertiK

1,045 projects reviewed · 1,376 reports · latest May 2025

See CertiK’s audits

Something wrong on this page? A missing report, a wrong date, a finding that was fixed since. Tell us and we check it against its source.

Tell us