Skip to content

wallet: SignTransaction releases its active-signing guard before freeing decrypted providers #287

Closed

Description

@kiwidream

Existing issue search

  • I have searched the existing issues.

Summary

In CWallet::SignTransaction, the decrypted signing providers outlive the guard that Lock() waits for. The guard is released first, so Lock() can return while copies of decrypted keys are still being freed. CWallet::FillPSBT declares the same guard in the safe order.

Current behaviour

  • In wallet.cpp#L2576-L2584, providers is declared before the active_signing_snapshot guard.
  • Locals are destroyed in reverse order, so RemoveActiveSigningProviderSnapshot() runs before the providers are destroyed. The providers hold every decrypted ECDSA and PQC key of the descriptor.
  • Lock() (#L4662-L4681) can therefore clear the master key and return while those secure buffers still exist, for as long as their destruction takes. With large keypools that is milliseconds.
  • FillPSBT (#L2806-L2826) declares the guard before the providers.

I found this by reading the code; I did not reproduce it.

Expected behaviour

Every decrypted key copy owned by a signing operation should be destroyed before its guard is released.

Suggested fix

Declare the guard before providers, or call providers.clear() before the function returns.

Version

1.x.x at e374ba24cf; v1.0.0 has the same structure.

Activity

  1. added
    bug
    on Nov 3, 2026
  2. added a commit that references this issue on Nov 5, 2026
    dd86425
  3. kiwidream commented on Nov 5, 2026

    @kiwidream
    MemberAuthor

    Fixed on 1.x.x by #299 (merged as dd86425), which declares SignTransaction's active-signing guard before the decrypted providers, so Lock() returns only after the decrypted key copies are freed. main gets the fix when 1.x.x is integrated.

  4. added a commit that references this issue on Nov 12, 2026
    b178391
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions