Skip to content

fix: always validate non_witness_utxo in add_foreign_utxo#461

Open
tnull wants to merge 1 commit intobitcoindevkit:masterfrom
tnull:2026-04-fix-foreign-utxo-validation
Open

fix: always validate non_witness_utxo in add_foreign_utxo#461
tnull wants to merge 1 commit intobitcoindevkit:masterfrom
tnull:2026-04-fix-foreign-utxo-validation

Conversation

@tnull
Copy link
Copy Markdown
Contributor

@tnull tnull commented Apr 24, 2026

Description

Previously, non_witness_utxo was only validated when witness_utxo was None. An attacker could supply both a valid witness_utxo and a non_witness_utxo with the wrong txid, bypassing the txid/outpoint checks entirely.

Restructure the validation so non_witness_utxo is always checked when present, regardless of whether witness_utxo is also set. Only require at least one of the two to exist.

Checklists

All Submissions:

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

Previously, non_witness_utxo was only validated when witness_utxo was
None. An attacker could supply both a valid witness_utxo and a
non_witness_utxo with the wrong txid, bypassing the txid/outpoint
checks entirely.

Restructure the validation so non_witness_utxo is always checked when
present, regardless of whether witness_utxo is also set. Only require
at least one of the two to exist.

Co-Authored-By: HAL 9000
Signed-off-by: Elias Rohrer <dev@tnull.de>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.21%. Comparing base (fb7681a) to head (f0302e9).
⚠️ Report is 16 commits behind head on master.

Files with missing lines Patch % Lines
src/wallet/tx_builder.rs 81.81% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #461      +/-   ##
==========================================
+ Coverage   80.04%   80.21%   +0.17%     
==========================================
  Files          24       24              
  Lines        5336     5347      +11     
  Branches      242      243       +1     
==========================================
+ Hits         4271     4289      +18     
+ Misses        987      980       -7     
  Partials       78       78              
Flag Coverage Δ
rust 80.21% <81.81%> (+0.17%) ⬆️

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 f0302e9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants