channeld: Cleaner error messages
What changed, and why it matters
This commit adds a safety check in Core Lightning's channel daemon to verify that incoming peer messages are actually the expected 'commitment signed' type before processing them. If a different message type arrives, the daemon now logs a clear error and fails the peer connection rather than potentially misinterpreting the data. It is a defensive hardening change, not a fix for a known exploitable bug.
Treat as routine defensive hardening. No urgent action required unless follow-up commits or disclosures indicate this guard was added in response to a specific vulnerability.
Security signals we found
Added explicit message-type validation before deserialization
Added diagnostic peer failure path for unexpected wire types
Defensive hardening around batch commitment_signed handling
Evidence from the diff
In channeld/channeld.c, handle_peer_commit_sig_batch() now calls check_tx_abort() and fromwire_peektype() to inspect the message before attempting to decode it as a commitment_signed. If the wire type does not match WIRE_COMMITMENT_SIGNED, it calls peer_failed_err() with an explicit diagnostic string. This improves error diagnostics and adds a type-validation guard at the entry point of batch commit-sig handling.
Changed components
channeld/channeld.chandle_peer_commit_sig_batch()Inspect captured patch +6 / −0
diff --git a/channeld/channeld.c b/channeld/channeld.c
index fde5e382..efbf4800 100644
--- a/channeld/channeld.c
+++ b/channeld/channeld.c
@@ -2270,6 +2270,12 @@ static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
struct tlv_commitment_signed_tlvs *cs_tlv
= tlv_commitment_signed_tlvs_new(tmpctx);
status_debug("fromwire_commitment_signed(%p) primary", msg);
+ check_tx_abort(peer, msg, NULL);
+ type = fromwire_peektype(msg);
+ if (type != WIRE_COMMITMENT_SIGNED)
+ peer_failed_err(peer->pps, &peer->channel_id,
+ "Expected WIRE_COMMITMENT_SIGNED but got %s.",
+ peer_wire_name(type));
if (!fromwire_commitment_signed(tmpctx, msg,
&channel_id, &commit_sig.s, &raw_sigs,
&cs_tlv))
Why this scored 26/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.