Merge bitcoin/bitcoin#36291: test: add script_tests cases covering interpreter mutants
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.
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.
Evidence from the diff
The commit adds test vectors to src/test/data/script_tests.json to improve coverage of DERSIG and STRICTENC rules in the script interpreter. It includes cases for: 74-byte/73-byte signature upper bound, total-length byte mismatch, null R/S bytes when R/S is single-byte, 3-byte signature lower bound, and 33-byte public keys with invalid prefix. These tests kill live mutants identified by bitcoincore.space mutation testing. No changes to src/script/interpreter.cpp or any consensus-critical runtime code are present in the diff.
Changed components
src/test/data/script_tests.jsonInspect captured patch +13 / −0
### src/test/data/script_tests.json
@@ -726,6 +726,9 @@
["0x17 0x3014020002107777777777777777777777777777777701", "0 CHECKSIG NOT", "", "OK", "Zero-length R is correctly encoded"],
["0x17 0x3014021077777777777777777777777777777777020001", "0 CHECKSIG NOT", "", "OK", "Zero-length S is correctly encoded for DERSIG"],
["0x27 0x302402107777777777777777777777777777777702108777777777777777777777777777777701", "0 CHECKSIG NOT", "", "OK", "Negative S is correctly encoded"],
+["0x4a 0x3047022201010101010101010101010101010101010101010101010101010101010101010101022101010101010101010101010101010101010101010101010101010101010101010101", "0 CHECKSIG NOT", "", "OK", "74-byte signature is correctly encoded"],
+["0x47 0x3043022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501", "0 CHECKSIG NOT", "", "OK", "Total-length byte not covering the entire signature is correctly encoded"],
+["0x03 0x300000", "0 CHECKSIG NOT", "", "OK", "3-byte signature is correctly encoded"],
["2147483648", "CHECKSEQUENCEVERIFY", "CHECKSEQUENCEVERIFY", "OK", "CSV passes if stack top bit 1 << 31 is set"],
@@ -1283,6 +1286,10 @@
"2-of-3 with one valid and one invalid signature due to parse error, nSigs > validSigs (DERSIG enabled)."
],
+["Increase STRICTENC test coverage"],
+["0", "0x21 0x06865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 CHECKSIG NOT", "", "OK", "33-byte pubkey with a prefix other than 0x02/0x03 is correctly encoded"],
+["0", "0x21 0x06865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 CHECKSIG NOT", "STRICTENC", "PUBKEYTYPE", "33-byte pubkey with a prefix other than 0x02/0x03 is incorrectly encoded for STRICTENC"],
+
["Increase DERSIG test coverage"],
["0x4a 0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "0 CHECKSIG NOT", "DERSIG", "SIG_DER", "Overly long signature is incorrectly encoded for DERSIG"],
["0x25 0x30220220000000000000000000000000000000000000000000000000000000000000000000", "0 CHECKSIG NOT", "DERSIG", "SIG_DER", "Missing S is incorrectly encoded for DERSIG"],
@@ -1293,6 +1300,12 @@
["0x17 0x3014021077777777777777777777777777777777020001", "0 CHECKSIG NOT", "DERSIG", "SIG_DER", "Zero-length S is incorrectly encoded for DERSIG"],
["0x27 0x302402107777777777777777777777777777777702108777777777777777777777777777777701", "0 CHECKSIG NOT", "DERSIG", "SIG_DER", "Negative S is incorrectly encoded for DERSIG"],
["0x27 0x312402107777777777777777777777777777777702107777777777777777777777777777777701", "0 CHECKSIG NOT", "DERSIG", "SIG_DER", "Non-compound type is incorrectly encoded for DERSIG"],
+["0x4a 0x3047022201010101010101010101010101010101010101010101010101010101010101010101022101010101010101010101010101010101010101010101010101010101010101010101", "0 CHECKSIG NOT", "DERSIG", "SIG_DER", "74-byte signature is incorrectly encoded for DERSIG"],
+["0x49 0x30460221010101010101010101010101010101010101010101010101010101010101010101022101010101010101010101010101010101010101010101010101010101010101010101", "0 CHECKSIG NOT", "DERSIG", "OK", "73-byte signature is correctly encoded for DERSIG"],
+["0x47 0x3043022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501", "0 CHECKSIG NOT", "DERSIG", "SIG_DER", "Total-length byte not covering the entire signature is incorrectly encoded for DERSIG"],
+["0x09 0x300602010002010101", "0 CHECKSIG NOT", "DERSIG", "OK", "Null R byte is correctly encoded for DERSIG when R is a single byte"],
+["0x09 0x300602010102010001", "0 CHECKSIG NOT", "DERSIG", "OK", "Null S byte is correctly encoded for DERSIG when S is a single byte"],
+["0x03 0x300000", "0 CHECKSIG NOT", "DERSIG", "SIG_DER", "3-byte signature is incorrectly encoded for DERSIG"],
["Some basic segwit checks"],
[["00", 0.00000000 ], "", "0 0x206e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d", "P2SH,WITNESS", "EVAL_FALSE", "Invalid witness script"],Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.