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

validation: detect witness stripping without re-running Script checks

Public commit record

What the developer wrote

Authored by Antoine Poinsot

98/100 · Strong
validation: detect witness stripping without re-running Script checks

Since it was introduced in 4eb515574e1012bc8ea5dafc3042dcdf4c766f26 (#18044), the detection of a
stripped witness relies on running the Script checks 3 times. In the worst case, this consists in
running Script validation 3 times for every single input.

Detection of a stripped witness is necessary because in this case wtxid==txid, and the transaction's
wtxid must not be added to the reject filter or it could allow a malicious peer to interfere with
txid-based orphan resolution as used in 1p1c package relay.

However it is not necessary to run Script validation to detect a stripped witness (much less so
doing it 3 times in a row). There are 3 types of witness program: defined program types (Taproot,
P2WPKH, P2WSH), undefined types, and the Pay-to-anchor carve-out.

For defined program types, Script validation with an empty witness will always fail (by consensus).
For undefined program types, Script validation is always going to fail regardless of the witness (by
standardness). For P2A, an empty witness is never going to lead to a failure.

Therefore it holds that we can always detect a stripped witness without re-running Script validation.
However this might lead to more "false positives" (cases where we return witness stripping for an
otherwise invalid transaction) than the existing implementation. For instance a transaction with one
P2PKH input with an invalid signature and one P2WPKH input with its witness stripped. The existing
implementation would treat it as consensus invalid while the implementation in this commit would
always consider it witness stripped.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit changes how Bitcoin Core detects when a transaction's witness data has been stripped away. Previously, the software ran expensive script checks up to three times to figure out if a transaction failed only because its witness was missing. The new code detects the same condition with a cheaper check, but it may label some transactions as 'witness stripped' even when they are invalid for other reasons. The change is a performance and correctness refactor, not a fix for an active exploit, though the underlying behavior affects how the network handles invalid transactions.

Recommended action

Review the SpendsNonAnchorWitnessProg helper for correctness and ensure the new heuristic does not allow transactions to bypass intended rejection caching. Monitor for any edge cases involving mixed input types. No urgent deployment action is indicated; this is a defensive refactor.

Security signals we found

01

Removes repeated script validation to avoid CPU exhaustion DoS vector in mempool acceptance

02

Changes rejection classification from consensus-invalid to witness-stripped for some multi-input transactions

03

Affects reject filter behavior and 1p1c package relay orphan resolution

04

Introduces a heuristic that may produce false positives compared to prior implementation

Risk score

Why this scored 48/100

Our methodology →
Potential impact 12/30
Exploitability 8/25
Stealth signal 7/15
Affected reach 10/15
Confidence 7/10
Evidence quality 4/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.