WeMix - Nile Contract Audit

CertiKFiles named in the report

Audit

Part of CertiK’s retainer series

CertiK reviewed WEMIX (WeMix - Nile Contract Audit) on 8 Feb 2023: 58 findings, 5 critical; 43 marked fixed, 15 open.

5 critical findings, fixed
Open the reportOpen WEMIX’s security record

Report hosted on skynet.certik.com.

Trustblock does not review code.

Findings58

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

SeverityOpenAcknowledgedFixed
Critical005
High708
Medium2018
Low6012
HighCentralization Related RisksOpen

In the contract `Furnace`, the role `Editor` has authority over the functions - changeDAORouter() - changeBuyProbability() - changeBuyAmount() - changeUnit() Any compromise to the `Editor` account may allow the hacker to take advantage of this authority and - change the address of DAORouter - change buy probability - change the buy amount - change unit In the contract `NILEComponent`, any compromise to the `Editor` account may allow the hacker to take advantage of this authority and change the address of FundRouter. In the contract `ContractFactory`, any compromise to the `Editor` account may allow the hacker to take advantage of this authority and deploy DAO/Governance token. In the contract `Payment`, any compromise to the `Editor` account may allow the hacker to take advantage of this authority and init `SpellRegistry`, `Station`, `Furnace`, `Governance`, and `Treasury` addresses. In the contract `PteRegistry`, any compromise to the `Editor` account may allow the hacker to take advantage of this authority and register/change the address of Pte. In the contract `SpellRegistry`, any compromise to the `Editor` account may allow the hacker to take advantage of this authority and add/remove/change the address of Spell. In the contract `EditorRole`, any compromise to the `_owner` account may allow the hacker to take advantage of this authority and add/remove the address of the Editor. In the contract `MakerRole`, any compromise to the `Editor` account may allow the hacker to take advantage of this authority and add/remove the address of the Marker. In the contract `RouterRole`, any compromise to the `Editor` account may allow the hacker to take advantage of this authority and add/remove the address of the Router. In the contract `SystemRole`, any compromise to the `Editor` account may allow the hacker to take advantage of this authority and add/remove the address of the System. In the contract `DAORouter`, any compromise to the `Editor` account may allow the hacker to take advantage of this authority and init `SpellRegistry`, `Station`, `Furnace`, `StakingPool`, `Governance`, `WemixFi`, `WemixFiRouter`, `PteRegistry`, `Payment` and `Trust` addresses. In the contract `FundRouter`, any compromise to the `Editor` account may allow the hacker to take advantage of this authority and init `SpellRegistry`, `Station`, `Furnace`, `Verify`, `ReOpen`, `Treasury`, `Payment` and `Trust` addresses. In the contract `FundRouter`, any compromise to the `Pte` account may allow the hacker to take advantage of this authority and deposit funds. In the contract `FundRouter`, any compromise to the `System` account may allow the hacker to take advantage of this authority and purchase DAO tokens. In the contract `ReOpen`, any compromise to the `Maker` account may allow the hacker to take advantage of this authority and check the success or failure after DAO the recruitment fund ends. In the contract `ReOpen`, any compromise to the `_owner` account may allow the hacker to take advantage of this authority and change the denominator. In the contract `Station`, any compromise to the `Editor` account may allow the hacker to take advantage of this authority and init `StakingPool`, `PteRegistry`, `Treasury`, and `Governance` addresses. In the contract `Station`, any compromise to the `Maker` account may allow the hacker to take advantage of this authority and - create a new DAO - check the success or failure after DAO recruitment end - change the currency type In the contract `Station`, any compromise to the `_owner` account may allow the hacker to take advantage of this authority and change the unit. In the contract `Station`, any compromise to the `Editor` account may allow the hacker to take advantage of this authority and change the `Router` address. In the contract `UniswapV2Factory`, any compromise to the `FeeToSetter` account may allow the hacker to take advantage of this authority and change the `FeeTo`/`FeeToSetter` address.

HighCentralized Control of Contract UpgradeOpen

[Governance] and [StakingPool] are upgradeable contracts, the owner can upgrade the contract without the community's commitment. If an attacker compromises the account, he can change the implementation of the contract and drain tokens from the contract.

HighPotential Double VotingOpen

There's currently no time lag enforced between the creation of an agenda and the start of the voting period. A user can create an agenda and vote on the agenda in the same block. This creates the opportunity for double voting, in which user Alice creates an agenda, immediately vote on it, and then transfer all her governance token to an affiliated user Bob in the same block. Bob can then vote on the same agenda using the governance token received, because Bob's token balance at the time the agenda is created is the same as Alice's original governance token balance.

HighPotential Governance AttackOpen

The `GovernanceToken` inherits the `ERC20Votes` contract, in which the voting power is moved after token transfers. The `DAORouter` contract calculates each user's voting power based on the `getVotes(user)` function of the `GovernanceToken`, which retrieves the voting power in the most recent checkpoints. Therefore, it is possible for a user to use flash loan to borrow `GovernanceToken`, and call `createAgenda()`, and then return the flash loan. By doing so, the user can circumvent the minimum threshold to create an agenda in the `require()` statement below: ```soliidty=179 require(quorumRatio <= (gUserVote * denominator) / gTotalVote , "DAORouter(GV): User does not have permission to create agenda"); ``` Additionally, the user can also call `vote()` right after calling `createAgenda()` and before returning the flash loan, in order to manipulate the voting outcome.

HighPotential transferring user to user via `_transfeOpen

The comment says `//lock transfer user to user and user to staking pool`. But in the actual code, token/vote can be transferred from user to user if `_isAllowedDelegate` is `false`. Thus token/vote transfer can be done among any EOA. For example, user Bob can create agendas, if Bob transfers tokens to Alice, then Alice has access to create agendas.

Highsame user can vote multiple timesOpen

The function `isSameVote()` returns `true` if the user does not vote or revote. If a user calls the function `vote()` multiple times with the same answer, then the check of on line 217 passes. The votes of the user and the total votes will keep increasing via the function `_vote()`. So the user can keep voting until the agenda is passed. ```solidity=374 function _vote(uint daoId, uint agendaId, address user, VoteType opinion, uint num) private { Agenda memory proposal = _agendas[daoId][agendaId]; uint voteStatus = uint(proposal.status); VoteStatus storage board = _agendas[daoId][agendaId].board[voteStatus]; board.total += num; board.voteBox[uint(opinion)] += num; VoteInfo storage voteInfo = _voters[user][daoId][agendaId][voteStatus]; voteInfo.vote = opinion; voteInfo.num = voteInfo.num + num; emit Voted(daoId, agendaId, opinion, num); } ```

HighUsers do not receive DAO tokens when they reopenOpen

This contract is used when additional recruitment is made by DAOs already generated through the Station Contract. Additional recruitment starts only through the agenda proposed by governance, and the subsequent recruitment flow is the same as when initially recruited by Station. But there is no function to receive DAO tokens for the users who enter the reopen recruitment.

MediumIncorrect use of VRFOpen

The `ranChar` and `ranNum` in vrf are not verified at all against vrf parameters. So they can be manipulated with arbitrary values to bypass the probability check.

MediumInteger underflow will cause `liquidate()` to revOpen

If the first token in token collection has a zero balance, the code `i -= 1;` will underflow and cause 'liquidate()' to revert unintendedly.

Low`enterCount` is not updatedOpen

In the function `_cancel()`, the `totalEnterAmount` decreases the user's amount, and the `enterCount` decreases by 1. However, the function `_refund()` only reduces the user's amount and does not update `enterCount`. The function `_reOpenRefund()` in the contract `ReOpen` has the same issue.

Show 5 more
LowDivide by ZeroOpen

If the value of `totalSupply` is 0, the following two division operations will fail due to the divide by 0 error, which ultimately make the invocation to `burn()` function fail. ```solidity=149 amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution ```

LowIncompatibility With Deflationary TokensOpen

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 and the transaction may fail due to the validation checks.

LowIneffective `isContract()` CheckOpen

The `isContract()` function can not be used to decide whether an address is EOA because when it returns false, the address can either be EOA or contract in construction. See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol

LowPte Trust AssumptionOpen

The project assumes that the Pte would deposit fund and distribute revenue via the `deposit()` function. However, the Pte does not have to call the `deposit()` function, or it can deposit an amount that does not represent the business revenue generated. There does not appear to be any collateral required from the Pte either, potentially allowing the Pte that has received funds from the protocol to run away with it without any consequences.

LowUnknown Implementation of InterfacesOpen

The code base contains external function calls with unknown implementation, such as the below. The scope of the audit treats contracts that are out of scope, unknown implementation of interfaces, and other dependencies as black boxes and assumes their functional correctness. However, in the real world, these out of scope contracts can be compromised, potentially causing major vulnerability for the project. ```solidity=275 require(IVRF(_vrfVerify).verify(_publicKey, _proof, _seed), "FundRouter: invalid VRF"); ```

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

  • contracts/WemixFi/core/UniswapV2Factory.sol
  • contracts/Token/GovernanceToken.sol
  • contracts/Token/DAOToken.sol
  • contracts/WemixFi/core/UniswapV2ERC20.sol
  • contracts/WemixFi/core/libraries/Math.sol
  • contracts/Components/NILEComponent.sol
  • contracts/Governance/SpellBase.sol
  • contracts/WemixFi/core/libraries/SafeMath.sol
  • contracts/ContractFactory/ContractFactory.sol
  • contracts/Common/Queue.sol
  • contracts/WemixFi/WWEMIX.sol
  • contracts/WemixFi/core/UniswapV2Pair.sol
  • contracts/Station/Station.sol
  • contracts/Role/SystemRole.sol
  • contracts/Router/FundRouter.sol
  • contracts/WemixFi/core/libraries/UQ112x112.sol
  • contracts/Governance/Spells/DistributionSpell.sol
  • contracts/Components/FundManager/FundManager.sol
  • contracts/Governance/Governance.sol
  • contracts/Registry/PteRegistry.sol
  • contracts/Governance/Spells/GovernanceSpell.sol
  • contracts/StakingPool/StakingPool.sol
  • contracts/Components/Furnace/Furnace.sol
  • contracts/Station/ReOpen.sol
  • contracts/WemixFi/periphery/contracts/libraries/SafeMath.sol
  • contracts/Role/RouterRole.sol
  • contracts/Router/DAORouter.sol
  • contracts/WemixFi/Wrap.sol
  • contracts/Registry/SpellRegistry.sol
  • contracts/Governance/Payment/Payment.sol
  • contracts/WemixFi/periphery/contracts/libraries/UniswapV2LiquidityMathLibrary.sol
  • contracts/Governance/GovernanceProxy.sol
  • contracts/Components/Trust/Trust.sol
  • contracts/WemixFi/periphery/contracts/libraries/UniswapV2Library.sol
  • contracts/WemixFi/periphery/contracts/UniswapV2Router01.sol
  • contracts/Governance/Spells/RevenueSpell.sol
  • contracts/Governance/Spells/SwapSpell.sol
  • contracts/WemixDollar.sol
  • contracts/Common/DAOPausable.sol
  • contracts/Governance/Spells/LiquidationSpell.sol
  • contracts/Role/EditorRole.sol
  • contracts/Role/MakerRole.sol
  • contracts/WemixFi/periphery/contracts/libraries/UniswapV2OracleLibrary.sol
  • contracts/Governance/Spells/ReopenSpell.sol
  • contracts/Components/Treasury/Treasury.sol
  • contracts/StakingPool/StakingPoolProxy.sol
  • contracts/Governance/Spells/TreasurySpell.sol

Part of WEMIX’s security record

WEMIX
Audits75 audits by 1 firmLast audit Feb 2025, by CertiK.
Critical findingsNo open critical findingsAcross the 75 reports, 17 critical findings were reported. Each is marked fixed by the firm that reported it.
Open WEMIX’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