fuzz-tests: Add fuzz target for closing_sig
What changed, and why it matters
This commit adds a new automated fuzz test for a Lightning network channel-closing message called 'closing_sig'. It only adds test code and does not change any production code, so it cannot introduce a runtime security vulnerability by itself. It is a defensive testing improvement.
No security action required. Treat as normal test-coverage improvement. If reviewing further, verify that the fuzz target is compiled and run in CI, and that the equal() function's assertions do not abort fuzzing on benign mismatches.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit introduces tests/fuzz/fuzz-wire-closing_sig.c, a new fuzz target that round-trips the WIRE_CLOSING_SIG peer wire message through towire_closing_sig/fromwire_closing_sig and checks equality of decoded fields. No production wire parsing/serialization logic is modified; the file is purely additive test infrastructure.
Changed components
tests/fuzz/fuzz-wire-closing_sig.cInspect captured patch +52 / −0
diff --git a/tests/fuzz/fuzz-wire-closing_sig.c b/tests/fuzz/fuzz-wire-closing_sig.c
new file mode 100644
index 00000000..e578a7c8
--- /dev/null
+++ b/tests/fuzz/fuzz-wire-closing_sig.c
@@ -0,0 +1,52 @@
+#include "config.h"
+#include <assert.h>
+#include <ccan/mem/mem.h>
+#include <tests/fuzz/libfuzz.h>
+#include <tests/fuzz/wire.h>
+#include <wire/peer_wire.h>
+
+struct closing_sig {
+ struct channel_id channel_id;
+ u32 locktime;
+ struct amount_sat fee_satoshis;
+ u8 *closer_scriptpubkey, *closee_scriptpubkey;
+ struct tlv_closing_tlvs *tlvs;
+};
+
+static void *encode(const tal_t *ctx, const struct closing_sig *s)
+{
+ return towire_closing_sig(ctx, &s->channel_id, s->closer_scriptpubkey,
+ s->closee_scriptpubkey, s->fee_satoshis, s->locktime, s->tlvs);
+}
+
+static struct closing_sig *decode(const tal_t *ctx, const void *p)
+{
+ struct closing_sig *s = tal(ctx, struct closing_sig);
+
+ if (fromwire_closing_sig(s, p, &s->channel_id, &s->closer_scriptpubkey,
+ &s->closee_scriptpubkey, &s->fee_satoshis, &s->locktime, &s->tlvs))
+ return s;
+ return tal_free(s);
+}
+
+static bool equal(const struct closing_sig *x,
+ const struct closing_sig *y)
+{
+ assert(memcmp(&x->channel_id, &y->channel_id, sizeof(x->channel_id)) == 0);
+ assert(x->locktime == y->locktime);
+ assert(memcmp(&x->fee_satoshis, &y->fee_satoshis, sizeof(x->fee_satoshis)) == 0);
+
+ assert(tal_arr_eq(x->closer_scriptpubkey, y->closer_scriptpubkey));
+ assert(tal_arr_eq(x->closee_scriptpubkey, y->closee_scriptpubkey));
+
+ assert(x->tlvs && y->tlvs);
+ assert(tal_arr_eq(x->tlvs->closer_output_only, y->tlvs->closer_output_only));
+ assert(tal_arr_eq(x->tlvs->closee_output_only, y->tlvs->closee_output_only));
+
+ return tal_arr_eq(x->tlvs->closer_and_closee_outputs, y->tlvs->closer_and_closee_outputs);
+}
+
+void run(const u8 *data, size_t size)
+{
+ test_decode_encode(data, size, WIRE_CLOSING_SIG, struct closing_sig);
+}
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.