Part of CertiK’s series
CertiK reviewed Venus Protocol (Venus - Prime) on 13 Nov 2023: 43 findings, 0 critical; 35 marked fixed, 8 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 | 2 |
| Medium | 0 | 0 | 2 |
| Low | 6 | 0 | 31 |
Only privileged functions introduced or affected by this PR: [https://github.com/VenusProtocol/venus-protocol/pull/196](https://github.com/VenusProtocol/venus-protocol/pull/196) are in the scope of this audit. All other privileged functions not cited in this finding were not considered and we recommend users carefully review them. ## PrimeLiquidityProvider In the contract `PrimeLiquidityProvider`, the role `_owner` has authority over the following functions: - `initializeTokens()` - `setPrimeToken()` - `sweepToken()` Any compromise to the `_owner` account may allow a hacker to take advantage of this authority and do the following: - Initialize tokens that were not planned to be initialized. - Set the `prime` variable as an account they control, so all funds in the contract can be sent to them. - Directly remove all funds from the contract immediately via the function `sweepToken()`. --- In the contract `PrimeLiquidityProvider`, the role `DEFAULT_ADMIN_ROLE` of the `AccessControlManager` can grant addresses the privilege to call the following functions: - `pauseFundsTransfer()` - `resumeFundsTransfer()` - `setTokensDistributionSpeed()` Any compromise to the `DEFAULT_ADMIN_ROLE` or accounts granted this privilege may allow a hacker to take advantage of this authority and do the following: - Prevent or enable the flow of funds into the `prime` contract. - Change the distribution speed so that the flow of funds to the `prime` contract is faster or slower than intended. --- ## Prime In the contract `Prime`, the role `DEFAULT_ADMIN_ROLE` of the `AccessControlManager` can grant addresses the privilege to call the following functions: - `updateAlpha()` - `updateMultipliers()` - `addMarket()` - `setLimit()` - `issue()` - `burn()` - `togglePause()` - `setStakedAt()` Any compromise to the `DEFAULT_ADMIN_ROLE` or accounts granted this privilege may allow a hacker to take advantage of this authority and do the following: - Update alpha or the borrow/supply multipliers to unintended values. - Add an unintended market. - Set the limit for revocable and irrevocable tokens so that users can no longer mint new prime tokens. Conversely, they could update the limit to allow more tokens to be minted. - Issue revocable or irrevocable tokens to themselves. - Burn any user's revocable or irrevocable tokens. - Pause or unpause the reward claiming function `claimInterest()`. - Update the staked at timestamp for any user. --- ## SetterFacet In the contract `SetterFacet`, the role `admin` has authority over the following functions: - `_setPrimeToken()` Any compromise to the `admin` account may allow a hacker to take advantage of this authority and do the following: - change the `prime` address to a contract with malicious logic, interacting with the `VToken` market contract or `Comptroller` unpredictably --- ## XVSVault In the contract `XVSVault`, the `admin` role has access to call the following functions: - `setPrimeToken()` Any compromise to the `admin` role may allow a hacker to take advantage of this authority and change the `primeToken` address to a contract with malicious logic.
The contracts `Prime`, `PrimeLiquidityProvider`, `XVSVault` and the Diamond Comptroller are upgradeable. The privileged roles of the proxy have the authority to update the implementation contracts. Any compromise of the privileged account could allow a hacker to exploit this authority, potentially altering the implementation contract pointed to by the proxy and thus executing malicious functionality within the implementation contract. This includes the ability to take all funds held by the contract.
The function `calculateAPR()` does not update the oracle for the input `market` or `xvsToken`. Thus the oracle will not update the pivot oracle price before calculating a users capital for their score.
The `FixedMath0x` library does not provide clear documentation to completely verify their logic. For example the comment: "`x` is now our residual in the range of 1 <= x <= 2 (or close enough)." does not give clear bounds on `x`. If `x` exceeds 2, then this can lead to potential issues as the Taylor series only converges and thus gives a valid approximation for $0<x \leq 2$. In addition, the hexadecimal values chosen are not always the closest value to those in the comments. For example: ```solidity // e ^ -32 if (x <= int256(0x00000000000000000000000000000000000000000001c8464f76164760000000)) { r -= int256(0x0000000000000000000000000000001000000000000000000000000000000000); // - 32 x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000000000001c8464f76164760000000); // / e ^ -32 } ``` Here the comment gives that the hexadecimal `0x00000000000000000000000000000000000000000001c8464f76164760000000` should represent `e^(-32)`. However this represented as a fixed point number should be `e^(-32) * 2^(127) = 2154696114062186216855968.0713581760...` Which rounds down to `2154696114062186216855968`, represented by the hexadecimal `0x00000000000000000000000000000000000000000001C8464F76164681E299A0`. Furthermore, there is a minimum value set that will behave as the default for small enough inputs. This is the value `-63.875`, but the true minimum that can be reached is approximately -88. Thus users can borrow/supply the minimum amount required to ensure that their ratio is exactly 1 (that is 1/2^127). This would mean that the natural log should return -88, but it returns the default -63.875 instead, allowing the user to slightly game the system. Currently, the formulas are rewritten using base $e$, however, we would like to note that they can be written in base 2. The use of base $e$ is optimal for the current library as a Taylor series is used to approximate the value, however, if other approximation methods are used base 2 may be the better choice.
### PrimeLiquidityProvider.sol - Function `sweepToken()` is missing a check that the `token_` input is not an initialized token for the contract. This allows the removal of tokens that may be reserved for the `Prime` contract. - Function `accrueTokens()` is missing a check that the `token_` input is an initialized token. In the contract, initializing tokens is represented as privileged action. However, a user can initialize any token by using its address in the `accrueTokens()` function. This presents a lack of control over when a given token is initialized in the contract. - Function `setTokenDistributionSpeed()` can be called for token addresses that have not yet been initialized. If a speed is set on an uninitialized token, then anyone can call function `releaseFunds()` for that token and in the call to `accrueTokens()`, the `deltaBlocks` value will be the difference in the current `blockNumber` and 0. If a token balance has been sent to the contract in anticipation of accruing the tokens based on the set speed from its initialized block, then the miscalculated `deltaBlocks` could cause the entire balance to be released to the `prime` contract immediately. Additionally, if the `prime` address is not set before setting distribution speeds, then it may be possible to transfer tokens to the `address(0)` through function `releaseFunds()`, if the initialized token allows transfers to `address(0)`. ### Prime.sol - The specification states alpha must be between 0 and 1 and in the contract `Scores`, it asserts that `alphaNumerator <= alphaDenominator`. The assert statement can be removed from `Scores` and instead the inputs can be checked when they are assigned to ensure they meet the specification. This should be done in the functions `initialize()` and `updateAlpha()`. - The `initialize()` and `updateAlpha()` functions are missing a check that `alphaDenominator` is set to a nonzero value. - The function `addMarket()` does not verify that the added `vToken` is a supported market of Venus. - Function `setStakedAt()` is missing a check that each `timestamps[i]` value is no larger than the current `block.timestamp`. If, for any reason, the privileged role attempts to set a user's `stakedAt` value to a timestamp that is larger than the current `block.timestamp`, a user that does not yet have a prime token can override this change by making the proper update to their staked xvs, triggering a call to `xvsUpdated()`, setting their `stakedAt` value to the current timestamp. A user who already has a prime token is not affected by the change to `stakedAt`.
According to the logic of function `accrueInterest()`, it is possible that some rewards will not be collected by any user. If rewards are currently being issued, but no user has a positive score, then no user can collect these rewards. Even so, all currently unreleased funds issued can be sent from both `PrimeLiquidityProvider` and `ProtocolShareReserve` to the `Prime` contract by anyone. Since no user is privy to these funds, they will become stuck in the contract. This is the case even if the `Prime` contract calls `releaseFunds()`, since all currently available funds will be released when the function is called.
Only a single comptroller is used to determine if a market exists, so the `Prime` contract cannot handle both the core pools and isolated pools in the prime program. While all pools may have a portion of their revenue captured for prime rewards, the only way to become privy to these rewards through the prime program would be to participate in the core pool. Considering the new design intent that all markets, including the isolated pools markets, will contribute to the prime rewards we would like to ensure that the prime programs design intent is to only allow core markets to be added to the prime program.
Often storage variables are read multiple times, when they can be stored as a temporary variable to reduce the amount of times it is read from storage.
The report names a repository or files. Open the report to see its scope.
Repository and files the report names (12)
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