Part of CertiK’s retainer series
CertiK reviewed WEMIX (Wemix Retainer 84 WMX.Fi (external audit)) on 24 Jan 2024: 14 findings, 1 critical; 4 marked fixed, 10 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 | 1 |
| High | 2 | 0 | 0 |
| Medium | 2 | 0 | 2 |
| Low | 6 | 0 | 1 |
In the contract `Oracle` the role `darkOracle` has authority over the functions shown in the diagram below. Any compromise to the `darkOracle` account may allow the hacker to take advantage of this authority and settle orders, liquidating user positions at an undesirable value, causing financial loss to the user.  In the contract `Oracle` 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 modify critical parameters of the project, damaging the operation of the project, and causing financial loss to the users.  ----- In the contract `OracleForwarder` 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 modify critical configurations of the project, damaging the operation of the project, and causing financial loss to the users.  ----- In the contract `Pool` 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 modify critical parameters of the project, damaging the operation of the project, and causing financial loss to the users.  ----- In the contract `Rewards` 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 modify the router address and withdraw tokens from the contract  ----- In the contract `Router` 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 modify critical parameters of the project, and damaging the operation of the project, causing financial loss to the users.  ----- In the contract `Trading` the role `oracle` has authority over the functions shown in the diagram below. Any compromise to the `oracle` account may allow the hacker to take advantage of this authority and settle orders, liquidating user positions at an undesirable value, causing financial loss to the user.  In the contract `Trading` 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 * Modify the router address * Modify the minimal margin * Add a new "product" and modify "product" list * Release margin * Damaging the operation of the project, causing financial loss to the users.  ----- In the contract `Treasury` the role `oracle` has authority over the functions shown in the diagram below. Any compromise to the `oracle` account may allow the hacker to take advantage of this authority and move funds from "Treasury" to the "Oracle".  In the contract `Treasury` 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 modify the router address and withdraw funds from the contract. 
All of the WMX tokens are sent to the contract deployer. This is a centralization risk because the deployer can distribute tokens without obtaining the consensus of the community. Any compromise to these addresses may allow a hacker to steal and sell tokens on the market, resulting in severe damage to the project.
The system requires an off-chain oracle (DarkOracle) to settle orders (`settleOrders`) and liquidate positions (`liquidatePositions()`). The audit's scope treats third-party off-chain oracles as black boxes and assumes their functional correctness. However, in the real world, the oracles can be compromised or malfunction, which may result in lost or stolen assets.
A possible rounding issue was identified in the reward calculation mechanism of the smart contract. The logic in question can lead to precision loss and result in some rewards not being credited to users. Specifically, the problem arises within the `updateRewards` function. When `pendingReward * UNIT` is less than `supply`, the division results in a round-down to zero, causing the value of `cumulativeRewardPerTokenStored` not to increase as intended. There is also a precision loss even in the case where the result is different from zero, this will occur whenever the pendingReward * UNIT is not divisible by the supply. This behavior fails to reflect the true amount of reward that should be accumulated per token, resulting in a discrepancy that leads to reward loss for users. ```sol=60 if (supply > 0) { cumulativeRewardPerTokenStored += pendingReward * UNIT / supply; pendingReward = 0; } ```
The smart contract contains a pair of functions `submitOrder` and `settleOrder` that enable users to open positions on the trading platform. During the `submitOrder` process, a check for `maxLeverage` is performed. However, it has been identified that `settleOrder`, which is executed by an external oracle, is missing this check. Due to the potential time gap between `submitOrder` and `settleOrder`, the currency price may fluctuate, resulting in a possibility where the user’s position might exceed the `maxLeverage` at the time of settlement.
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=32 owner = newOwner; ``` - `newOwner` is not zero-checked before being used. --- ```solidity=36 router = _router; ``` - `_router` is not zero-checked before being used. --- ```solidity=44 currency = _currency; ``` - `_currency` is not zero-checked before being used. --- ```solidity=48 owner = newOwner; ``` - `newOwner` is not zero-checked before being used. --- ```solidity=52 router = _router; ``` - `_router` is not zero-checked before being used. --- ```solidity=37 pool = _pool; ``` - `_pool` is not zero-checked before being used. --- ```solidity=38 currency = _currency; ``` - `_currency` is not zero-checked before being used. --- ```solidity=42 owner = newOwner; ``` - `newOwner` is not zero-checked before being used. --- ```solidity=46 router = _router; ``` - `_router` is not zero-checked before being used. --- ```solidity=81 treasury = _treasury; ``` - `_treasury` is not zero-checked before being used. --- ```solidity=82 trading = _trading; ``` - `_trading` is not zero-checked before being used. --- ```solidity=83 wmxPool = _wmxPool; ``` - `_wmxPool` is not zero-checked before being used. --- ```solidity=84 oracle = _oracle; ``` - `_oracle` is not zero-checked before being used. --- ```solidity=85 darkOracle = _darkOracle; ``` - `_darkOracle` is not zero-checked before being used. --- ```solidity=108 owner = newOwner; ``` - `newOwner` is not zero-checked before being used. --- ```solidity=94 owner = newOwner; ``` - `newOwner` is not zero-checked before being used. --- ```solidity=98 router = _router; ``` - `_router` is not zero-checked before being used. --- ```solidity=25 owner = newOwner; ``` - `newOwner` is not zero-checked before being used. --- ```solidity=29 router = _router; ``` - `_router` is not zero-checked before being used.
The perpetual contract project allows users to deposit funds into a pool, which serves as liquidity for other users engaging in perpetual trading against the pool providers. An issue is discovered in the contract's handling of deposits and withdrawals amount calculation; it fails to account for unrealized profits and losses. This vulnerability exposes the pool to front-running tactics. Specifically, if someone detects a significant position that is about to be liquidated, they can front-run the transaction by depositing it first. Similarly, if a large profitable position is about to be settled, a liquidity provider can front-run the transaction to minimize the loss.
Signed messages are not properly verified with the current chain ID, thus allowing attackers to perform replay attacks across chains. Hardcoded or cached chain ID values are also vulnerable since a hard fork may occur and change the chain ID in the future. ```solidity=51 require(_verify(users, productIds, currencies, directions, prices, signer, nonce, signature), "Invalid signature"); ``` - Calling `_verify`, which eventually calls `ecrecover`. ```solidity=142 address signer = ecrecover(hash, v, r, s); ``` - Calling `ecrecover` with a hash that does not properly include the chain ID.
The method used by the pool to calculate user shares is possibly vulnerable to "Inflation Attacks". In essence, an attacker can deposit one share into the pool when the vault is empty and front-run another user's deposit. This action causes the subsequent user's deposit to receive zero shares, effectively stealing the other user's deposit. For more information regarding "Inflation Attacks," please see: https://blog.openzeppelin.com/a-novel-defense-against-erc4626-inflation-attacks
The "ReleaseMargin" function enables the owner to close a position and refund all the principal, possibly including the fee, to the user. The auditor would like to know why such a function, which can create an unfair situation for most of the protocol users, is added to the contract.
The report names a repository or files. Open the report to see its scope.
Repository and files the report names (9)
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