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

bolt12: cover the amount overflow guard

Public commit record

What the developer wrote

Authored by bitromortac

91/100 · Strong
bolt12: cover the amount overflow guard

The request side had a test for the offer_amount times quantity overflow, the
invoice side did not, and it was the only uncovered branch in the invoice
amount check. Verified by neutering the guard, which makes the new case accept
an invoice_amount of one against an authorized amount that wrapped to zero.

Finding F9.
https://github.com/lightningnetwork/lnd/pull/10941#discussion_r3599755895
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ 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 test to ensure that when a BOLT 12 invoice is validated against a request, the multiplication of the offer amount by the requested quantity cannot overflow and wrap around to zero. Without this guard, a malicious or malformed invoice could claim an authorized amount of zero and pass validation even though the real intended amount was huge. The actual overflow guard already exists in production code; this change only adds the missing test coverage.

Recommended action

No immediate code change is required because the guard is already present and now tested. Reviewers should verify that the overflow guard in the non-test invoice validation code uses safe multiplication (e.g., math/bits.Mul64 or a pre-check) and consider adding fuzz tests for amount arithmetic in BOLT 12.

Security signals we found

01

Integer overflow / wraparound in amount calculation

02

Missing test coverage for security-critical branch

03

BOLT 12 invoice amount validation

04

Potential acceptance of under-funded invoice if guard were absent

Risk score

Why this scored 60/100

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