Loading
[P1] Insufficient vault validation - only checks existence, not ownership or status
Resolve #2447
This MR implements the changes described in issue #2447.
Summary
- Add vault type (Asgard) and status validation in
ensureVaultAndGetTxInVoterfunction - Reject NEW transactions to inactive vaults early, before voter creation and balance updates
- Allow existing observations to continue processing (refund handled later in flow)
- Add comprehensive unit tests for all vault validation scenarios
Technical Details
The security finding identified that ensureVaultAndGetTxInVoter only validated vault existence, not:
- Vault type (should be Asgard)
- Vault status (Active/Retiring/Inactive)
This allowed transactions to inactive vaults to proceed through voter creation and vault balance updates (lines 189-193) before being rejected at line 263. The fix adds early validation to:
- Retrieve vault early and check it's an Asgard vault (reject non-Asgard)
- Check vault status for NEW observations (no existing voter) - reject inactive vaults immediately
- Allow existing observations to continue (vault may have become inactive after initial observation)
The distinction between new and existing observations is important:
- New observations: Should be rejected immediately for inactive vaults (security fix)
-
Existing observations: Should continue to process (vault was active when first observed, refund handled in
handleObservedTxInQuorum)
Test Plan
- Unit tests for active Asgard vault (should succeed)
- Unit tests for inactive vault with no prior observations (should reject early)
- Unit tests for inactive vault with existing observations (should allow processing)
- Unit tests for non-Asgard vault (should reject)
- Unit tests for retiring vault (should succeed)
- Unit tests for non-existent vault (should reject)
-
Run
make testto verify no regressions -
Run
make lintto verify code quality