PlayDapp - Audit 2

CertiKFiles named in the report

CertiK reviewed PlayDapp (PlayDapp - Audit 2) on 22 Jul 2024: 46 findings, 0 critical; 11 marked fixed, 4 acknowledged, 31 open.

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

Report hosted on skynet.certik.com.

Trustblock does not review code.

Findings46

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

SeverityOpenAcknowledgedFixed
Critical000
High010
Medium033
Low3108
Low`_bridgeAddress` Must Be Set By Inheriting ContraOpen

The variable `_bridgeAddress` is used in the `_onlyBridge` modifier, which is used with functions in the `HandlerHelpers` contract. However, it is not set in the constructor and does not have a setter function. Thus, it must be set by any contracts that inherit it.

Low`_destinationChainID` May Be Confused With EVM `COpen

The `_destinationChainID` is a unique identifier for a chain. The comments state that it is the `ChainID`, however, for example, a `CHAIN_ID` on an EVM chain can exceed the `type(uint8).max` so that this identifier must represent a number the protocol associates to each chain it supports.

Low`burnable` Cannot Be ReversedOpen

If a token is set to be burnable on accident or the token revokes the ability for the bridge to mint/burn, then there is no functionality to reverse the operation. As such, the token will not be able to be used with the same handler contract. If the token is to be supported then it may require the deployment of a new handler.

LowChange `uint` to `uint256`Open

The `uint` type is an alias for `uint256`. It is recommended to use `uint256` instead of `uint` for better readability.

LowCommented Out CodeOpen

There is functionality that is commented out throughout the codebase. We assume that this code is to be omitted, however, it may accidentally be left commented out.

LowConsider Removing Recipient From Locking FunctionOpen

When locking ERC20 or ERC721 tokens, they should always be transferred to the safe, which is `address(this)`. As such the `recipient` parameter can be removed and the logic can be hardcoded to send tokens to `address(this)`.

LowDiscussion On Daily And Transactional LimitsOpen

The relayers provide a centralization risk, that if a `_relayerThreshold` of the relayers are compromised, then all funds can be stolen. A recommended mitigation is to implement transactional and daily limits for each token. These can be used to prevent the loss of all funds in such a scenario and can be set individually for each token.

LowFunction Can Be Modified With `pure` Or `view`Open

`GenericHandler._onlyBridge()` and `HandlerHelpers._onlyBridge()` do not require modifying the contract state, nor do they need to receive Ether. However, these functions are not labeled with `pure` or `view` modifiers.

LowLogic May Be Simplified Depending On Intended SupOpen

Can you please provide the intended chains that you plan to support? In particular, do you plan on supporting chains whose addresses utilize different numbers of bytes? If the bridge is designed to only interact with specific chains, then some logic may be able to be simplified.

LowMissing ChecksOpen

### HandlerHelpers - The function `setResource()` does not check that `_resourceIDToContractAddress[resourceID]` and `_contractAddressToResourceID[contractAddress]` are not already set. - The function `setBurnable()` does not check if `_burnList[contractAddress]` is already true. ### GenericHandler - The function `setGenericResource()` does not check that `_resourceIDToContractAddress[resourceID]`, `_contractAddressToResourceID[contractAddress]`, ` _contractAddressToDepositFunctionSignature[contractAddress]`, and `_contractAddressToExecuteFunctionSignature[contractAddress]` are not already set. - The functions `deposit()` and `executeProposal()` make a low level call to the `contractAddress`. While these are set via privileged roles, these contracts may self destructor or be set accidentally to EOA's, in which case the low level call will return true without executing any functionality. We recommend adding a check that the `contractAddress` is a contract. ### GenericERC20NativeHandler - The function `setGenericResource()` does not check that `_resourceIDToContractAddress[resourceID]`, `_contractAddressToResourceID[contractAddress]`, ` _contractAddressToDepositFunctionSignature[contractAddress]`, and `_contractAddressToExecuteFunctionSignature[contractAddress]` are not already set. - The functions `deposit()`, `depositWithPermit()`, and `executeProposal()` make a low level call to the `contractAddress`. While these are set via privileged roles, these contracts may self destructor or be set accidentally to EOA's, in which case the low level call will return true without executing any functionality. We recommend adding a check that the `contractAddress` is a contract. ### Bridge - The function `adminChangeRelayerThreshold()` does not check that the input `newThreshold` is greater than or equal to some minimum. In particular, the threshold should always be at least one, as a proposal must be proposed (which yields one yes vote). - The function `adminSetTrustedHandlers()` does not check if the input `_handlerAddress` already has the role. - The function `adminChangeFee()` does not check that the input `newFee` is within some bounds. In particular, if a fee should always be charged the input should be greater than zero and the fee may not want to exceed a theoretical maximum amount. - In the `Bridge.executeProposal()` function, the potential expiration of a proposal is not checked. If `proposal._status == ProposalStatus.Passed` and `block.number - proposal._proposedBlock > _expiry`. A relayer can decide to execute a proposal or cancel it.

Show 10 more
LowMissing Emit EventsOpen

There should always be events emitted in any function that updates an important state variable.

LowMissing License IdentifiersOpen

The linked files do not include an SPDX license identifier. We recommend adding a license identifier to clarify how users are able to use the source code. See [https://spdx.org/licenses/](https://spdx.org/licenses/) for details.

LowMissing/Incomplete NatSpecOpen

Throughout the codebase there are NatSpec comments included for some functions but not all. Throughout the handler contracts, the `resourceID` is a parameter, but not included in the NatSpec comments.

LowOptimization in `Bridge.executeProposal()`Open

In `Bridge.executeProposal()`, the following checks: ```solidity=505 require(proposal._status != ProposalStatus.Inactive, "proposal is not active"); require(proposal._status == ProposalStatus.Passed, "proposal already transferred"); ``` are both checking the status of a proposal, since a proposal cannot be `Inactive` and `Passed` the first **require** statement is redundant. Moreover, a proposal not passed can be `Inactive`, `Active`, `Executed` or `Cancelled`, therefore the error message `"proposal already transferred"` is not always accurate.

LowOutdated Openzeppelin VersionOpen

The contract `ERC721MinterBurnerPauser` utilizes Openzeppelin's library v3.0.0, which is outdated. Outdated versions are not as well maintained and miss the new optimizations, features, and security enhancements included in the more recent versions version.

LowOutdated Solidity VersionOpen

The highlighted files use solidity version 0.6.4. Outdated versions might contain security issues and miss the new features and security enhancements included in the recent solidity version.

LowPermit Parameter DecodingOpen

The `uint8 v`, `bytes32 r`, and `bytes32 s` parameters for permit functions are encoded in the input data for deposits. However, when `abi.decode()` is used, they are first decoded as `uint256` values and then recast as their respective types when used in the external call to `permit()`. Since `abi.encode()` pads parameters to 32 bytes, this should not create any issues, however, it decreases the readability of the codebase when they can be directly decoded to their respective types.

LowPotential Underflow/OverflowOpen

In `Bridge.adminRemoveRelayer()`, `_totalRelayers` is decremented. Due to potential inconsistency between `_totalRelayers` and the real number of relayers, an underflow can occur.

LowRedundant CheckOpen

In the contract `Bridge.sol`, when a proposal is created in `voteProposal()`, `dataHash` is provided as input, and the `proposal` is then created as: ```solidity=427 _proposals[nonceAndID][dataHash] = Proposal({ _resourceID : resourceID, _dataHash : dataHash, _yesVotes : new address[](1), _noVotes : new address[](0), _status : ProposalStatus.Active, _proposedBlock : block.number }); ``` Therefore everytime the following check is made: ```solidity require(dataHash == proposal._dataHash, "datahash mismatch"); ``` it will pass because `dataHash == proposal._dataHash` is always true.

LowSafeMath Is UnusedOpen

The contracts `ERC721Safe` and `ERC20Safe` use `SafeMath` for `uint256`. However, no SafeMath operations are utilized in the contract.

Show 10 more
LowSafeMath Used For OZ Library And ContractOpen

The contract `SafeMath` is a stripped down version of OpenZeppelin's `SafeMath` library, that is used in the `Bridge.sol` file. However, the `SafeMath` library is also imported and used in other contracts. As they have the same name, this can cause confusion.

LowSolidity Style Guide Is Not FollowedOpen

The codebase does not follow the [Solidity Style Guide](https://docs.soliditylang.org/en/latest/style-guide.html#). For example variables and functions to not follow the naming conventions for non-external facing variables and functions. In addition, the order of functions is not followed where view and pure functions should be put in the end of a grouping.

LowSpecific Imports Are Not UsedOpen

Specific imports are recommended to be used to avoid unpredictable pollution of the namespace. For example: import {A, B, C} from "X";

LowThe Surplus Native Tokens Are Not ReturnedOpen

In the `payable` functions `Bridge.deposit()` and `Bridge.depositWithPermit()`, there's a validation to ensure `msg.value` meets the minimum required amount of native tokens. However, it's important to note that if `msg.value` exceeds this amount, the function currently lacks a mechanism to refund the excess. This oversight could lead to unintentional loss of funds for the caller, as any surplus in `msg.value` is not returned.

LowTypos And InconsistenciesOpen

### ERC721Safe - In the comments above the function `lockERC721()`, "custoday" should be "custody". ### Bridge - In the comments for the contract `Bridge`, "voting" is misspelled as "votiing". - The comments above the function `cancelProposal()` do not match its functionality. - In the function `voteProposal` both the storage variable reference `proposal` and `_proposals[nonceAndID][dataHash]` are used to update states of `_proposals[nonceAndID][dataHash]`. - The function `_onlyTrustedHandlers` uses the role `RELEASE_ETH_FUND_ROLE` which does not match its naming. ### Handler Contracts - Throughout the handler contracts the comments include the `resourceID` in the input `data`. However, the `resourceID` is taken as a separate input.

LowUnnecessary modifierOpen

In functions `Bridge.renounceAdmin()`, `Bridge.adminSetTrustedHandlers()`, `Bridge.adminAddRelayer()`, `Bridge.adminRemoveRelayer()` the use of `onlyAdmin` modifier is redundant since the same check is made by functions inherited from `AccessControl`.

LowUnused `_noVotes` in Struct `Proposal`Open

When the relayers vote for the proposals through `voteProposal()`, they can only vote `yes`. The `_noVotes` field in the following struct is never used. ```solidity=30 struct Proposal { bytes32 _resourceID; bytes32 _dataHash; address[] _yesVotes; address[] _noVotes; ProposalStatus _status; uint256 _proposedBlock; } ```

LowUnused VariableOpen

This temporary variable `_recipientAddress` is not used within the function `executeProposal()`.

LowUser-Defined GettersOpen

The linked functions are equivalent to the compiler-generated getter functions for the respective variables.

LowVariables That Could Be Declared as ImmutableOpen

The linked variables assigned in the constructor can be declared as `immutable`. Immutable state variables can be assigned during contract creation but will remain constant throughout the lifetime of a deployed contract. A big advantage of immutable variables is that reading them is significantly cheaper than reading from regular state variables since they will not be stored in storage.

Show 1 more
LowWraps In Contract Not InterfaceOpen

In the contract `ERC20Safe`, input addresses are wrapped in the contract `ERC20PresetMinterPauser` or `ERC20Burnable` as opposed to an interface. In the contract `ERC721Safe`, input address are wrapped in the contract `ERC721MinterBurnerPauser` as opposed to an interface.

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 (13)

  • contracts/ERC721Safe.sol
  • contracts/handlers/GenericHandler.sol
  • contracts/utils/SafeMath.sol
  • contracts/handlers/ERC20Handler.sol
  • contracts/ERC20Safe.sol
  • contracts/CentrifugeAsset.sol
  • contracts/utils/Pausable.sol
  • contracts/handlers/ERC721Handler.sol
  • contracts/ERC721MinterBurnerPauser.sol
  • contracts/utils/ChainId.sol
  • contracts/handlers/HandlerHelpers.sol
  • contracts/Bridge.sol
  • contracts/handlers/GenericERC20NativeHandler.sol

Part of PlayDapp’s security record

PlayDapp
Audits2 audits by 1 firmLast audit Jul 2024, by CertiK.
Critical findingsNo open critical findingsAcross 2 reports.
Open PlayDapp’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