Part of CertiK’s series
CertiK reviewed Venus Protocol (Venus - Private Conversions) on 27 Nov 2023: 12 findings, 0 critical; 9 marked fixed, 3 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 | 2 | 0 | 0 |
| Medium | 0 | 0 | 1 |
| Low | 1 | 0 | 8 |
In the function `setConversionConfig()`, the following check is made: ```solidity if ( ((conversionConfigurations[tokenAddressIn][tokenAddressOut].conversionAccess == ConversionAccessibility.ONLY_FOR_CONVERTERS) || (conversionConfigurations[tokenAddressIn][tokenAddressOut].conversionAccess == ConversionAccessibility.ALL)) && (address(converterNetwork) == address(0)) ) { revert InvalidConverterNetwork(); } ``` This check is performed on what is already recorded within `conversionConfigurations` mapping, rather than the input that is being used for `conversionConfig.conversionAccess`. This means that the function allows an update to this state, but that the configuration cannot be corrected unless the `address(converterNetwork)` is first updated to a nonzero address. Can you provide more information on the intended purpose of this check? Is it structured in this way with consideration of the change from an `enabled` bool to a `conversionAccess` enum during upgrade, or should it have been an input validation check?
*Venus has documented that they do not currently support tokens with hooks. This finding is created in consideration of future support for tokens with hooks or callback features.* Function `_findTokenConverters()` in contract `ConverterNetwork` reads the `balanceOf()` value of token converter contracts. In the case of the `RiskFundConverter` contract, this returns the value of `assetsReserves` for the input `tokenAddress`. It is important to note that this value is not updated until after transfers occur, in both `updateAssetsState()` and in any token converting functions it inherits from `AbstractTokenConverter`. Consequently, this value may not accurately reflect the state of the `RiskFundConverter` contract in the order in which it is read, if tokens with hooks are supported within the protocol. Any logic depending upon this read value within `_findTokenConverters()` may consequently fail or act unexpectedly, preventing conversions between token converter contracts.
In the contract `RiskFundConverter`, the function `_postPrivateConversion()` makes the following call: ```solidity IRiskFund(destinationAddress).updatePoolState(comptroller, tokenAddressIn, convertedTokenInBalance); ``` However, the `convertedTokenInBalance` may not necessarily be the amount of tokens the `destinationAddress` received if it is a deflationary token. This is because it is only called via the function `AbstractTokenConverter._privateConversion()` which calculates the `convertedTokenInBalance` by incrementing by the `actualAmountOut`, which is the amount of tokens that are sent from the converter, not the amount that has been received by the destination address.
The `initialize()` functions do not consistently have a NatSpec comment such as `/// @notice ConverterNetwork initializer`. ### AbstractTokenConverter - The comments for `_updateAssetsState()` do not include the return value. - The function `_doTransferIn()` is missing NatSpec comments. - The comments for `_getAmountOut()` do not include the return value `tokenInToOutConversion`. - The comments for `_getDestinationBaseAsset()` do not include the return value. ### RiskFundConverter - The comments for `getPoolAssetReserve()` do not include the error. - The comments for `updatePoolAssetsReserve()` do not include the return value. - The comments for `_updateAssetsState()` do not include the return value, do not include the error, and states it emits `AssetsReservesUpdated` in certain cases, which it does not. - The function `_postPrivateConversion()` does not have any NatSpec comments. - The comments for `_getDestinationBaseAsset()` do not include the return value. ### SingleTokenConverter - The comments for `_updateAssetsState()` do not include the return value. - The comments for `_getDestinationBaseAsset()` do not include the return value. ### ConverterNetwork - The comments for `initialize()` do not include the parameter `_loopsLimit`. - The comments for the functions `findTokenConverters()` and `findTokenConvertersForConverters()` do not indicate any difference between the functions. - The comments for `_findTokenConverters()` do not include the parameter `forConverters` and does not indicate it returns two separate arrays. - the comments for `_findConverterIndex()` do not include the return value.
In function `setConversionConfig()` of `AbstractTokenConverter`, the input `conversionConfig.incentive` can be nonzero even when when the `conversionConfig.conversionAccess` is set to `ONLY_FOR_CONVERTERS` or `NONE`. While the incentive value will not be used in that case, it should be made zero to ensure intended updates are made. - When set to `NONE`, the mapping `conversionConfigurations` corresponding entry can be deleted, instead of updating the value. - If being set to `ONLY_FOR_CONVERTERS`, then incentive should be required to be 0.
The `_loopsLimit` and any update to it should be ensured to be less than `2**128 - 1`. This is because `2**128 - 1` is the upper limit on the return value for `_findConverterIndex()`, and a return of this max value indicates that a tokenConverter does not exist in the array `allConverters`. Since the `_loopsLimit` is a `uint256` value, it may be set larger than this maximum value. This also ensures the casting of `allConverters.length` to a `uint128` value is safe.
Any configurations that are currently enabled will have their bool translate into an enum representation. That is, `enabled = false` will now translate to `conversionAccess` of `NONE`, and `enabled = true` should translate to `conversionAccess` of `ALL`. Since the `converterNetwork` will correspond to `address(0)` until updated, this should mean that all previously enabled configurations continue to function as they did previously at the time of upgrade.
### AbstractTokenConverter - In the comments at the start of the contract it has a comment for `findTokenConverter()`. However, the contract `ConverterNetwork` has two functions `findTokenConverters()` and `findTokenConvertersForConverters()`. - In the comments above error `InsufficientPoolLiquidity` and within functions `getAmountOut()`, `_doTransferOut()`, the word "liquidity" is misspelled as "liquity." ### ConverterNetwork - The comments for the function `isTokenConverter()` state "This function checks for given address is converter or not" when it should be "This function checks if the given address is a converter or not".
In function `removeTokenConverter()`, if a `_tokenConverter` was added successfully through `addTokenConverter()`, then the corresponding address was necessarily nonzero.
The report names a repository or files. Open the report to see its scope.
Repository and files the report names (7)
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