Skip to content

Ban unicode control characters from utf8 fields#1341

Open
t-bast wants to merge 1 commit into
lightning:masterfrom
t-bast:disallow-null-chars
Open

Ban unicode control characters from utf8 fields#1341
t-bast wants to merge 1 commit into
lightning:masterfrom
t-bast:disallow-null-chars

Conversation

@t-bast

@t-bast t-bast commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

As discussed in #1260, we should ban NULL and other control characters in utf8 fields: there's no valid use-case for them.

We also make sure that feature bits MUST be minimally-encoded everywhere instead of being lenient for node_announcement for no good reason.

@morehouse morehouse left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it also make sense to call out that the receiving node MAY reject gossip with non-conforming alias or features fields?

Eclair and LND in particular may want to reject such gossip during decoding since they currently don't preserve the underlying bytes of some non-conforming fields for signature verification (ACINQ/eclair#3314, lightningnetwork/lnd#10835).

@t-bast

t-bast commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

Good idea, I added explicit requirements on the receiving side in f160681

@morehouse morehouse left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread 01-messaging.md Outdated

@tnull tnull left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do wonder if it would be worth to provide test vectors for this? Maybe they could be generated by reusing the script we recently added to LDK, see https://github.com/lightningdevkit/rust-lightning/pull/4605/changes#diff-af90f55a5f5e4af60b13fc942aee60e49311cb223f15bccdf373117b4aabc3df

As discussed in lightning#1260, we should ban NULL and other control characters
in utf8 fields, along with characters that don't provide any value in
node aliases: there's no valid use-case for them.

Unfortunately, unicode cannot provide static lists of characters in each
category, since it is open to extension. We thus more strongly restrict
writers, and set reader restrictions that are more stable.

We also make sure that feature bits MUST be minimally-encoded everywhere
instead of being lenient for `node_announcement` for no good reason.
@t-bast t-bast force-pushed the disallow-null-chars branch from f160681 to dcd957d Compare June 8, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants