Skip to content

Fail bolt11 invoices with a wrong-length p, h, s or n field - #9670

Open
vincenzopalazzo wants to merge 1 commit into
ElementsProject:masterfrom
vincenzopalazzo:fix/bolt11-wrong-fixed-length
Open

vincenzopalazzo wants to merge 1 commit into
ElementsProject:masterfrom
vincenzopalazzo:fix/bolt11-wrong-fixed-length

Conversation

@vincenzopalazzo

Copy link
Copy Markdown
Collaborator

Summary

  • bolt11_decode accepted an invoice whose p, h, s or n field had the wrong data_length. A duplicate of those tags never reached the length check: it was stored as an unknown field and skipped.
  • BOLT Minor issues in documentation #11 (pinned 4b539711, also current master of lightning/bolts) says a reader MUST fail the payment if any field with fixed data_length (p, h, s, n) is not 52, 52, 52 or 53. The older "MUST skip" wording is gone.
  • The length is now checked before the unknown-field skip, including a second copy of the tag. Unknown tags and unknown f versions are still skipped.
  • The published "fields which must be ignored" vector still marks those wrong lengths as "(ignored)". That breakdown disagrees with the reader requirement, so the vector is now rejected. Worth a spec follow-up.

Fixes #9668

Test plan

  • make unittest/common/test/run-bolt11 — rejects p/h/s of length 51 and 53, and n of length 52 and 54, and rejects the published ignored-fields vector with p: invalid length 51 (expected 52)
  • make bolt-check/common/bolt11.c against the pinned BOLT quote
  • CI

@vincenzopalazzo
vincenzopalazzo force-pushed the fix/bolt11-wrong-fixed-length branch 2 times, most recently from 485ce33 to 6540882 Compare October 27, 2026 16:11
BOLT ElementsProject#11 requires a reader to fail the payment if a fixed-length
`p`, `h`, `s` or `n` field is not 52, 52, 52 or 53 digits.  A second
copy of those tags was treated as an unknown field and skipped, so
decode accepted the invoice.

Check the length before the unknown-field skip, including duplicates.
The published "fields which must be ignored" vector is now rejected;
unknown tags and unknown fallback versions are still skipped.

Fixes ElementsProject#9668
Changelog-Fixed: bolt11: reject an invoice whose `p`, `h`, `s` or `n` field has the wrong length.
@vincenzopalazzo
vincenzopalazzo force-pushed the fix/bolt11-wrong-fixed-length branch from 6540882 to a19705e Compare October 27, 2026 17:26

This branch has not been deployed

No deployments
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.

bolt11 decode accepts a p, h, s or n field of the wrong length

1 participant