Part of CertiK’s series
CertiK reviewed SquidGrow (Old SquidGrow Token Contract) on 27 Oct 2023: 23 findings, 0 critical; none marked fixed.
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 | 3 | 0 | 0 |
| Medium | 1 | 0 | 0 |
| Low | 19 | 0 | 0 |
In the contract `SquidGrow` the role `authorized` has authority over the following functions: - authorize() - unauthorize() - transferOwnership() - renounceOwnership() - setFeeExempt() - setisBot() - setisInternal() - setbotOn() - syncContractPair() - approvals() - setPairReceiver() - setstartSwap() - setSwapBackSettings() - setMaxes() - rescueBEP20() - setExemptAddress() - setDivisors() - setStructure() - setInternalAddresses() Any compromise to the `authorized` account may allow the hacker to take advantage of this authority and - remove all funds (BNB, LP tokens, SquidGrow, etc) from the contract through functions `approvals()`, `rescueBEP20()`, and `syncContractPair()`; - set the `liquidity_receiver` to an address they control through `setPairReceiver()`; - authorize multiple addresses they control, set unintended internal addresses, and exempt addresses; - set their controlled address to be exempt from fees while exchanging large amounts of the token; - set addresses which are not bots to `isBot` status, causing addresses to be subject to larger fees; - set addresses they control to `isInternal` status so they can exceed the `maxWallet` value; - update the divisors, fees, maxes, and threshold value to the disadvantage of the user;
The `addLiquidity()` function calls the `router.addLiquidityETH` function with the `to` address specified as `liquidity_receiver` for acquiring the generated LP tokens from the `SquidGrow-BNB` pool. As a result, over time the `liquidity_reciever` address will accumulate a significant portion of LP tokens. If the `liquidity_receiver` is an EOA (Externally Owned Account), mishandling of its private key can have devastating consequences to the project as a whole. ```solidity router.addLiquidityETH{value: BNBAmount}( address(this), tokenAmount, 0, 0, liquidity_receiver, block.timestamp ); ```
All `SquidGrow` is sent to the `owner` address when deploying the contract. This could be a centralization risk as the `owner` can distribute tokens without obtaining the consensus of the community.
When `swapAndLiquify()` is called, `swapping` is set to true. The transaction will include a secondary call to function `transfer()`. Even though `swapping` is true, function `taxableEvent()` still allows for the possibility of taxes to be taken in the secondary transfer.
Function `_transfer()` disallows an input `amount` to be zero. However, fees collected could be 100% of the `amount` value. In that case, `amountReceived` will be 0, and a user will have paid for a transaction in which the `recipient` gets nothing.
Once an account gains `isDistributor` status, it cannot be revoked.
Contract `SquidGrow` inherits abstract contract `Auth`. This contract specifies both an `owner` and uses a mapping `authorizations` to track privileged accounts. State variable `owner` and modifier `onlyOwner` are unused within the contract. As such, the cited functions and state variables are unneeded.
Performing integer division before multiplication truncates the low bits, losing the precision of calculation. ```solidity=278 uint256 feeAmount = amount.mul(getTotalFee(sender, recipient)).div(feeDenominator); ``` ```solidity=279 uint256 bAmount = feeAmount.mul(burnFee).div(totalFees); ``` --- ```solidity=355 uint256 acBNBa = acBNB.mul(_na).div(_da); ``` ```solidity=356 uint256 acBNBf = acBNBa.mul(25).div(100); ``` --- ```solidity=405 uint256 unitBalance= deltaBalance.div(denominator.sub(liquidity_divisor)); ``` ```solidity=406 uint256 BNBToAddLiquidityWith = unitBalance.mul(liquidity_divisor); ```
The approval function of the ERC20 standard possesses a well-known vulnerability whereby two consecutive approvals can be exploited to instead “reset” the approval by consuming the approval that is meant to be replaced with a new one.
Function `setstartSwap()` can be updated more than once, which updates the `startedTime` to `block.timestamp.add(_input)`. If this function is called after `startedTime` has passed the first time, then any user making a transfer in the same block as the update may be subject to the 99% transfer fee.
Function `getCirculatingSupply()` has the following formula: ```solidity return _totalSupply.sub(balanceOf(DEAD)).sub(balanceOf(address(0))); ``` The `_totalSupply` already excludes the `balanceOf(address(0))`, and this value should not be subtracted away. Since tokens cannot be transferred to `address(0)` and since there is no burning mechanic which sends tokens tokens to `address(0)`, the inaccurate formula will show the correct value.
The conditional logic of the cited functions appears to allow for unforeseen fringe cases that may cause issues in the protocol. As set up, it is difficult to determine the meaning behind the checks made in each of the functions. Please clarify what each `if` condition is meant to determine in the functions cited. Additionally some of the logic appears to be counter to its intended use. For instance, function `checkBot()` may set either the `sender` or `recipient` as true in mapping `isBot` if the `msg.sender` is not the `tx.origin`. However, a recipient has no control over who sends tokens to them, and the `msg.sender` is never `tx.origin` when the `sender` is the `pair` address. If the `pair` address is updated to not be internal, then both the `pair` address and the `recipient` are set as bots. The `pair` being set as a bot may produce complications within the contract logic.
The transaction may be charged fees, so the max holding of the receiver should be the sum of the held tokens and the amount received from the transfer. The fees should not be included in the max holding. ```solidity=259 require((_balances[recipient].add(amount)) <= _maxWalletToken, "Exceeds maximum wallet amount.");} ``` - Max holding is checked. ```solidity=239 uint256 amountReceived = shouldTakeFee(sender, recipient) ? taketotalFee(sender, recipient, amount) : amount; ``` - Receiving amount is adjusted. ```solidity=240 _balances[recipient] = _balances[recipient].add(amountReceived); ``` - Balance is increased by the adjusted amount.
Sensitive functions controlled by privileged roles or which make important updates to the project should emit events.
The following checks should be made for input parameters. ### SquidGrow.sol - Function `setFeeExempt()` is missing a check that `_address` is not labeled as a bot. - Function `setisBot()` is missing a check that the `_address` is not `DEAD`. - Function `setisBot()` is missing a check that the `_address` is not exempt from fees. - Function `setPairReceiver()` is missing a check that `_address` is not `DEAD`. - Function `setDivisors()` is missing a check that the sum of the inputs is nonzero; if all values are set to 0, this will cause a revert in function `swapAndLiquify()`. - Function `setStructure()` is missing a check that the sum of `transferFee` and `totalFee` does not exceed 100% of the transfer amount.
Addresses should be checked before assignment or external call to ensure `address(0)` is not used.
The use of 19 as the `_decimals` value may cause the token to be incompatible with some projects.
When function `transferOwnership()` is called, the `owner` is changed to the new input `adr`, but the previous owner address remains in the `authorizations` mapping as `true`.
State variables that never change should be declared as `constant` to save gas.
The linked `transfer()` invocation does not check the return value of the function call which should yield a `true` result in case of proper ERC-20 implementation.
The `SafeMath` library is used unnecessarily. With Solidity compiler versions 0.8.0 or newer, arithmetic operations will automatically revert in case of integer overflow or underflow.
Use of Solidity's `transfer()` and `send()` functions for transferring Ether is not recommended, since some contracts may not be able to receive the funds. The cited functions forward only a fixed amount of gas (2300 specifically) and the receiving contracts may run out of gas before finishing the transfer. Also, EVM instructions' gas costs may increase in the future. Thus, some contracts that can receive now may stop working in the future due to the gas limitation.
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.
| Address | Chain | Source code |
|---|---|---|
| 0x8847…c7650x88479186bac914e4313389a64881f5ed0153c765 | Chain: Ethereum | Source code: Verified source |
| 0x8847…c7650x88479186bac914e4313389a64881f5ed0153c765 | Chain: BNB Chain | Source code: Verified source |
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