CertiK reviewed Blockchain Bets on 27 Feb 2023: 14 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 | 0 | 0 | 0 |
| Medium | 0 | 0 | 0 |
| Low | 14 | 0 | 0 |
If the value of `protected[sender]` is greater than zero, the transfer operation of the sender should not be validated against the `protectionLimit`. ```solidity=457 if (protected[sender] != 0){ require(amount <= protectionLimit * (10 ** _decimals) && lastSell[sender] == 0 && protectionTimer > block.timestamp, "Wallet protected, please contact support."); lastSell[sender] = block.number; } ``` Since the `protectionLimit` has already been multiplied by `(10 ** _decimals)` at line 333, the value can be large enough to allow any amount to bypass validation. The value for `protectionLimit` is set as 0 in the contract [0x597e43c8715a504bb7a7cec931c6daf69af5fafb3c4d5a791fe176ad41331a7f](https://etherscan.io/tx/0x597e43c8715a504bb7a7cec931c6daf69af5fafb3c4d5a791fe176ad41331a7f) which means protected users are not able to transfer at the time. It could lead to potential issues if the code is reused in the future.
When `shouldTakeFee(sender, recipient)` returns false, the `lastBuy[recipient]` will not be updated. This means that if someone is exempted from the fees through the whitelist, they will also be exempted from updating the `lastBuy` because it won't be changed anymore. As a result, they will also be considered as `isTxLimitExempt`. ```solidity=462 if (liquidityPools[recipient]) { lastSell[sender] = block.number; } else if (shouldTakeFee(sender, recipient)) { if (protectionEnabled && protectionTimer > block.timestamp && lastBuy[tx.origin] == block.number && protected[recipient] == 0) { protected[recipient] = block.number; emit ProtectedWallet(tx.origin, recipient, block.number, 1); } lastBuy[recipient] = block.number; if (tx.origin != recipient) lastBuy[tx.origin] = block.number; } ```
The public function `approve` does not call the internal function `_approve`, which does not comply with the code design principles and makes the `spender` lacking of zero address check.
The `swapBack` function transfers the `amountETHMarketing` native token to the `marketingFeeReceiver` if it is greater than zero. However, the code does not handle the return value of this transfer. ```solidity=534 (bool sentMarketing, ) = marketingFeeReceiver.call{value: amountETHMarketing}(""); if(!sentMarketing) { //Failed to transfer to marketing wallet } ```
The function `disablePause` will allow the `team` role to disable the pause functionality. However, if `disablePause` is invoked when `startBullRun` is false, it will block the `openTrading()` function.
Addresses should be checked before assignment or external call to make sure they are not zero addresses. ```solidity=312 if(!liquidityPools[addresses[i]] && !liquidityCreator[addresses[i]]) { _basicTransfer(from, addresses[i], amounts[i] * (10 ** _decimals)); } ``` - `addresses[i]` is not zero-checked before being used. --- ```solidity=322 (bool sent, ) = adr.call{value: (amountETH * amountPercentage) / 100}(""); ``` - `adr` is not zero-checked before being used. --- ```solidity=601 liquidityFeeReceiver = payable(_liquidityFeeReceiver); ``` - `_liquidityFeeReceiver` is not zero-checked before being used. --- ```solidity=602 marketingFeeReceiver = payable(_marketingFeeReceiver); ``` - `_marketingFeeReceiver` is not zero-checked before being used.
The `approve` function could be used in a Front-Running attack that allows a spender to transfer more tokens than the owner of the tokens ever wanted to allow the spender to transfer. Here is a possible attack scenario: Alice allows Bob to transfer N of Alice's tokens (N>0) by calling approve method on Token smart contract passing Bob's address and N as method arguments After some time, Alice decides to change from N to M (M>0) the number of Alice's tokens Bob is allowed to transfer, so she calls approve method again, this time passing Bob's address and M as method arguments Bob notices Alice's second transaction before it was mined and quickly sends another transaction that calls ·transferFrom· method to transfer N Alice's tokens somewhere If Bob's transaction will be executed before Alice's transaction, then Bob will successfully transfer N Alice's tokens and will gain the ability to transfer another M tokens Before Alice noticed that something went wrong, Bob calls ·transferFrom· method again, this time to transfer M Alice's tokens. So, Alice's attempt to change Bob's allowance from N to M (N>0 and M>0) made it possible for Bob to transfer N+M of Alice's tokens, while Alice never wanted to allow so many of her tokens to be transferred by Bob. ERC20 API: An Attack Vector on [Approve/TransferFrom Methods](https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/edit#heading=h.m9fhqynw2xvt)
A sandwich attack might happen when an attacker observes a transaction swapping tokens or adding liquidity without setting restrictions on slippage or minimum output amount. The attacker can manipulate the exchange rate by frontrunning (before the transaction being attacked) a transaction to purchase one of the assets and make profits by back running (after the transaction being attacked) a transaction to sell the asset. The following functions are called without setting restrictions on slippage or minimum output amount, so transactions triggering these functions are vulnerable to sandwich attacks, especially when the input amount is large: - `router.swapExactTokensForETHSupportingFeeOnTransferTokens()` - `router.addLiquidityETH()`
The function `checkTxLimit()` will be invoked during the token transfer it will update the `lastsell` and `lastbuy` for `sender`, `recipient`, and `tx.origin` accordingly. Based on the current design, the same recipient cannot receive the token twice in the same block. ```solidity=387 require(isTxLimitExempt[sender] || lastBuy[recipient] + rateLimit <= block.number, "Transfer rate limit exceeded."); ``` And `tx.origin` also cannot sell then buy(as the recipient) the token because of the same limitation: ```solidity=402 if (tx.origin != recipient) lastBuy[tx.origin] = block.number; ``` The concern is the `sender` is not limited by this restriction when `sender != tx.origin`.
In the function `_transferFrom()`, there is a chance to bypass the fee when sending a small amount due to truncation in solidity. ```solidity=480 function takeFee(address recipient, uint256 amount) internal returns (uint256) { bool selling = liquidityPools[recipient]; uint256 feeAmount = (amount * getTotalFee(selling)) / feeDenominator; _balances[address(this)] += feeAmount; return amount - feeAmount; } ``` This truncation will happen when the $amount * getTotalFee(selling) < feeDenominator$. \ This is worth noting that the math truncation is *unlikely* to happen due to the necessity of a small `amount` because the gas cost will be more expensive than the truncation profit.
The `owner` is exempt from fees and transaction limits by default. Yet when ownership is reset through `renounceOwnership()` or `transferOwnership()`, the exemptions are not granted to the new owner nor are they revoked from the previous `owner`.
State variables that never change should be declared as `constant` to save gas. ```solidity=193 address DEAD = 0x000000000000000000000000000000000000dEaD; ``` - `DEAD` should be declared `constant`. --- ```solidity=194 address ZERO = 0x0000000000000000000000000000000000000000; ``` - `ZERO` should be declared `constant`. --- ```solidity=200 uint256 _totalSupply = 1_000_000_000 * (10 ** _decimals); ``` - `_totalSupply` should be declared `constant`. --- ```solidity=227 address routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; ``` - `routerAddress` should be declared `constant`.
The contract serves as the underlying entity to interact with one or more third-party protocols. The scope of the audit treats third-party entities as black boxes and assumes their functional correctness. However, in the real world, third parties can be compromised, and this may lead to lost or stolen assets. In addition, upgrades of third parties can create severe impacts, such as increasing fees of third parties, migrating to new LP pools, etc. ```solidity=226 IDEXRouter public router; ``` Especially, the contract `BlockchainBets` interacts with a third-party contract with `IDEXRouter` interface via `router`. As the time of writing, the router address is [0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D](https://etherscan.io/address/0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D).
The return value of an external call is not stored in a local or state variable. ```solidity=512 router.swapExactTokensForETHSupportingFeeOnTransferTokens( amountToSwap, 0, path, address(this), block.timestamp ); ```
| Address | Chain | Source code |
|---|---|---|
| 0x2d88…eb7e0x2d886570a0da04885bfd6eb48ed8b8ff01a0eb7e | Chain: Ethereum | 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