Repository navigation
Description
Summary
The issue's headline attack is not mitigated, and the follow-up issue misdescribes the fix.
Severity: low. Found in the 2026-11-04 review of the v1.0.1 change set (all 1.x.x merges since v1.0.0 plus the open PRs that target it), against 1.x.x 21fee6ee8e; area: #265, #259.
Observed
Confidence: confirmed.
- Location:
src/script/sigcache.cpp:122-142; Review finding: OP_CHECKDATASIGPQC failures bypass the PQC signature cache #259 body; Mempool: per-peer accounting for failed PQC verification time #275 body. - Scenario: Review finding: OP_CHECKDATASIGPQC failures bypass the PQC signature cache #259's observed attack is "a grinded garbage signature passes the cheap FORS+C gate and forces a full ~1.7-2.2 ms verify; ... the same witness can be replayed with a mutated transaction." script: cache verified P2MR data-signature checks (v1.0.1) #265 caches successes only, so an invalid signature costs a full verification on every mutated replay, before and after script: cache verified P2MR data-signature checks (v1.0.1) #265 (the PR's own test shows 2 submissions, 2 verifies). script: cache verified P2MR data-signature checks (v1.0.1) #265 fixes the related valid-signature-in-failing-leaf replay that Release v1.0.1: test results, remaining fixes, and release gates #174's triage identified. Review finding: OP_CHECKDATASIGPQC failures bypass the PQC signature cache #259 is nonetheless closed "Fixed by script: cache verified P2MR data-signature checks (v1.0.1) #265". Mempool: per-peer accounting for failed PQC verification time #275 says "the failure cache added with script: cache verified P2MR data-signature checks (v1.0.1) #265 helps only byte-identical resubmissions", but script: cache verified P2MR data-signature checks (v1.0.1) #265 added no failure cache, and byte-identical resubmissions were already stopped by the wtxid reject filter.
- Evidence: code, the PR script: cache verified P2MR data-signature checks (v1.0.1) #265 test description, issue texts.
Impact
Tracking accuracy for a DoS that is still open (~0.5 µs of cs_main time per witness byte, no peer penalty). Anyone reading #259/#275 could conclude the garbage-signature path is partly mitigated.
Suggested fix
Edit #275 to say "#265 caches verified successes only; it does not reduce the cost of invalid signatures", and link #259's headline scenario to #275 as the open item.
No other defects found. Checks that came back clean (attempted disproof):
- Cache keys (script: cache successful P2MR PQC signature checks #162, script: cache verified P2MR data-signature checks (v1.0.1) #265).
'P'key = salted SHA256(sighash ‖ 32-byte pubkey ‖ 3,680-byte sig).CheckPQCSignaturefixes both lengths before the seam (interpreter.cpp:2039-2057), so the concatenation is unambiguous. The P2MR sighash commits to hash type, annex, tapleaf hash (leaf version + script), key_version and codeseparator position (interpreter.cpp:1736-1827), and the SLH-DSA verdict depends only on (digest, pk, sig). Leaving script flags and leaf version out of the key is therefore sound, as for Core's ECDSA/Schnorr entries. 'D'domain (script: cache verified P2MR data-signature checks (v1.0.1) #265). Separate salt; invalid key or wrong size bypasses the cache (sigcache.cpp:125-129). A'P'entry cannot satisfy a'D'lookup or the reverse.- Validation weight. The weight debit happens in
EvalChecksigP2MR/EvalCheckDataSigPQCbefore any checker call (interpreter.cpp:416-427,447-457), so a hit never skips the weight charge or size, hash-type or missing-data checks. - Policy vs consensus. The cache stores primitive verdicts only, which are independent of flags. The script-execution cache key includes flags.
GetBlockScriptFlags/GetNextBlockScriptFlagsnever addSCRIPT_VERIFY_P2MR_STACK_BYTES(validation.cpp:2385-2449). A policy-validated mempool entry therefore cannot make block validation skip a consensus check. - Concurrency.
Gettakes a shared lock (cuckoo erase flags are atomic),Setan exclusive one; unchanged from Core. With-par, two threads checking one signature can both miss and both verify; correct, just redundant. Assumevalid skips scripts entirely, and reindex consumes entries or misses, so results match a cacheless run. - Thread-safety of production hot paths. The test-only hooks cost one atomic load each (
ScopedPQCVerificationCounter::g_counterinCPQCPubKey::Verify, the observer pointer). - Every
BaseSignatureCheckersubclass keeps its pre-script: cache verified P2MR data-signature checks (v1.0.1) #265 data-signature behavior (Deferring forwards; everything else runs the primitive). - policy: bound P2MR runtime stack bytes #263 distance to wallet spends.
- Stack bytes are per input, so input count does not accumulate.
- Single-sig P2MR input peak: 3,681 + 32 bytes = 3,713 B, 0.35% of the cap (about 282× headroom).
- Largest consensus-possible multi-sig or data-sig leaf: at most 128 KiB of initial items + 32-byte pushes, about 131 KiB, about 12.5% of the cap (8× headroom).
- Without copy opcodes no script can exceed 651,072 B (static_assert at
script.h:57). - Miniscript/descriptor fragments copy only 1-byte selectors or 32-byte keys (
miniscript.h:769,779,794), so no wallet-created, PSBT orOP_CHECKDATASIGPQCleaf comes near 1 MiB.
- policy: bound P2MR runtime stack bytes #263 error contract.
SCRIPT_ERR_P2MR_STACK_BYTESmaps toTX_NOT_STANDARDwithmempool-script-verify-flag-failed (Standard P2MR stack byte limit exceeded). qbit does not penalize peers for transaction failures (net_processing.cpp:3316-3326), so no peer penalty and no ban divergence. Inserting the enum value shifts laterScriptErrorintegers, but none is serialized or exported (no kernel C API, RPC uses strings). - doc: fix pipe rendering and tighten P2MR v1 consensus profile #252. A word diff and a normative-token diff of the whole file show:
- MUST/MUST NOT changes come only from line re-wraps; no value, error name or range changed.
- The removed sentence "Commitment validation precedes known-leaf resource and script validation" is subsumed by the new "fails at the first failing stage, in this order" table. I checked that order against
VerifyWitnessProgram(interpreter.cpp:2381-2440) andExecuteWitnessScript(:2164-2208): witness presence → control shape → marker → commitment → initial resources → OP_SUCCESS pre-scan/script → cleanstack → truth. They match. - The §11 column split keeps every row's meaning, including the "unknown witness version" qualifier restored after Codex's comment.
- doc: document bounded30 usage-dependent security margin and raw-key counter limits #264.
- The §9 wording changes no MUST. RPC help texts match the code:
FlatSigningProviderstarts each key at counter 0 per call (rpc/rawtransaction_util.cpp:60,77;script/signingprovider.cpp:181-199). - The 118.2-bit figure re-derives as 128 − log2(Bell(7)=877).
- The birthday figure re-derives as √(2 ln 2 · 2^30) ≈ 38,580.
- Wallet thresholds match
wallet/pqc_usage.h:23-24. - The "repeated digest reproduces the same signature" claim holds: signing randomness is derived from (sk, msg) in
libbitcoinpqc/src/slh_dsa/sign.c:85-98.
- The §9 wording changes no MUST. RPC help texts match the code:
- Manifests and digests.
sha256(src/test/data/p2mr_v1_manifest.json)=00cd4e1c…7abequals all 13corpus_manifest_sha256entries indoc/integration/p2mr-v1-support-matrix.jsonand the.mdheader. All four corpus files listed in the manifest match their recorded digests.ci/release/test_verify_p2mr_v1_conformance.py(31 tests) andcontrib/devtools/test_p2mr_v1_generators.py(3 tests) pass.
Related: extends #275 and the #181 "Failed PQC signature checks are not cached" known limitation, both of which document the residual DoS correctly. New: the #259 closure and the #275 description are inaccurate.
Activity
kiwidream commentedon Nov 10, 2026
Consolidated into #275, which is now the single tracking issue for the validation cost of invalid PQC signatures. What this issue asked for is done:
The checks this report found clean need no follow-up. Closing as a duplicate of #275.