bitcoindevkit / bitcoindevkit/bdk_wallet
Policy satisfaction from PSBT counts signatures without verifying them
- Dominant language
- Rust
- Stars
- 59
- Forks
- 105
- Avg merge
- 10d 9h
- Merged PRs (30d)
- 1
Description
**Describe the bug**
`Descriptor::extract_policy` with `BuildSatisfaction::Psbt` / `PsbtTimelocks` reports a key as satisfied when the PSBT input merely *contains* an entry for it (`partial_sigs.contains_key`, `tap_key_sig.is_some()`, `tap_script_sigs` key match in `src/descriptor/policy.rs`, `generic_sig_in_psbt` and the `signature`/`signature_key` helpers). The signature bytes are never verified, and for xpub keys the derivation path in `bip32_derivation` is trusted without checking that the listed pubkey is actually derived from the xpub (see the `//TODO check signature validity` / `//TODO check actual derivation matches` comments).
As a result, `Policy::satisfaction` can say a path is `Complete`/`Partial` with N signatures when the PSBT only carries garbage or foreign entries under the right keys.
This issue was found by AI.
**To Reproduce**
1. Build a PSBT for a `wsh(multi(2, A, B))` descriptor.
2. Insert an arbitrary (invalid) `ecdsa::Signature` into `inputs[0].partial_sigs` under key `A`.
3. Call `descriptor.extract_policy(&signers, BuildSatisfaction::Psbt(&psbt), &secp)`.
4. `satisfaction` reports `A` as satisfied.
**Expected behavior**
`satisfaction` should either verify the signatures/derivations it counts, or the docs should make clear that it only reflects the presence of entries in the PSBT and must not be taken as proof that the input is finalizable.
**Build environment**
- BDK tag/commit: `6fc68462` (master)
**Which backend(s) are relevant (if any)?**
- [x] None / not backend-related (e.g. `bdk_chain`, `bdk_core`)
**Is this blocking production use?**
- [x] No
Contributor guide
Research direction
Start in src/descriptor/policy.rs, especially Descriptor::extract_policy, generic_sig_in_psbt, and the signature, signature_key, and derivation handling mentioned in the issue. Reproduce the wsh(multi(2, A, B)) case with an invalid partial signature, then determine whether satisfaction verifies signatures and derivations or clearly documents that it only reflects PSBT entry presence.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cryptography, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100