[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 ensureVaultAndGetTxInVoter function
  • 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:

  1. Vault type (should be Asgard)
  2. 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:

  1. Retrieve vault early and check it's an Asgard vault (reject non-Asgard)
  2. Check vault status for NEW observations (no existing voter) - reject inactive vaults immediately
  3. 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 test to verify no regressions
  • Run make lint to verify code quality

🤖 Generated with Claude Code

Merge request reports

Loading
Loading