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

Serialize experimental TLV records in unsigned invoice requests

Public commit record

What the developer wrote

Authored by auto-pr-bot

86/100 · Strong
Serialize experimental TLV records in unsigned invoice requests

The `Writeable` implementation for `UnsignedInvoiceRequest` emitted only
`bytes`, omitting `experimental_bytes`, even though construction and
parsing include that buffer in `tagged_hash` and `sign` appends it to
the signed invoice request. A signer reviewing the unsigned
serialization before releasing a signature would therefore not see
records that the signature commits to.

@jkczyz asked in issue #5193:

> @auto-pr-bot please open a PR to fix this issue

> `UnsignedInvoiceRequest` stores normal records in `bytes` and
> experimental offer/invoice-request records in `experimental_bytes`.
> Its signing hash is computed over both buffers, and `sign` inserts
> the signature before appending `experimental_bytes` to the final
> request. However, the public `Writeable` implementation emits only
> `bytes`. A custom/HSM policy signer receiving the
> `&UnsignedInvoiceRequest` through `SignInvoiceRequestFn` and
> serializing it for review therefore sees fewer fields than it is
> being asked to authenticate. A malicious offer can carry an unknown
> odd experimental extension: the policy approves the truncated
> serialization, while the returned `InvoiceRequest` includes the
> hidden extension under the payer's valid signature. [...]

Fixes #5193, superseding #5289, an earlier standalone fix for the same
issue. The analogous fix for `UnsignedBolt12Invoice` follows in the
next commit.

Requested-by: @jkczyz
Link: https://git.rust-bitcoin.org/lightningdevkit/rust-lightning/issues/5193
Authored-By: matt/GLM-5.3-Flash-GGUF:Q4_K_XL <goose@users.noreply.local>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit fixes a bug in how unsigned invoice requests were serialized before being signed. The code previously left out experimental extra data, meaning a signer reviewing the request would not see everything their signature would later cover. A malicious offer could hide data in that experimental space, getting a valid signature on content the signer never reviewed. The fix makes the unsigned serialization include both the normal and experimental bytes.

Recommended action

Review and merge the fix; ensure the analogous `UnsignedBolt12Invoice` fix in the following commit is also merged. HSM and custom signers should upgrade to a release containing this patch and verify that their signer serialization matches the full tagged hash input.

Security signals we found

01

Signature commits to data not shown to signer (truncated serialization)

02

Experimental/unknown odd TLV records omitted from pre-signature review

03

Potential HSM/custom signer policy bypass via hidden extensions

04

Round-trip test added to detect serialization/hash mismatch

Risk score

Why this scored 72/100

Our methodology →
Potential impact 22/30
Exploitability 16/25
Stealth signal 12/15
Affected reach 10/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.