[bug]: zpay32.Decode wraps an invoice amount that overflows uint64
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
- #11441 di @Reacher3745 — chiusa senza merge
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 79/100
Direzione di ricerca
Inizia dai punti di moltiplicazione in zpay32/amountunits.go alle righe 30–43 e 99–105, poi esegui la riproduzione fornita TestAmountWrap con go test ./zpay32 -run TestAmountWrap -v. Verifica che zpay32.Decode rifiuti una fattura quando la conversione del suo importo causerebbe un overflow di uint64; il lavoro è concluso quando la riproduzione restituisce un errore invece di un valore MilliSat con overflow.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Pre-Submission Checklist
- I have searched the existing issues and believe this is a new bug.
- I am not asking a question about how to use lnd, but reporting a bug (otherwise open a discussion).
LND Version
master at 1a359d4aa1e5, v0.21.4-beta at 390b2d2b7bdc, and v0.20.5-beta at cfa58463aedc
LND Configuration
None. The test below runs with go test in the lnd source tree at each version above.
Backend Version
Not used. The test runs with go test only.
Backend Configuration
None.
OS/Distribution
Fedora Linux 44, x86_64, with Go 1.26.10 for master and Go 1.26.9 for the releases
Bug Details & Steps to Reproduce
zpay32.Decode accepts the invoice below and returns a MilliSat of 90,448,384 msat. Its amount, 184467440738m, is 18,446,744,073,800,000,000 msat, and 90,448,384 msat is that product modulo 2^64. The payment intent that SendPaymentV2 builds for this invoice carries 90,448,384 msat as its amount. This happens on master at 1a359d4aa1e5, v0.21.4-beta and v0.20.5-beta.
Saved as zpay32/amount_wrap_test.go on master, this test decodes the invoice, which is signed with the private key from the BOLT 11 examples:
package zpay32
import (
"testing"
"github.com/btcsuite/btcd/chaincfg/v2"
)
func TestAmountWrap(t *testing.T) {
inv, err := Decode("lnbc184467440738m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9qrsgqujcur0j9f47men4nlh79jjnav8799h55ufx3dyhec962ctkpv6u8dz9j36avrfwph0f0l562f05a769wkdkpqe3wkpre66ea5udgfqcpm5v6f3", &chaincfg.MainNetParams)
if err == nil {
t.Fatalf("expected error, got MilliSat: %v", *inv.MilliSat)
}
}
With go test ./zpay32 -run TestAmountWrap -v, the test fails:
=== RUN TestAmountWrap
amount_wrap_test.go:12: expected error, got MilliSat: 90448384 mSAT
--- FAIL: TestAmountWrap (0.00s)
zpay32 multiplies the amount by its multiplier in a uint64 without an overflow check. The products are at zpay32/amountunits.go:30-43 for m, u and n, and at zpay32/amountunits.go:99-105 when there is no multiplier.
Expected Behavior
zpay32.Decode should return an error for this invoice, because 18,446,744,073,800,000,000 msat does not fit in a uint64. BOLT 11 says at lines 83-85 that a reader "MUST multiply amount by the multiplier value to derive the amount required for payment".
Debug Information
No response
Environment
No response
- Lingua principale
- Go
- Stelle
- 8.2k
- Fork
- 2.3k
- Merge medio
- 1g 11h
- PR unite (30g)
- 103
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di lightningnetwork/lnd
-
funding: failure logs print `<nil>` error and zero channel IDForse già presa @litbot-9000 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
lightningnetwork/lnd#11676 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 85/100
lightningnetwork/lnd#11674 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
lightningnetwork/lnd#11672 ·
I maintainer di solito rispondono entro 1 giorno
-
test flake
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
lightningnetwork/lnd#11663 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[flake]: lnwallet/test/bitcoind.TestLightningWalletBitcoindRPCPolling/spend_unconfirmed_outputsApertatest flake
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
lightningnetwork/lnd#11642 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di lightningnetwork/lnd
Issue simili
-
ConcatAgenticMessages loses the approval request ID of a streamed MCP tool callForse già presa @ningsiyuan1024 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
containers/gvisor-tap-vsock#796 ·
I maintainer di solito rispondono entro 2 giorni
-
external needs:triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
celestiaorg/celestia-node#5448 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Azure SAS signing uses local time instead of UTC, shifting validity window on non-UTC hostsForse già presa @huanghaoyuanhhy l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
zilliztech/milvus-backup#1418 ·
I maintainer di solito rispondono entro 1 giorno