Skip to content

[bug]: BOLT 11 Compliance: Invoice description field not validated as UTF-8 #9904

@erickcestari

Description

@erickcestari

Background

After doing some differential fuzzing between rust-lightining and LND using bitcoinfuzz I noticed that LND currently accepts Lightning invoices with invalid UTF-8 in the description field (d), violating BOLT 11 specification requirements.

BOLT 11 Requirements:

  • d field "Short description of purpose of payment (UTF-8)"
  • Writer "MUST set d to a valid UTF-8 string"

Current Behavior: The parseDescription function converts bech32 data to string without UTF-8 validation, allowing invalid byte sequences.

Expected Behavior: Reject invoices with non-UTF-8 description fields per spec.

Impact:

  • Spec non-compliance
  • Potential interoperability issues with other Lightning implementations
  • Display problems in wallets/UIs

Proposed Fix: Add utf8.Valid() check in parseDescription before string conversion.

if !utf8.Valid(base256Data) {
    return nil, fmt.Errorf("description is not valid UTF-8")
}

Example invoice with invalid description UTF-8 bytes:

lnbc100n1pllllllpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdz823jhxapqv3jhxcmjd9c8g6t0dcs924zx95uzqamfw35zq6twweskc6tyyp38jar9wvs0llsnp4q0n326hr8v9zprg8gsvezcch06gfaqqhde2aj730yg0durunfhv669qrsgquuwsa0vmqyngdnj3j2sz0hc29eaq0sypz2lpr8v2aa0csjufcw9j3hzp6sfzzuu6jz7gzs22sw0msxaq7uc0jzp7usmg2dsa6cxahrqpjdwkzz

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2should be fixed if one has timebugUnintended code behaviourinvoices

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions