Part of CertiK’s retainer series
CertiK reviewed WEMIX (Wemix Retainer 102 DEX NFT Service) on 19 Mar 2024: 9 findings, 0 critical; 4 marked fixed, 5 open.
Report hosted on skynet.certik.com.
Trustblock does not review code.
Statuses are the security firm’s own, from its report.
| Severity | Open | Acknowledged | Fixed |
|---|---|---|---|
| Critical | 0 | 0 | 0 |
| High | 2 | 0 | 0 |
| Medium | 1 | 0 | 1 |
| Low | 2 | 0 | 3 |
A diamond proxy contract, also known as a "diamond," is a design pattern for Ethereum smart contracts that is introduced by [Ethereum Improvement Proposal (EIP) 2535](https://eips.ethereum.org/EIPS/eip-2535). The diamond pattern allows a contract to have an unlimited number of functions by separating the contract's functions into smaller contracts called "facets." The diamond acts as a proxy that routes function calls to the appropriate facets. The `Diamond` contract within the audit scope works as the diamond proxy, the `contractOwner` can add/remove/replace any facets. Any compromise of the privileged account could allow a hacker to exploit this authority and execute malicious functionality within the implementation contract.
In the contract `DiamondCutFacet` the role `contractOwner` has authority over the following function: - diamondCut(): add/remove/replace facets of a diamond proxy Any compromise to the `contractOwner` account may allow the hacker to take advantage of this authority. In the contract `OwnershipFacet` the role `contractOwner` has authority over the following function: - transferOwnership(): transfer the ownership Any compromise to the `contractOwner` account may allow the hacker to take advantage of this authority. In the contract `ERC721Facet` the role `contractOwner` has authority over the following function: - function `initialize()`, to set the `_name`, `_symbol`, `_baseURI` of ERC721Storage and the `birthAt` of CharacterStorage. Any compromise to the `contractOwner` account may allow the hacker to take advantage of this authority. In the contract `CharacterFacet` the role `contractOwner` has authority over the following function: - function `registerCharacter()`, to add `characterIDList` to CharacterStorage. Any compromise to the `contractOwner` account may allow the hacker to take advantage of this authority. In the contract `GachaTableInitFacet` the role `contractOwner` has authority over the following function: - function `initialize()`, to set the `dev` of GachaStorage; - function `setBonusStatGacha()`, to set the `bonusStat` of GachaStorage; - function `setCharacterGacha()`, to set the `bonusCharacter` of GachaStorage; - function `newGacha()`, to add `gachaIDList` to GachaStorage and set `collections` and `grades` for Gacha; - function `addGachaCharacter()`, to add `characters` to Gacha; - function `addGachaCollection()`, to add `collections` to Gacha. Any compromise to the `contractOwner` account may allow the hacker to take advantage of this authority.
The `random` number generation is based on the result of the function `nextSeed()`; And the inputs are the result of `newSeed()`, `keccak256` encryption of `block.number`,`gasleft()` etc... which is easy to control or get. The inputs can be controlled by the caller of the transaction. ```solidity function newSeed(GachaStorage storage _gs, bytes memory _salt) internal returns (uint256) { uint256 _seed = uint256(keccak256(abi.encodePacked(_gs.seed, _salt, msg.sender, block.timestamp, gasleft()))); _gs.seed = _seed; return _seed; } function nextSeed(uint256 _seed, uint256 _maxRatio) internal pure returns (uint256 next, uint256 value) { if (_maxRatio == 0) revert ZeroMaxRatio(); unchecked { value = _seed % _maxRatio; next = _seed / _maxRatio; } } ``` The `nextSeed()` is called multiple times in the function `_executeGacha()`, and the result(value,ratio) of the prior call is used as input to invoke the subsequent call. However, the result is still not randomized, which would result in the result being deterministic. ```solidity function _executeGacha( LibGacha.GachaStorage storage _gs, LibCharacter.CharacterStorage storage _cs, uint256 _gachaID, LibGacha.Gacha storage _gacha, bytes memory _salt ) private { address _owner = msg.sender; // call `nextSeed` 3 times in this internal function (uint256 _seed, uint256 _characterID) = _gachaCharacterID(_gs.newSeed(_salt), _gacha); // call `nextSeed` 2 times in this internal function LibCharacter.Info memory _characterInfo = _gachaCharacterInfo(_cs, _gs, _seed, _characterID); uint256 _tokenID = LibCharacter.mint(_cs, _owner, _characterInfo); emit GachaExecuted(_owner, _gachaID, _tokenID); } ``` Given that the randomize is used on the mint of new Gacha, a user could wait until an "appropriate" block number happens, input prepared gas and other parameters to execute the transaction, and gain an advantage on the random generation of a new Gacha, which would impact its base and bonus stats.
When transferring standard ERC20 deflationary tokens, the input amount may not be equal to the received amount due to the charged transaction fee. As a result, an inconsistency in the amount will occur. For example, if a user sends 100 deflationary tokens (with a 10% transaction fee) to the target contract, only 90 tokens arrive at the contract.
In the `LibCharacter` library, the `Base` and `Info` structs are put directly in the `CharacterStorage`. It is not able to add new state variables to inner structs in upgrades without overwriting the storage slot of variables declared after the struct. ```solidity=16 struct Base { uint16 collection; uint16 grade; uint32[STAT_SIZE] stat; } // Info 32 bytes struct Info { uint32 id; uint8 level; uint8 powerBonus; // x % POWER_MC uint32[STAT_SIZE] stat; } // @custom:storage-location erc7201:diamond.standard.character.v1.storage struct CharacterStorage { uint256 birthAt; LibERC721.ERC721Storage character; EnumerableSet.UintSet characterIDList; mapping(uint256 => Base) bases; // characterID => CollectionGrade mapping(uint256 => Info) infos; // tokenID => Info; } ```
The report names a repository or files. Open the report to see its scope.
Repository and files the report names (16)
1,045 projects reviewed · 1,376 reports · latest May 2025
See CertiK’s auditsSomething 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