Coresky Ⅱ-Audit

CertiKFiles named in the report

CertiK reviewed CoreSky (Coresky Ⅱ-Audit) on 22 Mar 2023: 18 findings, 0 critical; 5 marked fixed, 13 open.

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

Report hosted on skynet.certik.com.

Trustblock does not review code.

Findings18

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

SeverityOpenAcknowledgedFixed
Critical000
High000
Medium200
Low1105
MediumIncompatibility with NFTs of `tokenID` 0Open

The `Escrow` contract is incompatible with `nft` contracts which allow for a `tokenID` of 0. This is because the `ledger` mapping uses the `uint256` of 0 as a default to identify that a user has not deposited a token into the contract. It is assumed that the `ERC721Template` contract may be used as the `nft` which interacts with the `Escrow` contract, and this contract allows for the possibility of minting a token with `tokenID` 0. If a user deposits a token with ID 0, then they will be unable to withdraw and the privileged `OPERATOR_ROLE` will be unable to intervene, since function `EmergencyWithdrawVault()` still requires that the check to `_onlyOwner` passes.

MediumVolatility when Updating `vault`Open

The `OPERATOR_ROLE` can update the address of `vault` at any time. This could cause unforeseen issues such as the following possibilities: - the `vault` is updated while users still currently have NFTs deposited in the formerly used `vault`. This will keep users from withdrawing their NFTs from the previously used `vault`, and will require an EOA address be granted role `WITHDRAW_ROLE` in `Vault` in order to get the users' tokens back. We note that it appears that `Escrow` contract is meant to have `WITHDRAW_ROLE`, and not an externally owned account; - if users' NFTs are withdrawn through the process listed above, they will still be listed as having deposited their NFTs in the `Escrow` contract, through mapping `ledger`, since there is no other way to update this mapping except through the withdrawal mechanics of `Escrow`. In such a case, this inaccuracy could cause many unforeseen issues. One consequence is that a user who undergoes this situation would no longer be able to participate in the `Escrow` contract.

LowChecks in `onlyNFT()`Open

The modifier `onlyNFT()` makes two checks, that the input address `token` is a contract and that the `token` address matches the address of `nft`. If the `nft` address is not a contract in the first place, the `Escrow` contract will not function as intended, so it should be enough to check in this modifier that the input address is the same as `address(nft)`. Instead, when the `nft` address is set in the constructor, it is more beneficial to ensure at that stage that the input address passes `isContract()`, since it is not updated after that stage.

LowDeclaration Naming ConventionOpen

One or more declarations do not conform to the [Solidity style guide](https://solidity.readthedocs.io/en/v0.7.3/style-guide.html#naming-conventions) with regards to its naming convention. Particularly: - `camelCase`: Should be applied to function names, argument names, local and state variable names, modifiers - `UPPER_CASE`: Should be applied to `constant` variables - `CapWords`: Should be applied to contract names, struct names, event names and enums ```solidity=2563 uint256[] calldata TokenID, ``` - Parameter `TokenID` is not in `camelCase`. --- ```solidity=1497 function EmergencyWithdrawVault ( ``` - Function `EmergencyWithdrawVault` is not in `camelCase`. --- ```solidity=1513 function EmergencyWithdraw ( ``` - Function `EmergencyWithdraw` is not in `camelCase`.

LowInefficient Memory ParameterOpen

One or more parameters with `memory` data location are never modified in their functions and those functions are never called internally within the contract. Thus, their data location can be changed to `calldata` to avoid the gas consumption copying from calldata to memory. ```solidity=1485 function onERC721Received( ``` `onERC721Received` has memory location parameters.

LowMissing Emit EventsOpen

Events should be emitted in sensitive functions controlled by centralization roles.

LowMissing InheritanceOpen

`Vault` implements the interface `IVault`, but does not inherit from it. ```solidity=1426 contract Vault is ``` ```solidity=1392 interface IVault { ```

LowMissing Zero Address ValidationOpen

The cited address inputs are missing a check that they are not `address(0)`.

LowPotential ReentrancyOpen

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. *This finding is considered minor because only the sequence of when the corresponding uris would are updated would be affected. So, the effect of out-of-order updates may be unobservable after transaction. However, the reentrancy vulnerability may still cause other issues in the middle of transaction.* ### External call(s) ```solidity=2531 _safeMint(to, tokenID); ``` * This function call executes the following external call(s). * In `ERC721._checkOnERC721Received`, * `(retval) = IERC721Receiver(to).onERC721Received(_msgSender(),from,tokenId,data)` ### State variables written after the call(s) ```solidity=2532 _setTokenURI(tokenID, uri); ``` * This function call executes the following assignment(s). * In `ERC721URIStorage._setTokenURI`, * `_tokenURIs[tokenId] = _tokenURI` --- ### External call(s) ```solidity=2545 _safeMint(msg.sender, tokenID); ``` * This function call executes the following external call(s). * In `ERC721._checkOnERC721Received`, * `(retval) = IERC721Receiver(to).onERC721Received(_msgSender(),from,tokenId,data)` ### State variables written after the call(s) ```solidity=2546 _setTokenURI(tokenID, uri); ``` * This function call executes the following assignment(s). * In `ERC721URIStorage._setTokenURI`, * `_tokenURIs[tokenId] = _tokenURI` --- ### External call(s) ```solidity=2556 _safeMint(to, tokenID); ``` * This function call executes the following external call(s). * In `ERC721._checkOnERC721Received`, * `(retval) = IERC721Receiver(to).onERC721Received(_msgSender(),from,tokenId,data)` ### State variables written after the call(s) ```solidity=2557 _setTokenURI(tokenID, uri); ``` * This function call executes the following assignment(s). * In `ERC721URIStorage._setTokenURI`, * `_tokenURIs[tokenId] = _tokenURI` --- ### External call(s) ```solidity=2569 _safeMint(to, TokenID[i]); ``` * This function call executes the following external call(s). * In `ERC721._checkOnERC721Received`, * `(retval) = IERC721Receiver(to).onERC721Received(_msgSender(),from,tokenId,data)` ### State variables written after the call(s) ```solidity=2570 _setTokenURI(TokenID[i], uri[i]); ``` * This function call executes the following assignment(s). * In `ERC721URIStorage._setTokenURI`, * `_tokenURIs[tokenId] = _tokenURI`

LowPotential Reentrancy Attack (Out-of-Order Events)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. *This finding is considered minor because the reentrancy only causes out-of-order events.* ### External call(s) ```solidity=1471 IERC721(nft).safeTransferFrom(msg.sender, address(vault), tokenID); ``` ### Events emitted after the call(s) ```solidity=1472 emit Deposit(msg.sender, msg.sender, tokenID); ``` We note here that the reentrancy cited in the call above can only be performed in the case where the centralized authority has been hacked and the hacker updates the `vault` contract to be a malicious contract. --- ### External call(s) ```solidity=1477 IVault(vault).withdrawERC721(address(nft), msg.sender, tokenID); ``` ### Events emitted after the call(s) ```solidity=1478 emit Withdraw(msg.sender, msg.sender, tokenID); ``` We note here that the reentrancy cited in the call above can be performed by any `msg.sender` that is a malicious contract, when receiving the corresponding NFT, through the `onERC721Received` logic. --- ### External call(s) ```solidity=1488 IERC721(nft).safeTransferFrom(address(this), address(vault), tokenID); ``` ### Events emitted after the call(s) ```solidity=1489 emit Deposit(sender, from, tokenID); ``` We note here that the reentrancy cited in the call above can only be performed in the case where the centralized authority has been hacked and the hacker updates the `vault` contract to be a malicious contract.

Show 3 more
LowShadowing Local VariableOpen

A local variable is shadowing another component defined elsewhere. ```solidity=2462 string memory name, ``` - Local variable `name` in `ERC721Template.constructor` shadows: - Function `name` in `ERC721` - Function `name` in `IERC721Metadata` --- ```solidity=2463 string memory symbol, ``` - Local variable `symbol` in `ERC721Template.constructor` shadows: - Function `symbol` in `ERC721` - Function `symbol` in `IERC721Metadata`

LowUnnecessary Interface UseOpen

The state variables `nft` and `vault` are already of type `IERC721` and `IVault` respectively. As such, they do not need to be wrapped in their respective interfaces again before use.

LowVariable Can Be Declared as ImmutableOpen

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. An advantage of immutable variables is that reading them is significantly cheaper than reading from regular state variables since they are not located in storage. ### ERC721Template - Variable `merkleReservedMinTokenID` can be declared as immutable; - Variable `merkleReservedMaxTokenID` can be declared as immutable; ### Escrow - Variable `nft` can be declared as immutable.

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

  • contracts/Vault.sol
  • contracts/Escrow.sol
  • contracts/ERC721Template.sol

Part of CoreSky’s security record

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