Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

AuditorPraise - LMPVaultRegistry.removeVault doesn’t remove vault from _vaultsByType mapping #68

Closed
sherlock-admin opened this issue Aug 29, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Aug 29, 2023

AuditorPraise

medium

LMPVaultRegistry.removeVault doesn’t remove vault from _vaultsByType mapping

Summary

LMPVaultRegistry.removeVault doesn’t remove vault from _vaultsByType mapping

Vulnerability Detail

when vaults are added via LMPVaultRegistry.addVault(), the vaults are added to 3 mappings

  1. _vaults mapping, see here
  2. _vaultsByAsset mapping, see here
  3. _vaultsByType mapping, see here

But when the vaults are being removed via LMPVaultRegistry.removeVault(), LMPVaultRegistry.removeVault() fails to remove the vault from _vaultsByType mapping.

  • it removes the vault from _vaults mapping here and _vaultsByAsset mapping here

But it fails to remove the vault from _vaultsByType mapping.

Therefore a removed vault will still exist in _vaultsByType mapping

Impact

  • A removed vault will still exist in _vaultsByType mapping
  • And if there be any need to re-add the vault via LMPVaultRegistry.addVault() there will be a revert because of this line
  • function listVaultsForType() will still list the removed vault as one of the available vaults for a particular type, see here

Code Snippet

https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/vault/LMPVaultRegistry.sol#L64

Tool used

LOFI Radio and Manual Review

Recommendation

remove the vault from _vaultsByType mapping too in the LMPVaultRegistry.removeVault() function

Duplicate of #674

@github-actions github-actions bot added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Sep 11, 2023
@sherlock-admin2 sherlock-admin2 changed the title Cheerful Ruby Cod - LMPVaultRegistry.removeVault doesn’t remove vault from _vaultsByType mapping AuditorPraise - LMPVaultRegistry.removeVault doesn’t remove vault from _vaultsByType mapping Oct 3, 2023
@sherlock-admin2 sherlock-admin2 added the Reward A payout will be made for this issue label Oct 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

2 participants