AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
High 72 Bitcoin

lightning-types: replace Zl/Zp separators in `PrintableString`

Public commit record

What the developer wrote

Authored by Vincenzo Palazzo

96/100 · Strong
lightning-types: replace Zl/Zp separators in `PrintableString`

`PrintableString` replaces control (`Cc`), "other" (`C*`, including
`Cf`), and unassigned codepoints with U+FFFD, but U+2028 LINE SEPARATOR
(`Zl`) and U+2029 PARAGRAPH SEPARATOR (`Zp`) passed through verbatim:
`char::is_control` is `Cc`-only and the generated tables in
`unicode.rs` only cover the top-level `C` categories. Many terminals
and log viewers render U+2028/U+2029 as hard line breaks, so a
peer-controlled string (node alias, BOLT 12 description/issuer/
payer_note, `peer_msg`) could inject forged log lines that appear
sanitised.

Extend `contrib/gen_unicode_general_category.py` to also emit a
`Zl`/`Zp` separator predicate and regenerate `unicode.rs` from the
same UnicodeData 17.0.0 the existing tables were built from, then filter
on the new predicate in `PrintableString`. `Zs` is deliberately
excluded as it contains U+0020 SPACE. Add a regression test mirroring
the existing bidi-override test.

Found by a Loupe scan, tracked by the Bitcoin Security Council:
https://github.com/bitcoin-security-council/findings/pull/180

Co-Authored-By: goose (AI agent) <noreply@localhost>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit fixes a log-forgery risk in a Rust Lightning library helper called PrintableString. That helper is meant to make untrusted text safe to print by replacing dangerous characters with a placeholder. It already caught most control characters, but it missed two special Unicode line-break characters (U+2028 and U+2029). Because many terminals and log viewers treat those as real line breaks, an attacker could smuggle them inside an otherwise 'sanitised' string to fake new log lines, potentially misleading an operator. The patch adds a check for those two characters and includes a regression test.

Recommended action

Review all downstream uses of PrintableString to confirm no other output path bypasses the new predicate, and ensure the regenerated unicode.rs tables are committed consistently. Consider auditing other string-display helpers for similar separator bypasses.

Security signals we found

01

log injection / log forgery via U+2028/U+2029 line separators

02

incomplete input sanitisation in PrintableString

03

peer-controlled strings (node alias, BOLT 12 description/issuer/payer_note, peer_msg) as attack surface

04

regression test added for the sanitisation gap

Risk score

Why this scored 72/100

Our methodology →
Potential impact 18/30
Exploitability 16/25
Stealth signal 12/15
Affected reach 12/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.