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

feat: add validation for leading whitespace in BOLT 12 bech32 strings

Public commit record

What the developer wrote

Authored by Erick Cestari

95/100 · Strong
feat: add validation for leading whitespace in BOLT 12 bech32 strings

Found through differential fuzzing between C-Lightning and rust-lightning:
rust-lightning incorrectly accepted offers starting with whitespace when
continuation characters (+) were present, while C-Lightning correctly
rejected them per BOLT 12 specification.

- Add InvalidLeadingWhitespace error variant to Bolt12ParseError
- Validate that bech32 strings don't start with whitespace characters
- Separate validation logic for first chunk vs continuation chunks
- Add test case for leading whitespace validation
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Uses a recognizable type or scope✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes a parsing bug in rust-lightning's handling of BOLT 12 payment offers. Previously, the library incorrectly accepted offers that began with whitespace characters when the offer string was split across multiple lines using '+' continuation characters. This violated the BOLT 12 specification and could cause rust-lightning to accept malformed offers that other Lightning implementations would reject. The fix adds explicit validation to reject any offer string that starts with whitespace.

Recommended action

Review whether any other BOLT 12 parsing edge cases differ from the specification and consider expanding differential fuzzing coverage against C-Lightning and other implementations. Ensure downstream users update to include this validation fix.

Security signals we found

01

Specification non-compliance in cryptographic/offer parsing

02

Cross-implementation differential fuzzing finding

03

Input validation weakness allowing malformed bech32 strings

04

Potential interoperability or denial-of-service vector via malformed BOLT 12 offers

Risk score

Why this scored 38/100

Our methodology →
Potential impact 8/30
Exploitability 6/25
Stealth signal 5/15
Affected reach 7/15
Confidence 8/10
Evidence quality 4/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.