hsmd: check *all* anchor inputs for short sigs.
What changed, and why it matters
This commit fixes a test-only diagnostic check in Core Lightning's hardware signing daemon (HSM). The code warns developers if a Bitcoin signature is unusually short (a sign of 'overgrinding' during signature creation), but it only checked the first input of an anchor-spending transaction. Anchor transactions can have multiple inputs, so the check missed short signatures on the other inputs. This is a testing/quality fix, not a vulnerability that attackers can exploit.
No urgent action. Treat as a minor developer-experience/test-reliability fix. Ensure tests that rely on overgrind warnings now cover multi-input anchor spends.
Security signals we found
Signature-length diagnostic expanded from first input to all inputs
No transaction rejection or policy enforcement added
Only active under dev_warn_on_overgrind developer flag
Fixes a test assertion failure in test_closing.py related to expected overgrind detection
Evidence from the diff
In hsmd/libhsmd.c, handle_sign_anchorspend() previously inspected only psbt->inputs[0] for short ECDSA signatures (< 71 bytes) when the dev_warn_on_overgrind flag is enabled. The patch loops over all psbt->num_inputs and reports any input with a single signature whose value_len is under 71. The change is purely diagnostic: it logs a LOG_BROKEN warning and does not reject or alter the transaction. The included test failure shows the missing warning caused an unrelated feerate assertion to fail because the test expected the overgrind warning to relax the feerate check.
Changed components
hsmd/libhsmd.chandle_sign_anchorspend()dev_warn_on_overgrind diagnostic pathInspect captured patch +10 / −6
diff --git a/hsmd/libhsmd.c b/hsmd/libhsmd.c
index dd23292..53988bf 100644
--- a/hsmd/libhsmd.c
+++ b/hsmd/libhsmd.c
@@ -1820,12 +1820,16 @@ static u8 *handle_sign_anchorspend(struct hsmd_client *c, const u8 *msg_in)
fmt_pubkey(tmpctx, &local_funding_pubkey),
fmt_wally_psbt(tmpctx, psbt));
}
- if (dev_warn_on_overgrind
- && psbt->inputs[0].signatures.num_items == 1
- && psbt->inputs[0].signatures.items[0].value_len < 71) {
- hsmd_status_fmt(LOG_BROKEN, NULL,
- "overgrind: short signature length %zu",
- psbt->inputs[0].signatures.items[0].value_len);
+
+ if (dev_warn_on_overgrind) {
+ for (size_t i = 0; i < psbt->num_inputs; i++) {
+ if (psbt->inputs[i].signatures.num_items == 1
+ && psbt->inputs[i].signatures.items[0].value_len < 71) {
+ hsmd_status_fmt(LOG_BROKEN, NULL,
+ "overgrind: short signature length %zu",
+ psbt->inputs[i].signatures.items[0].value_len);
+ }
+ }
}
return towire_hsmd_sign_anchorspend_reply(NULL, psbt);
Why this scored 19/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.