What changed, and why it matters
This change is a hardening patch, not an active exploit fix. LND removed two protobuf fields that let callers request timed output leases. Older clients still send those field numbers over the wire as 'unknown' protobuf data, so the server would silently ignore them and create a different kind of lease than the client expected. The patch now detects those retired field numbers in LeaseOutput and FundPsbt and returns an explicit error instead of silently falling through. The main risk is operational: an old client or script that relied on the removed fields will now fail fast rather than silently changing behavior.
Treat as a defensive hardening commit. Review release notes for any client compatibility guidance, ensure callers using LeaseOutput or FundPsbt have migrated to no_expiry / input_lease_no_expiry, and consider whether any integrations depend on the retired fields. No emergency deployment is indicated by the diff alone.
Security signals we found
Behavioral change from silent ignore to explicit error for deprecated protobuf fields
Prevention of unintended lease semantics when old clients send removed parameters
Uses protobuf unknown-field parsing to avoid re-adding retired fields to the public schema
Adds unit tests covering both affected handlers with stable error identity
Evidence from the diff
The commit adds rejectRetiredLeaseSpendConfs, which scans preserved protobuf unknown fields for retired field numbers (4 in LeaseOutputRequest, 15 in FundPsbtRequest) using protowire.ConsumeField. If the retired release_after_spend_confs / input_release_after_spend_confs fields are present, the handler returns errLeaseSpendConfsUnsupported before any wallet logic runs. Tests verify both LeaseOutput and FundPsbt reject crafted old-style wire payloads. The patch keeps the existing wallet lifetime implementation intact and only changes RPC-layer validation.
Changed components
lnrpc/walletrpc/walletkit_server.golnrpc/walletrpc/walletkit_server_test.goWalletKit.LeaseOutput RPC handlerWalletKit.FundPsbt RPC handlerInspect captured patch +77 / −0
### lnrpc/walletrpc/walletkit_server.go
@@ -49,6 +49,7 @@ import (
"github.com/lightningnetwork/lnd/macaroons"
"github.com/lightningnetwork/lnd/sweep"
"google.golang.org/grpc"
+ "google.golang.org/protobuf/encoding/protowire"
"gopkg.in/macaroon-bakery.v2/bakery"
)
@@ -57,6 +58,14 @@ import (
const noExpiryLeaseDepth uint32 = 1
var (
+ // errLeaseSpendConfsUnsupported prevents retired request parameters
+ // from silently choosing timed leases after their fields were removed.
+ errLeaseSpendConfsUnsupported = errors.New(
+ "release_after_spend_confs and " +
+ "input_release_after_spend_confs are no longer " +
+ "supported; use no_expiry or input_lease_no_expiry",
+ )
+
// errLeaseLifetimeConflict gives both handlers a stable identity for
// no-expiry requests that also select a competing duration.
errLeaseLifetimeConflict = errors.New("no-expiry cannot be combined " +
@@ -509,6 +518,14 @@ func (w *WalletKit) ListUnspent(ctx context.Context,
func (w *WalletKit) LeaseOutput(ctx context.Context,
req *LeaseOutputRequest) (*LeaseOutputResponse, error) {
+ // Older clients still send reserved field 4 as unknown protobuf data.
+ // Fail before an unsupported policy can fall through to a timed lease.
+ if err := rejectRetiredLeaseSpendConfs(
+ req.ProtoReflect().GetUnknown(), 4,
+ ); err != nil {
+ return nil, err
+ }
+
if len(req.Id) != 32 {
return nil, errors.New("id must be 32 random bytes")
}
@@ -598,6 +615,27 @@ func (w *WalletKit) LeaseOutput(ctx context.Context,
}, nil
}
+// rejectRetiredLeaseSpendConfs checks preserved protobuf data for a removed
+// lifetime request so older clients receive an explicit migration error.
+func rejectRetiredLeaseSpendConfs(unknown []byte,
+ retiredField protowire.Number) error {
+
+ // Consume complete encoded fields using the codec's framing rules;
+ // unrelated unknown fields must not select or invalidate a lifetime.
+ for len(unknown) > 0 {
+ number, _, n := protowire.ConsumeField(unknown)
+ if n < 0 {
+ return protowire.ParseError(n)
+ }
+ if number == retiredField {
+ return errLeaseSpendConfsUnsupported
+ }
+ unknown = unknown[n:]
+ }
+
+ return nil
+}
+
// storedLeaseDepth returns the wallet lifetime of an existing lease owned by
// lockID so a renewal can acknowledge a preserved no-expiry reservation.
func storedLeaseDepth(wallet lnwallet.WalletController, lockID wtxmgr.LockID,
@@ -1729,6 +1767,14 @@ func (w *WalletKit) LabelTransaction(ctx context.Context,
func (w *WalletKit) FundPsbt(_ context.Context,
req *FundPsbtRequest) (*FundPsbtResponse, error) {
+ // The removed input policy still arrives under field 15 from old
+ // protobuf clients. Reject it before funding can acquire timed leases.
+ if err := rejectRetiredLeaseSpendConfs(
+ req.ProtoReflect().GetUnknown(), 15,
+ ); err != nil {
+ return nil, err
+ }
+
// Normalize the explicit no-timeout option once so every funding mode
// uses the existing capability, owner checks, and acquisition rollback.
var releaseAfterSpendConfs uint32
### lnrpc/walletrpc/walletkit_server_test.go
@@ -28,6 +28,8 @@ import (
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
testifymock "github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
+ "google.golang.org/protobuf/encoding/protowire"
+ "google.golang.org/protobuf/proto"
)
// TestMarshallLeasesIncludesSpendProgress verifies that lease responses
@@ -235,6 +237,35 @@ func TestLeaseOutputRejectsNoExpiryConflicts(t *testing.T) {
require.ErrorIs(t, fundErr, errLeaseLifetimeConflict)
}
+// TestLeaseOutputRejectsRetiredSpendConfs verifies old protobuf requests
+// fail explicitly at both lease entry points instead of selecting timed locks.
+func TestLeaseOutputRejectsRetiredSpendConfs(t *testing.T) {
+ t.Parallel()
+
+ // Arrange the old count value at each retired wire number. Ordinary
+ // decoding retains these bytes even though the fields are now reserved;
+ // no wallet is configured: rejection must need no acquisition.
+ leaseReq := &LeaseOutputRequest{}
+ leaseWire := protowire.AppendTag(nil, 4, protowire.VarintType)
+ leaseWire = protowire.AppendVarint(leaseWire, 3)
+ require.NoError(t, proto.Unmarshal(leaseWire, leaseReq))
+ fundReq := &FundPsbtRequest{}
+ fundWire := protowire.AppendTag(nil, 15, protowire.VarintType)
+ fundWire = protowire.AppendVarint(fundWire, 3)
+ require.NoError(t, proto.Unmarshal(fundWire, fundReq))
+ server := &WalletKit{cfg: &Config{}}
+
+ // Act through both public handlers with the decoded old requests, as
+ // gRPC would deliver them from clients using the removed parameters.
+ _, leaseErr := server.LeaseOutput(t.Context(), leaseReq)
+ _, fundErr := server.FundPsbt(t.Context(), fundReq)
+
+ // Assert the shared migration error before other validation or wallet
+ // work; error identity keeps this independent of diagnostic wording.
+ require.ErrorIs(t, leaseErr, errLeaseSpendConfsUnsupported)
+ require.ErrorIs(t, fundErr, errLeaseSpendConfsUnsupported)
+}
+
// WithCoinSelectLock runs the callback and optionally returns a test error.
func (m *mockCoinSelectionLocker) WithCoinSelectLock(f func() error) error {
if err := f(); err != nil {Why this scored 48/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.