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

Merge bitcoin/bitcoin#36291: test: add script_tests cases covering interpreter mutants

Public commit record

What the developer wrote

Authored by merge-script

100/100 · Strong
Merge bitcoin/bitcoin#36291: test: add script_tests cases covering interpreter mutants

efe0dfcf1e5c431c62dc9ac4fd2c2d97a62814fe test: cover DERSIG 9-byte signature lower bound (ViniciusCestarii)
bbc4bdf9092efb218202dceefbacda57d5513e1d test: cover DERSIG null S byte only when S is multi-byte (ViniciusCestarii)
fd2cf0450276e9f503570eda5639966ce81065e5 test: cover DERSIG null R byte only when R is multi-byte (ViniciusCestarii)
a1deba78c5f668eaab359b8e54ac93df02f4ce37 test: cover DERSIG total-length byte check (ViniciusCestarii)
3d04ed8ac77bf930d7b1d6dd11701417ff53a0d6 test: cover DERSIG 73-byte signature upper bound (ViniciusCestarii)
2c0f69a0478947de26d544c1b9b42a7d1eebd42f test: cover STRICTENC rejects bad 33-byte pubkey prefix (ViniciusCestarii)

Pull request description:

Kills some live mutants on `interpreter.cpp` found by https://bitcoincore.space. They are:

[interpreter.cpp#5168](https://bitcoincore.space/src/script/interpreter.cpp#5168): `IsCompressedOrUncompressedPubKey`: pubkey with neither compressed nor uncompressed prefix returns `true`

```diff
- } else if (vchPubKey[0] == 0x02 || vchPubKey[0] == 0x03) {
+ } else if (1==1) {
```

[interpreter.cpp#5191](https://bitcoincore.space/src/script/interpreter.cpp#5191): `IsValidSignatureEncoding`: 73-byte upper bound returns `true`

```diff
if (sig.size() < 9) return false;
- if (sig.size() > 73) return false;
```

[interpreter.cpp#5200](https://bitcoincore.space/src/script/interpreter.cpp#5200): `IsValidSignatureEncoding`: total-length byte check returns `true`

```diff
// Make sure the length covers the entire signature.
- if (sig[1] != sig.size() - 3) return false;
```

[interpreter.cpp#5232](https://bitcoincore.space/src/script/interpreter.cpp#5232): `IsValidSignatureEncoding`: null R byte check `lenR > 1` -> `lenR >=1`

```diff
// Null bytes at the start of R are not allowed, unless R would
// otherwise be interpreted as a negative number.
- if (lenR > 1 && (sig[4] == 0x00) && !(sig[5] & 0x80)) return false;
+ if (lenR >= 1 && (sig[4] == 0x00) && !(sig[5] & 0x80)) return false;
```

[interpreter.cpp#5259](https://bitcoincore.space/src/script/interpreter.cpp#5259): `IsValidSignatureEncoding`: null S byte check `lenS > 1` -> `lenS >= 1`

```diff
// Null bytes at the start of S are not allowed, unless S would otherwise be
// interpreted as a negative number.
- if (lenS > 1 && (sig[lenR + 6] == 0x00) && !(sig[lenR + 7] & 0x80)) return false;
+ if (lenS >= 1 && (sig[lenR + 6] == 0x00) && !(sig[lenR + 7] & 0x80)) return false;
```

[interpreter.cpp#5186](https://bitcoincore.space/src/script/interpreter.cpp#5186): `IsValidSignatureEncoding`: 9-byte lower bound returns `true`

```diff
// Minimum and maximum size constraints.
- if (sig.size() < 9) return false;
```

The first affects policy only, the next four affect consensus, and the last covers the lower bound and lets ASan catch UB: a 3-byte signature reaches the `sig[3]` read that the `sig.size() < 9` guard protects.

Recommend reviewing per commit.

ACKs for top commit:
fametrano:
ACK efe0dfcf1e5c431c62dc9ac4fd2c2d97a62814fe
brunoerg:
reACK efe0dfcf1e5c431c62dc9ac4fd2c2d97a62814fe
sedited:
ACK efe0dfcf1e5c431c62dc9ac4fd2c2d97a62814fe

Tree-SHA512: 6ce18dd013b65275fa5fd6d6c7752a8fcc0283648dc0a56411c37f3afa6da4125d7f849174f78475500800495d47131c1d91b42ee2967ad2c87cc967fb2a097a
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit only adds new test cases to Bitcoin Core's script test data file. It does not change any production code, so it cannot introduce a security vulnerability on its own. The tests are designed to detect certain incorrect code changes ('mutants') in the script interpreter's signature and public-key validation logic, but the actual interpreter code remains unchanged.

Recommended action

No security action required. This is a test-only change. Reviewers may optionally verify the new test vectors correctly exercise the intended interpreter branches.

Security signals we found

No strong security signals were identified.

Risk score

Why this scored 15/100

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