CubiSwap-Audit

CertiKFiles named in the report

CertiK reviewed Cubiswap (CubiSwap-Audit) on 15 Sep 2023: 12 findings, 0 critical; 6 acknowledged, 6 open.

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

Report hosted on skynet.certik.com.

Trustblock does not review code.

Findings12

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

SeverityOpenAcknowledgedFixed
Critical000
High040
Medium020
Low600
LowDivide Before MultiplyOpen

Performing integer division before multiplication truncates the low bits, losing the precision of calculation. ```solidity=166 uint256 cubiReward = multiplier.mul(cubiPerBlock).mul(pool.allocPoint).div(totalAllocPoint); ``` ```solidity=167 accCubiPerShare = accCubiPerShare.add(cubiReward.mul(1e12).div(lpSupply)); ``` --- ```solidity=192 uint256 cubiReward = multiplier.mul(cubiPerBlock).mul(pool.allocPoint).div(totalAllocPoint); ``` ```solidity=195 pool.accCubiPerShare = pool.accCubiPerShare.add(cubiReward.mul(1e12).div(lpSupply)); ```

LowIncompatibility with Deflationary TokensOpen

When transferring deflationary ERC20 tokens, the input amount may not be equal to the received amount due to the charged transaction fee. For example, if a user sends 100 deflationary tokens (with a 10% transaction fee), only 90 tokens actually arrived to the contract. However, a failure to discount such fees may allow the same user to withdraw 100 tokens from the contract, which causes the contract to lose 10 tokens in such a transaction. Reference: https://thoreum-finance.medium.com/what-exploit-happened-today-for-gocerberus-and-garuda-also-for-lokum-ybear-piggy-caramelswap-3943ee23a39f ```solidity=214 pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); ``` - Transferring tokens by `_amount`. ```solidity=215 user.amount = user.amount.add(_amount); ``` - This function call executes the following operation. - In `SafeMath.add`, - `uint256 c = a + b;` - The `_amount` appears to be used for bookkeeping purposes without compensating the potential transfer fees. --- ```solidity=233 pool.lpToken.safeTransfer(address(msg.sender), _amount); ``` - Transferring tokens by `_amount`. ```solidity=232 user.amount = user.amount.sub(_amount); ``` - This function call executes the following operation. - In `SafeMath.sub`, - `return a - b;` - The `_amount` appears to be used for bookkeeping purposes without compensating the potential transfer fees.

Lowlog info should be removedOpen

There are some console.log arguments within the codebase, this seems to only be used for development purposes and is not useful for users.

LowPotential Cross-Chain Replay AttackOpen

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=98 abi.encodePacked( '\x19\x01', DOMAIN_SEPARATOR, keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline)) ) ``` - Reading a state variable `DOMAIN_SEPARATOR`, which seems to be a cached chain ID value. - Encoding the cached chain ID value `DOMAIN_SEPARATOR`. ```solidity=104 address recoveredAddress = ecrecover(digest, v, r, s); ``` - Calling `ecrecover` with a hash that does not properly include the chain ID.

LowUnprotected InitializerOpen

One or more logic contracts do not protect their initializers. An attacker can call the initializer and assume ownership of the logic contract, whereby she can perform privileged operations that trick unsuspecting users into believing that she is the owner of the upgradeable contract. ```solidity=22 contract MasterChef is OwnableUpgradeable { ``` - `MasterChef` is an upgradeable contract that does not protect its initializer. ```solidity=77 function initialize( ``` - `initialize` is an unprotected initializer function.

LowWhitelist cannot be removedOpen

The owner of the contract `Cubitoken` can add users to whitelist utilizing function `addWhiteList`. Once a user is added to the whitelist, he cannot be removed.

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

  • contracts/libraries/SafaMath.sol
  • contracts/libraries/TransferHelper.sol
  • contracts/core/CubiSwapRouter.sol
  • contracts/libraries/UQ112x112.sol
  • contracts/MasterChef.sol
  • contracts/libraries/FixedPoint.sol
  • contracts/CubiToken.sol
  • contracts/libraries/CubiSwapLibrary.sol
  • contracts/core/CubiSwapPair.sol
  • contracts/core/CubiSwapFactory.sol

Part of Cubiswap’s security record

Cubiswap
Audits1 audit by 1 firmLast audit Sep 2023, by CertiK.
Critical findingsNo open critical findingsIn 1 report.
Open Cubiswap’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