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

Merge bitcoin/bitcoin#32143: Fix 11-year-old mis-categorized error code in OP_IF evaluation

Public commit record

What the developer wrote

Authored by Ava Chow

81/100 · Strong
Merge bitcoin/bitcoin#32143: Fix 11-year-old mis-categorized error code in OP_IF evaluation

a7b581423e44c51fb7d177c5a15fe2cc2ab8aa43 Fix 11-year-old mis-categorized error code in OP_IF evaluation (Calin Culianu)

Pull request description:

This was introduced by commit ab9edbd6b6eb3efbca11f16fa467c3c0ef905708.

It appears the original author may have gotten tired and pasted the wrong error code into this 1 place. Every other situation where the value stack lacks the required number of arguments for the op-code, SCRIPT_ERR_INVALID_STACK_OPERATION is reported. Not so here.

This commit fixes the situation.

EDIT: Note this turns out to be a dupe of the abandoned #30359 .

ACKs for top commit:
billymcbip:
tACK a7b581423e44c51fb7d177c5a15fe2cc2ab8aa43
achow101:
ACK a7b581423e44c51fb7d177c5a15fe2cc2ab8aa43
darosior:
utACK a7b581423e44c51fb7d177c5a15fe2cc2ab8aa43
sedited:
ACK a7b581423e44c51fb7d177c5a15fe2cc2ab8aa43

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

What changed, and why it matters

This commit fixes a long-standing mistake in how Bitcoin Core reports an error when an OP_IF command is used without enough values on the script stack. In one specific spot, the wrong error code was returned for 11 years. The fix makes the error code consistent with every other similar case. This is a minor correctness/observability fix, not a vulnerability that lets an attacker steal funds or crash nodes.

Recommended action

Treat as a routine bug fix. No emergency deployment is warranted. Verify the change is included in the next regular release and ensure downstream monitoring/logic that keys on SCRIPT_ERR_UNBALANCED_CONDITIONAL for empty-stack OP_IF cases is updated if needed.

Security signals we found

01

Consensus-critical code touched (script interpreter)

02

Error-code-only change; both old and new codes fail script validation

03

No memory safety, authentication, or network behavior change

04

No test vectors or functional tests modified in the visible diff

05

Vendor did not label as a security fix

Risk score

Why this scored 23/100

Our methodology →
Potential impact 2/30
Exploitability 1/25
Stealth signal 3/15
Affected reach 5/15
Confidence 8/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.