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

BOLT 12: Validate bech32 padding per BIP-173

Public commit record

What the developer wrote

Authored by Vincenzo Palazzo

86/100 · Strong
BOLT 12: Validate bech32 padding per BIP-173

Add validation for bech32 padding in BOLT 12 offer parsing per BIP-173
which states: "Any incomplete group at the end MUST be 4 bits or less,
MUST be all zeroes, and is discarded."

This adds a test vector from the BOLT specification that ensures offers
with invalid padding (exceeding the 4-bit limit) are properly rejected.

Previously, LDK would accept offers with invalid bech32 padding. This
was identified through differential fuzzing across Lightning
implementations (see lightning/bolts#1312).

The fix calls `validate_segwit_padding()` from the bech32 crate during
offer parsing, and introduces a new `InvalidPadding` variant to
`Bolt12ParseError` to surface these errors.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This change fixes how LDK parses BOLT 12 offers encoded in bech32. Previously, LDK accepted offers whose bech32 padding was invalid according to the BIP-173 standard. The fix now rejects such malformed offers, matching the protocol specification and preventing potential parsing disagreements between Lightning implementations.

Recommended action

Review whether other bech32-decoding paths in the codebase (e.g., invoice parsing, node announcements, other BOLT 12 message types) similarly lack padding validation and should be hardened. Ensure the new InvalidPadding error is handled appropriately by downstream consumers and bindings.

Security signals we found

01

Input validation hardening: enforces BIP-173 bech32 padding rules during BOLT 12 offer parsing

02

New error variant surfaces previously swallowed malformed input

03

Adds specification test vectors for invalid padding rejection

04

Cross-implementation differential fuzzing identified the discrepancy

Risk score

Why this scored 45/100

Our methodology →
Potential impact 12/30
Exploitability 8/25
Stealth signal 6/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.