Part of CertiK’s series
CertiK reviewed Venus Protocol (Venus - XVS Token Bridge) on 26 Dec 2023: 21 findings, 0 critical; 20 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 | 0 |
| High | 1 | 0 | 0 |
| Medium | 0 | 0 | 1 |
| Low | 0 | 0 | 19 |
Function `_increaseMintLimit()` is used within the `burn()` function of the in-scope `XVS` token contract as a way to document the increase in available funds to mint after burning. The function logic assumes that the `minterToCap` mapping for the source address `from` will be larger than the calculated `totalMintedNew` value after subtracting away the new `amount_` that is burned. If in between minting and burning, the `minterToCap` corresponding value is decreased for the minter address, then it is possible that `minterToCap` is less than the calculated `totalMintedNew` value at the time of burning. In that case, the logic of `_increaseMintLimit()` will cause a revert in the `burn()` logic, preventing burning from functioning properly.
In general, the counter in a for loop can be incremented or decremented in an unchecked block as it cannot overflow or underflow, saving gas as it will not perform a check for overflow or underflow. Additionally, it saves a small amount of gas to increment an index in a `for` loop from the left instead of from the right side as it performs fewer operations.
- An account given a nonzero `minterToCap` value is assumed to be given access to functions `mint()` and `burn()`. - An account given access to functions `mint()` or `burn()` is assumed to be given a nonzero `minterToCap` value. - An account given access to the `burn()` function is assumed to be given access to mint, and vice versa. While these privileges are dependent on one another, each part of the privilege is given independently, increasing the chance for inconsistent update.
If `active_[i] && signature.length != 0` or `!active_[i] && signature.length == 0` then none of the if-blocks will be executed. If either of these combinations are input by accident, then it can cause confusion as there is nothing to indicate this other than a lack of event emitted.
An external call to transfer the `innerToken` is made first, and then the `outboundAmount` is updated and checked. While it is assumed that the `innerToken` is the team's `XVS` token, following the check-effect-interaction pattern can reduce any unforeseen risk.
In `BaseXVSProxyOFT.sol`, the check that the `oracle_` address input on deployment is nonzero is made after setting state variables `ld2sdRate` and `innerToken`. The check with `ensureNonzeroAddress` can be made at the beginning of the constructor with the other zero address checks.
The function `renounceOwnership()` is overriden to have an empty implementation to prevent ownership from accidentally being revoked. We recommend considering having the function revert with a descriptive error message indicating this function has been disabled for the contract. This will help avoid any potential confusion in the future if someone was to call this function.
In the `XVS` contract, a blacklisted account cannot be minted tokens. However, on the chain in which the account is blacklisted, anyone can still transfer tokens to the blacklisted account, transfer tokens from the blacklisted account, the account can be approved to move others' tokens, and the account can have their tokens burned. As a consequence, the blacklisted account can easily acquire tokens, and they can still bridge these tokens to another chain where they may not be blacklisted. Moreover, in `XVSProxyOFTSrc`, there is no check from this side of whether the account bridging tokens is blacklisted on other chains, and there is no way to blacklist the user from the source chain. As a result, a user can transfer in their tokens into the `XVSProxyOFTSrc` contract, but if they are blacklisted on the destination chain, there is no equivalent amount given out. In this way, these tokens become stuck within the protocol and cannot be removed without intervention via centralized accounts.
There are currently two bridge contracts `XVSProxyOFTSrc` and `XVSProxyOFTDest`. The main difference being that `XVSProxyOFTSrc` locks tokens if transferring to another chain and gives locked tokens when receiving tokens from another chain, while `XVSProxyOFTDest` burns or mints tokens when transffering to another chain or receiving from another chain respectively. As such we assume that the design is to deploy a single `XVSProxyOFTSrc` on BSC as it holds the current supply of XVS and all other chains should only receive XVS that has been bridged out of BSC. Furthermore we assume that all other chains will have a single `XVSProxyOFTDest` contract deployed to bridge XVS tokens. Last, it is assumed that only one address (the bridge contract) will utilize a nonzero `minterToCap` value per chain, except in extenuating circumstances in which funds become stuck in the protocol based upon the restrictions of the design (such as the bridged amount exceeding the mint cap of the bridge for the chain). Furthermore, it is assumed that any use of this minting capability beyond the bridge associated with the chain will be carefully assessed in order to maintain the invariant that `totalSupply()` of XVS on BSC is equivalent to the `circulatingSupply()` of the BSC bridge contract, plus the amount `outboundAmount`. A similar assumption is made for the `fallbackWithdraw()` function in `XVSProxyOFTSrc`. Please let us know if these assumptions are correct and provide further information if they do not align with the design intent.
It is our understanding that the design of these contracts are for `XVS`, however, they also include functionality to check balances and potentially handle deflationary tokens. We would like to ensure these contracts are only to be used for `XVS` and that no other deflationary or token that implements hooks should be considered.
The function `initialize()` in the contract `XVSBridgeAdmin` checks that the input `accessControlManager_` is not the zero address via `ensureNonzeroAddress`. However, it also calls `__AccessControlled_init()`, which will call `_setAccessControlManager()` that has the following check ```solidity require(address(accessControlManager_) != address(0), "invalid acess control manager address"); ``` Thus it will check that the input `accessControlManager_` is not the `address(0)` twice. --- The function `transferBridgeOwnership()` in the contract `XVSBridgeAdmin` checks that the input `newOwner_` is not the zero address via `ensureNonzeroAddress`. However, it calls `XVSBridge.transferOwnership()`, which calls `transferOwnership()` in OpenZeppelin's `Ownable` contract that also checks the input is not the zero address.
In the function `fallbackDeposit()` it is checked that the new `outboundAmount` after the deposit will not exceed the `_sd2ld(type(uint64).max)`. As some chains like Aptos use `uint64` to represent balances, the maximum balance on their chain would be `type(uint64).max` and thus `_sd2ld(type(uint64).max)` represents this maximum amount using the local decimals. However, this check is not performed in `_debitFrom()`, so that it is possible to exceed this cap using normal chain operations and then preventing `fallbackDeposit()` from being called.
### TokenController.sol - In function `_increaseMintLimit()` there is a missing check that the input `amount_` is no larger than the `minterToMintedAmount` for the input `from_` address. This may cause an ambiguous error message due to underflow in the calculation of `totalMintedNew` in the function. - In function `migrateMinterTokens()`, there is no check that the `source_` and `destination_` addresses are not the same. If they are the same address, the update to mapping `minterToMintedAmount` for that address will not accurately reflect the minted amount (e.g. an address with `mintedToMinted` amount of 100 originally will double to 200 as long as the `destinationCap` is not exceeded). ### XVSProxyOFTSrc.sol - In the function `fallbackWithdraw()` there is no check that `amount_` is no larger than `outboundAmount`. In this case, an ambiguous error message due to underflow will be thrown. - In the function `_creditTo()` there is no check that `amount_` is no larger than `outboundAmount`. In this case, an ambiguous error message due to underflow will be thrown.
### XVSProxyOFTSrc - The comments above `fallbackWithdraw()` do not include the emmited event or the access restriction. - The comments above `dropFailedMessage()` do not include the emmited event or the access restriction. - The comments above `circulatingSupply()` do not include the return value. - There are no comments above the function `_debitFrom()`. - There are no comments above the function `_creditTo()`. ### XVSProxyOFTDest - The comments above `dropFailedMessage()` do not include the emmited event or the access restriction. - The comments above `circulatingSupply()` do not include the return value. - There are no comments above the function `_debitFrom()`. - There are no comments above the function `_creditTo()`. ### XVSBridgeAdmin - The comments above `fallback()` do not include the return value. - The comments above `setTrustedRemoteAddress()` do not include the access restriction or a summary of the functionality. - The comments above `upsertSignature()` do not include the access restriction or emitted events. - The comments above `transferBridgeOwnership()` do not include the potential error. - The comments above `isTrustedRemote()` do not include the return value. - The comments above `_getFunctionName()` do not include the input parameter and return value. - There are no comments above the function `bytesToAddress()`. ### BaseXVSProxyOFT - The comments above the `constructor()` do not include the emitted events. - The comments above `removeTrustedRemote()` do not include the access restriction or emitted event. - The comments above `token()` do not include the return value. - There are no comments above the function `_isEligibleToSend()`. - There are no comments above the function `_isEligibleToReceive()`. - There are no comments above the function `_transferFrom()`. - There are no comments above the function `_nonblockingLzReceive()`. - There are no comments above the function `_ld2sdRate()`. ### TokenController - The comments above the function `_isEligibleToMint()` do not include the emitted event or potential error. - The comments above the function `_increaseMintLimit()` do not include the emitted event. - The comments above the function `_ensureAllowed()` do not include the input parameter or the potential error.
`mint()` and `burn()` can be paused, however users can still transfer tokens when the contract is paused. We would like to ensure that this is the intended behavior.
Function `isBlacklisted()` is a view function for mapping `_blacklist`, however, this mapping is public.
The function `lzReceive()` in [https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/lzApp/LzApp.sol](https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/lzApp/LzApp.sol) makes the check ```solidity require( _srcAddress.length == trustedRemote.length && trustedRemote.length > 0 && keccak256(_srcAddress) == keccak256(trustedRemote), "LzApp: invalid source sending contract" ); ``` If this succeeds then it calls `_blockingLzReceive()`, which is overriden in [https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/lzApp/NonblockingLzApp.sol](https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/lzApp/NonblockingLzApp.sol) to call `nonblockingLzReceive()`, which then calls `_nonblockingLzReceive()`. However, this contract overrides this to then perform the same check again: ```solidity require( _srcAddress.length == trustedRemote.length && trustedRemote.length > 0 && keccak256(_srcAddress) == keccak256(trustedRemote), "LzApp: invalid source sending contract" ); ``` While this will ensure if there are any updates to trusted remotes between when a message fails and is retried, a check can be added when retrying the message to prevent making duplicate checks on successful messages.
In the case where XVS tokens are bridged to the `XVSProxyOFTSrc` contract itself, the `_creditTo()` logic will subtract the `amount_` from the `outboundAmount` while keeping the corresponding `XVS` in the contract, in order to account for the fact that it is no longer bridged to one of the destination chains, and is now technically part of the `circulatingSupply()` on the source chain. However, the only way to remove tokens bridged to the `XVSProxyOFTSrc` contract itself would be to use the `fallbackWithdraw()` function, in which case, the `amount_` would be subtracted from the `outboundAmount` a second time, causing a discrepancy in the accounting of the variable. Consequently, any funds a user accidentally sends directly to the bridge rather than sending to their own account will cause the tokens to be permanently locked in the bridge, or else will cause an issue with `outboundAmount` where eventually someone else's tokens will be permanently locked in the bridge. Additionally, if anyone directly transfers tokens to the bridge, they will not be accounted for in the `outboundAmount`, so they also cannot be removed with `fallbackWithdraw()` without causing an issue with this variable.
### XVSProxyOFTSrc - The comment above the variable `outboundAmount` states "total amount is transferred from this chain to other chains." which should be "Total amount that is transferred from this chain to other chains." - In the comment above the event `DropFailedMessage`, the word "successful" is misspelled as "successfull." ### XVSProxyOFTDest - In the comment above the event `DropFailedMessage`, the word "successful" is misspelled as "successfull." ### XVSBridgeAdmin - The comment above the function `upsertSignature()` does not describe that this is a setter function for the registry. - In the comment above function `transferBridgeOwnership()`, "transfer" should be "transfers". ### BaseXVSProxyOFT - In the comment above the `whitelist` mapping, the word "applicable" is misspelled as "appicable." - In the comment above event `SetWhitelist`, the word "emitted" is misspelled as "emmited" - In the comment above function `setWhitelist()`, the word "address" is misspelled as "Adress" - In the comment above the `constructor()`, "No" should either be "No." or "Number". ### TokenController.sol - In the comment above the `minterToMintedAmount` mapping, the word "minted" is misspelled as "m inted." - In the comment above functions `setMintCap()` and `_increaseMintLimit()` the word "minting" is misspelled as "miniting." ### XVS.sol - In the comment above `mint()` function the description "@param account_ Address to which tokens be assigned" reads correctly as "account_ Address to which tokens are assigned." - In the comment above `mint()`, there is an incorrect description of error `MintNotAllowed`. The error should say it is thrown when minting is not allowed to `to_` address; instead it says the error is thrown when minting is not allowed to the `from_` address. - In the comment above `mint()`, the error description "MintLimitExceed is thrown when minting amount exceed the maximum cap" reads correctly as "MintLimitExceed is thrown when minting amount exceeds the maximum cap"
In the function `_isEligibleToMint()` the logic: ```solidity if (totalMintedNew > mintingCap) { revert MintLimitExceed(); } ``` ensures that `mintingCap >= totalMintedNew`. Thus it is impossible for `mintingCap - totalMintedNew` to underflow so it can be placed in an unchecked block.
The report names a repository or files. Open the report to see its scope.
Repository and files the report names (8)
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