AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
High 76 Bitcoin

Merge bitcoin-core/secp256k1#1983: silentpayments: return 0 instead of `ARG_CHECK`ing for empty inputs/outputs

Public commit record

What the developer wrote

Authored by merge-script

86/100 · Strong
Merge bitcoin-core/secp256k1#1983: silentpayments: return 0 instead of `ARG_CHECK`ing for empty inputs/outputs

160590d1922914ddabe7c4d39fe14846b009212e changelog: mention silentpayments returning 0 for empty inputs/outputs (Sebastian Falbesoner)
e7bb01121ffbd2bd8ea66c1e09d2dbd287aabdf6 silentpayments: allow NULL arrays in scan_outputs if n_tx_outputs is 0 (Sebastian Falbesoner)
d7821f4adbe7d13925bf670a720618a52a890d6e silentpayments: return 0 instead of `ARG_CHECK`ing for empty inputs/outputs (Sebastian Falbesoner)

Pull request description:

`secp256k1_silentpayments_recipient_prevouts_summary_create` and `secp256k1_silentpayments_recipient_scan_outputs` treated a transaction with no eligible inputs, or no taproot outputs, as an illegal argument. With the default illegal callback, that calls abort().

That contradicts the API documentation. Both functions are documented to return 0 if the transaction is not a Silent Payments transaction, and a transaction with no eligible inputs or no taproot outputs is exactly that case. It also puts the burden on callers. Anyone scanning a block or building an index has to filter these transactions out before calling the library. If they forget, a transaction someone else created can crash their process.

This PR makes both functions return 0 in these cases:

- `prevouts_summary_create`: drops the `ARG_CHECK((n_pubkeys > 0) || (n_xonly_pubkeys > 0))`. With no public keys, the sum is the point at infinity, so the existing "sum is infinity" check already returns 0. No new code path is needed.
- `scan_outputs`: drops the `ARG_CHECK(n_tx_outputs > 0)`. It returns 0 after all other arguments have been validated and before the scan key is loaded. `*n_found_outputs` is still set to 0.
- `scan_outputs`: tx_outputs and found_outputs are now only checked for NULL if `n_tx_outputs > 0`, and their `SECP256K1_ARG_NONNULL` attributes are removed. This lets callers pass an empty array as NULL (e.g., data() of an empty std::vector). It matches how prevouts_summary_create and sender_create_outputs already treat empty key arrays (see the [previous "Fixed" entry in the CHANGELOG](https://github.com/bitcoin-core/secp256k1/blob/b88cbc7a65ab7629e13368c6c46468fc96d0d3da/CHANGELOG.md?plain=1#L11) added in PR #1932).

ACKs for top commit:
fametrano:
ACK 160590d1922914ddabe7c4d39fe14846b009212e
real-or-random:
utACK 160590d1922914ddabe7c4d39fe14846b009212e

Tree-SHA512: 5ae2f7515356ad4eb0d7499a3705f1e03dac8532e26601603d415d0ba4bc01410cdef4e123b5deecdd0b2f0b395d623c934fc1ce16a7f9d364f6108393be36dc
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This update fixes a crash risk in Bitcoin's silent payments scanning code. Before the change, if a transaction had no suitable inputs or no taproot outputs, the library treated that as an illegal argument and could call abort(), killing the program. Now it calmly returns 0, matching its own documentation. This matters because a stranger could craft a transaction that crashes a wallet or indexing service that forgot to filter these cases first.

Recommended action

Upgrade to a release containing this commit. If running a service that scans blocks or builds silent-payments indexes, ensure the library is updated so that transactions with no eligible inputs or no taproot outputs no longer crash the process. No application-level workaround is needed after patching.

Security signals we found

01

Denial-of-service vector: maliciously crafted transaction could trigger abort() in a scanning/indexing process

02

API contract violation: documented return-0 behavior was not implemented for empty inputs/outputs

03

ARG_CHECK removal in two public silentpayments functions

04

NULL pointer attributes relaxed for empty arrays

05

Test expectations changed from CHECK_ILLEGAL to CHECK(ret == 0)

Risk score

Why this scored 76/100

Our methodology →
Potential impact 22/30
Exploitability 18/25
Stealth signal 12/15
Affected reach 10/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.