Skip to content

fix(audit): add non-witness-utxo validation for psbt#471

Open
muhahahmad68 wants to merge 2 commits intobitcoindevkit:masterfrom
muhahahmad68:fix/validating-non-witness-utxo
Open

fix(audit): add non-witness-utxo validation for psbt#471
muhahahmad68 wants to merge 2 commits intobitcoindevkit:masterfrom
muhahahmad68:fix/validating-non-witness-utxo

Conversation

@muhahahmad68
Copy link
Copy Markdown

Description

This PR fixes a security vulnerability in get_utxo_for() within src/psbt/mod.rs where non_witness_utxo was being used without verifying that its txid matches the input's previous_output.txid.

Notes to the reviewers

  • The validation silently returns None on txid mismatch rather than propagating an error, which is consistent with the existing behavior of this function.

Changelog notice

Fixed

Checklists

All Submissions:

New Features:

  • N/A

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@ValuedMammal ValuedMammal moved this to Needs Review in BDK Wallet Apr 29, 2026
@ValuedMammal ValuedMammal added the bug Something isn't working label Apr 29, 2026
@ValuedMammal ValuedMammal added this to the Wallet 3.1.0 milestone Apr 29, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.20%. Comparing base (db1eab4) to head (6b2f8ff).

Files with missing lines Patch % Lines
src/psbt/mod.rs 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #471      +/-   ##
==========================================
- Coverage   80.21%   80.20%   -0.02%     
==========================================
  Files          24       24              
  Lines        5348     5354       +6     
  Branches      242      243       +1     
==========================================
+ Hits         4290     4294       +4     
- Misses        980      981       +1     
- Partials       78       79       +1     
Flag Coverage Δ
rust 80.20% <75.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@ValuedMammal ValuedMammal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 6b2f8ff

It'd be nice to see a test to check

  1. get_utxo_for returns None on txid mismatch
  2. get_utxo_for returns None on previous_output.vout out of bounds

commit should say

fix(psbt): add non-witness-utxo validation for get_utxo_for

Comment thread src/psbt/mod.rs Outdated
@ValuedMammal
Copy link
Copy Markdown
Collaborator

We need to drop the duplicate 081c3be commit from this branch that already exists on master with a different ID.

@muhahahmad68 muhahahmad68 force-pushed the fix/validating-non-witness-utxo branch from f0fe014 to 4add4ca Compare May 1, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

[psbt] Validate non_witness_utxo txid with tx input previous output

2 participants