What changed, and why it matters
This commit updates the Lightning Network 'init' handshake message in LND so it can carry custom data records using a standard format (TLV). It is a protocol-level feature addition that enables future functionality, not a fix for a known bug or vulnerability. There is no direct evidence in the commit that this change addresses a security issue.
Treat as a routine feature commit. Review the ParseAndExtractCustomRecords and MergeAndEncode implementations for validation of TLV types and lengths if assessing robustness, but no immediate security action is indicated by this diff alone.
Security signals we found
No security-relevant language in commit title or message
No CVE, advisory, or bug reference present
Change is a feature addition enabling custom TLV records in init message
No bounds, validation, or memory-safety fixes visible
No attribution to a security researcher
Evidence from the diff
The patch modifies lnwire/init_message.go to add a CustomRecords field to the Init message and changes Decode/Encode to parse and emit TLV-style custom records via ParseAndExtractCustomRecords and MergeAndEncode helpers. The ExtraData field is now populated from leftover bytes after custom records are extracted, and encoding merges custom records with any existing extra data. This aligns the Init message with the custom records pattern already used elsewhere in LND’s wire messages.
Changed components
lnwire/init_message.goLND peer wire protocol Init message encoding/decodingInspect captured patch +29 / −4
diff --git a/lnwire/init_message.go b/lnwire/init_message.go
index b88891b..dd3b471 100644
--- a/lnwire/init_message.go
+++ b/lnwire/init_message.go
@@ -24,6 +24,10 @@ type Init struct {
// Features field.
Features *RawFeatureVector
+ // CustomRecords maps TLV types to byte slices, storing arbitrary data
+ // intended for inclusion in the ExtraData field of the init message.
+ CustomRecords CustomRecords
+
// ExtraData is the set of data that was appended to this message to
// fill out the full maximum transport message size. These fields can
// be used to specify optional data such as custom TLV fields.
@@ -35,7 +39,6 @@ func NewInitMessage(gf *RawFeatureVector, f *RawFeatureVector) *Init {
return &Init{
GlobalFeatures: gf,
Features: f,
- ExtraData: make([]byte, 0),
}
}
@@ -52,11 +55,28 @@ var _ SizeableMessage = (*Init)(nil)
//
// This is part of the lnwire.Message interface.
func (msg *Init) Decode(r io.Reader, pver uint32) error {
- return ReadElements(r,
+ var msgExtraData ExtraOpaqueData
+
+ err := ReadElements(r,
&msg.GlobalFeatures,
&msg.Features,
- &msg.ExtraData,
+ &msgExtraData,
)
+ if err != nil {
+ return err
+ }
+
+ customRecords, _, extraDData, err := ParseAndExtractCustomRecords(
+ msgExtraData,
+ )
+ if err != nil {
+ return err
+ }
+
+ msg.CustomRecords = customRecords
+ msg.ExtraData = extraDData
+
+ return nil
}
// Encode serializes the target Init into the passed io.Writer observing
@@ -72,7 +92,12 @@ func (msg *Init) Encode(w *bytes.Buffer, pver uint32) error {
return err
}
- return WriteBytes(w, msg.ExtraData)
+ extraData, err := MergeAndEncode(nil, msg.ExtraData, msg.CustomRecords)
+ if err != nil {
+ return err
+ }
+
+ return WriteBytes(w, extraData)
}
// MsgType returns the integer uniquely identifying this message type on the
Why this scored 21/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.