CertiK reviewed OKX (OKC Swap) on 13 Dec 2022: 9 findings, 0 critical; 2 acknowledged, 7 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 | 0 |
| High | 0 | 1 | 0 |
| Medium | 0 | 1 | 0 |
| Low | 7 | 0 | 0 |
In the contract `StakingRewards`, the role `rewardsDistribution` has authority over the functions shown in the diagram below. Any compromise to the `rewardsDistribution` account may allow the hacker to take advantage of this authority and change the amount of rewards or the reward duration.  In the contract `StakingRewardsFactory`, 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 change the amount of rewards or the reward duration for staking contracts.  In the contract `OKCSwapFactory`, the role `feeToSetter` has authority over the functions shown in the diagram below. Any compromise to the `feeToSetter` account may allow the hacker to take advantage of this authority and change the amount of liquidity fees as well as change the fee recipient.  In the contract `OKCSwapPair` the role `factory` has authority over the functions shown in the diagram below. Any compromise to the `factory` account may allow the hacker to take advantage of this authority and initialize the incorrect tokens for the pair. 
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=90 stakingToken.safeTransferFrom(msg.sender, address(this), amount); ``` - Transferring tokens by `amount`. ```solidity=85 _balances[msg.sender] = _balances[msg.sender].add(amount); ``` - The `amount` is used for bookkeeping purposes without compensating for potential transfer fees. --- ```solidity=98 stakingToken.safeTransferFrom(msg.sender, address(this), amount); ``` - Transferring tokens by `amount`. ```solidity=97 _balances[msg.sender] = _balances[msg.sender].add(amount); ``` - The `amount` is used for bookkeeping purposes without compensating for potential transfer fees. --- ```solidity=45 require( rewardsToken.transfer(stakingRewards, rewardAmount), 'StakingRewardsFactory::notifyRewardAmount: transfer failed' ); ``` - Transferring tokens by `rewardAmount`. ```solidity=49 StakingRewards(stakingRewards).notifyRewardAmount(rewardAmount,rewardsDuration); ``` - The `rewardAmount` is used for bookkeeping purposes without compensating for potential transfer fees. ### Proof of Concept The following unit test created using `forge` demonstrates the issue by performing the following: 1. A deflationary ERC20 token is created where when transferring tokens, only 90% of the inputted amount is transferred 2. The test mints 100 tokens to the contract and the contract stakes 100 tokens 3. The staking balance is compared with ERC20 balance of the staking contract 4. The test fails as expected as the staking balance is 100 while the ERC20 balance is 90 ```solidity pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "forge-std/Test.sol"; import {mockERC20} from "../src/mocks/mockERC20.sol"; import {mockWETH} from "../src/mocks/mockWETH.sol"; import {StakingRewards} from "../src/farm/StakingRewards.sol"; contract DeflationaryERC20 is mockERC20 { function _transfer(address sender, address recipient, uint256 amount) internal override { amount = amount * 9 / 10; super._transfer(sender, recipient, amount); } } contract StakingRewardsTest is Test { StakingRewards public stakingRewards; DeflationaryERC20 public mockToken; mockWETH public WETH; function setUp() public { mockToken = new DeflationaryERC20(); WETH = new mockWETH(); stakingRewards = new StakingRewards(address(mockToken), address(WETH)); } function testStakeDeflationary() public { mockToken.mint(address(this), 100); mockToken.approve(address(stakingRewards), 100); stakingRewards.stake(100); uint256 balance = stakingRewards.balanceOf(address(this)); uint256 actualBalance = mockToken.balanceOf(address(stakingRewards)); assertFalse(actualBalance == balance); } } ```
The report names a repository or files. Open the report to see its scope.
Repository and files the report names (23)
1,044 projects reviewed · 1,375 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