The list of assets will be incorrect after reweight()
Proof of Concept
Base on the doc, _updatedAssets[] is the list of asset for the index after reweight. But the implementation just iterates throw all of the _updatedAsset and checks if that weight of asset > 0, it will add it to the asset list. (if weight < 0 it will add that asset to inactiveAsset list). So what if there are some assets that don't appear in _updatedAssets, they won't be removed from assets?
Lines of code
https://github.com/code-423n4/2022-04-phuture/blob/594459d0865fb6603ba388b53f3f01648f5bb6fb/contracts/ManagedIndexReweightingLogic.sol#L28 https://github.com/code-423n4/2022-04-phuture/blob/594459d0865fb6603ba388b53f3f01648f5bb6fb/contracts/ManagedIndexReweightingLogic.sol#L50 https://github.com/code-423n4/2022-04-phuture/blob/594459d0865fb6603ba388b53f3f01648f5bb6fb/contracts/ManagedIndexReweightingLogic.sol#L32 https://github.com/code-423n4/2022-04-phuture/blob/594459d0865fb6603ba388b53f3f01648f5bb6fb/contracts/interfaces/IManagedIndexReweightingLogic.sol#L11
Vulnerability details
Impact
The list of assets will be incorrect after reweight()
Proof of Concept
Base on the doc,
_updatedAssets[]
is the list of asset for the index after reweight. But the implementation just iterates throw all of the_updatedAsset
and checks if that weight of asset > 0, it will add it to the asset list. (if weight < 0 it will add that asset to inactiveAsset list). So what if there are some assets that don't appear in_updatedAssets
, they won't be removed from assets?Tools Used
manual review
Recommended Mitigation Steps
Remove all assets before adding new asset