Omniscia Moby Audit

OptionsMarket Static Analysis Findings

OptionsMarket Static Analysis Findings

OMT-01S: Inexistent Initialization Protection of Base Implementation

Description:

The contract is meant to be upgradeable yet does not properly protect its logic deployment from malicious initializations.

Example:

contracts/OptionsMarket.sol
12contract OptionsMarket is IOptionsMarket, OwnableUpgradeable, AuthorityUtil {
13 uint256 public registeredOptionsCount;
14 uint256 public activeOptionsCount;
15
16 uint256 public totalNotionalVolume;
17
18 address public override mainStableAsset;
19
20 uint16 public nextUnderlyingAssetIndex; // starts from 1
21
22 // Once registered, underlying asset cannot be removed (only can be disabled)
23 // index <> underlyingAsset <> optionsToken strongly connected (not able to update)
24 mapping (uint16 => address) public override indexToUnderlyingAsset; // index => underlyingAsset
25 mapping (address => uint16) public override underlyingAssetToIndex; // underlyingAsset => index
26 mapping (address => address) public override underlyingAssetToOptionsToken; // underlyingAsset => optionsToken
27 mapping (address => address) public override optionsTokenToUnderlyingAsset; // optionsToken => underlyingAsset
28 mapping (address => bool) public override isUnderlyingAssetActive; // check if underlying asset is active
29
30 mapping (bytes32 => Option) public options;
31
32 mapping (uint16 => uint256) public amountForUnderlyingAsset; // underlyingAssetIndex => totalAmount
33 mapping (uint16 => uint256) public notionalVolumeForUnderlyingAsset; // underlyingAssetIndex => totalNotionalVolume
34
35 event SetMainStableAsset(address indexed mainStableAsset);
36 event AddUnderlyingAsset(uint16 indexed underlyingAssetIndex, address indexed underlyingAsset, address optionsToken);
37 event UpdateOptionsToken(address indexed underlyingAsset, address optionsToken);
38 event SetIsUnderlyingAsset(address indexed underlyingAsset, bool isUnderlyingAssetActive);
39
40 event OptionStatusChanged(bytes32 indexed id, address indexed underlyingAsset, uint40 indexed expiry, uint48 strikePrice, bool isActive);
41 event IncreaseAmountAndNotionalVolume(bytes32 indexed id, address indexed underlyingAsset, uint40 indexed expiry, uint48 strikePrice, uint256 amount, uint256 notionalVolume);
42
43 function initialize(IOptionsAuthority _authority) public initializer {

Recommendation:

We advise a constructor to be introduced that either invokes the initializer modifier of the Initializable contract or invokes the Initializable::_disableInitializers function to prevent the base implementation from ever being initialized.

Alleviation (a95db4124c4689f421fc3fd505ffb91173355034):

The Moby team evaluated this exhibit, and opted not to apply the alleviation described.

After discussions with the Moby team, we consider this and its relevant sister exhibits as acknowledged based on the fact that the Moby team will manually invoke the initializer of each implementation contract when needed.