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

common/test: reproduce BOLT 12 PR #1295 marker-jump spec contradiction

Public commit record

What the developer wrote

Authored by Vincenzo Palazzo

100/100 · Strong
common/test: reproduce BOLT 12 PR #1295 marker-jump spec contradiction

Add a failing C unit test that reproduces the BOLT 12 spec
contradiction raised on lightning/bolts#1295.

The writer rule in `12-offer-encoding.md` (lines 1041-1049, head
db3eff3a54) mandates that after a `proof_omitted_tlvs` entry of
`239` the next entry MUST be `1000000000`, because the writer skips
past the signature/payer-proof TLV range (240..999999999).

The reader rule (lines 1065-1067) only accepts an entry that is
`prev + 1` or `<included TLV> + 1`, with no carve-out for the
239 -> 1000000000 jump.

A reader applying the spec literally rejects a marker sequence the
writer rule mandates.

CLN's reader in common/bolt12_proof.c lines 339-388 is a literal
transcription of the bogus reader rule (specifically the
`omitted != prev_omitted + 1` branch at line 379).

Fed the writer-rule-mandated sequence [1, 2, ..., 239, 1000000000]
it returns an error on the 1000000000 entry.

The new test in common/test/run-bolt12_proof_marker_jump.c builds
the minimum tlv_payer_proof needed to reach the marker-validation
loop and asserts check_payer_proof returns NULL.

It is expected to fail on current master, the failure IS the
reproduction. The fix belongs in the spec PR first (amend reader
rule 1065) and only then mirrored into CLN.

The same contradiction is reproduced on the Rust-Lightning side in
lightningdevkit/rust-lightning#4297, test
spec_writer_reader_rules_contradict_on_gap_jump in
lightning/src/offers/merkle.rs (commit 0034c79ae).

Changelog-None

Link: https://github.com/lightning/bolts/pull/1295#discussion_r3286972971
Link: https://github.com/lightningdevkit/rust-lightning/pull/4297
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ 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 adds a new test file that deliberately fails to prove there is a contradiction in the BOLT 12 specification. The spec's writer rules say a certain list of omitted fields must jump from 239 to 1,000,000,000, but the reader rules reject that exact jump. Core Lightning's code follows the reader rule literally, so it would reject a message that another implementation following the writer rule would produce. The commit itself does not fix the bug; it only reproduces it and is expected to fail until the specification is updated.

Recommended action

Treat this as a specification/implementation mismatch rather than an immediate exploitable vulnerability. Monitor lightning/bolts#1295 for the spec fix, then update common/bolt12_proof.c's check_payer_proof() to mirror the amended reader rule allowing the 239 -> 1000000000 jump. Re-run the new test to confirm it passes. Do not merge this commit alone if CI enforces passing tests, because the commit is intentionally a failing reproduction.

Security signals we found

01

Protocol-level spec contradiction between writer and reader rules

02

Implementation follows a reader rule that rejects spec-compliant encodings

03

Potential interoperability failure with other BOLT12 implementations

04

Failing regression test added to document the contradiction

Risk score

Why this scored 37/100

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