Part of CertiK’s series
CertiK reviewed Venus Protocol (Venus - Swap Router) on 22 May 2023: 14 findings, 1 critical; 13 marked fixed, 1 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 | 1 | 0 | 0 |
| Medium | 0 | 0 | 0 |
| Low | 0 | 0 | 12 |
The `PancakeLibrary` is used to interact with pairs created through the `PancakeRouter v2` (See [0x10ed43c718714eb63d5aa57b78b54704e256024e](https://bscscan.com/address/0x10ed43c718714eb63d5aa57b78b54704e256024e#code) for deployed code). In `v1` the fee was $0.2\%$, however, the fees were changed in `v2` to be $0.25\%$. The logic here assumes that the fee is only $0.2\%$, when in fact a $0.25\%$ fee will be taken. This means that the calculated `amountIn` will be less than the amount needed and the `amountOut` will be greater than the amount that can be received, causing the constant product to not be preserved and reverting the transaction.
The `natspec` comments of many functions cited above are missing the parameter `deadline`. The `natspec` comment for the function `sweepToken()`, is missing the parameter `to`.
When transferring `WBNB` the call is checked to be successful via an assert statement. However, the `TransferHelper` library's functions can be used in place of this.
The functions `_checkForAmountOut()` and `_getSwapAmount()` have an input array of addresses `path`, however, only the last element is used. A single address can instead be taken as input to reduce gas costs. In addition, the last element of the path `path[path.length - 1]` is used multiple times in functions, storing this in a temporary variable and referencing the temporary variable can save gas.
The comments above some of the functions that support fee on transfer tokens in the contract `SwapRouter` do not mention how it is intended to be used for fee on transfer tokens.
Custom Errors are used throughout the codebase, however, string errors are still used in the codebase.
The following check is performed in the function `getAmountIn()` and `getAmountOut()`: ```solidity if (reserveIn == 0 && reserveOut == 0) { revert InsufficientLiquidity(); } ``` However, this check does not cover the case when either `reserveIn` or `reserveOut` is 0, while the other is nonzero.
The comment above `sweepToken` states that tokens are sent to admin (timelock). However, the tokens are sent to the input `to` address, which may not be the admin.
The following two checks are performed: ```solidity require(reserveA > 0 && reserveB > 0, "PancakeLibrary: INSUFFICIENT_LIQUIDITY"); ``` which will revert if `reserveA` or `reserveB` is zero. ```solidity if (reserveA == 0 && reserveB == 0) { revert InsufficientLiquidity(); } ``` which will revert if `reserveA` and `reserveB` are zero. Thus this check is not needed as the require statement covers it.
It is checked that the input `vTokenAddress` is listed, however, there is no check that the final element of the input `path` is the underlying of the `vToken`. As approval is given for the last element of the input `path` to either repay or supply, it should be checked that it corresponds to the underlying of the `vToken`. It is not checked that the input `vBNBAddress` is listed. It should be checked that this is a listed market, or alternatively, the input can be removed and the address stored by the contract itself.
In the `constructor()`, the input `_comptrollerAddress` is not checked if it is the zero address.
A reentrancy attack can occur when the contract creates a function that makes an external call to another untrusted contract before resolving any effects. If the attacker can control the untrusted contract, they can make a recursive call back to the original function, repeating interactions that would have otherwise not run after the external call resolved the effects. * Reentrancy can occur during the swaps as they will make external calls to the receiver of the tokens, this will cause the corresponding swap events to be emitted out of order. * If a token implements hooks that make external calls, then reentrancy can also occur during token transfers, which may cause events to be emitted out of order. * Token addresses are also provided as inputs, so that it is possible that a token is provided that can cause reentrancy with any external call made to it (for example if `balanceOf`), which may cause events to be emitted out of order. *This finding is considered minor because the reentrancy only causes out-of-order events.*
In general, the counter in a for loop can be incremented or decremented in an unchecked block.
The report names a repository or files. Open the report to see its scope.
Repository and files the report names (13)
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