Merge pull request #10708 from jtobin/alias-perms
What changed, and why it matters
This commit fixes a missing permission check on a new Lightning routing RPC called XFindBaseLocalChanAlias. Without the entry, any valid macaroon could call that RPC, bypassing the normal access-control list. The patch adds the required permission and a regression test that ensures every Router RPC has a matching permission entry.
Review the permissions assigned to XFindBaseLocalChanAlias to confirm "offchain:read" is the least-privilege requirement. Ensure the new regression test passes in CI and consider applying the same coverage test to other gRPC services.
Security signals we found
Missing macaroon authorization entry for an RPC endpoint
Potential privilege escalation: any valid macaroon could invoke an unprotected RPC
Regression test added to enforce macPermissions coverage
Evidence from the diff
The change adds “/routerrpc.Router/XFindBaseLocalChanAlias” to the macPermissions map in lnrpc/routerrpc/router_server.go with Entity “offchain” and Action “read”. It also adds TestMacPermissionsCoverage, which verifies that macPermissions contains exactly the RPCs declared in Router_ServiceDesc and that each entry has at least one operation. This prevents future RPCs from being added without corresponding macaroon authorization rules.
Changed components
lnrpc/routerrpc/router_server.golnrpc/routerrpc/router_server_test.gorouterrpc.Router/XFindBaseLocalChanAlias RPCInspect captured patch +35 / −0
### lnrpc/routerrpc/router_server.go
@@ -156,6 +156,10 @@ var (
Entity: "offchain",
Action: "write",
}},
+ "/routerrpc.Router/XFindBaseLocalChanAlias": {{
+ Entity: "offchain",
+ Action: "read",
+ }},
"/routerrpc.Router/DeleteForwardingHistory": {{
Entity: "offchain",
Action: "write",
### lnrpc/routerrpc/router_server_test.go
@@ -3,6 +3,8 @@ package routerrpc
import (
"bytes"
"context"
+ "maps"
+ "slices"
"testing"
"time"
@@ -901,3 +903,32 @@ func TestProbePaymentRequestUsesUniqueHashPerLSP(t *testing.T) {
require.Contains(t, probedDests, eveVertex)
require.Contains(t, probedDests, daveVertex)
}
+
+// TestMacPermissionsCoverage checks that macPermissions has an entry for
+// exactly the RPCs of the Router service, as listed in its generated service
+// descriptor, and that each entry requires at least one permission. An RPC
+// without an entry is rejected outright by the macaroon interceptor, an entry
+// without an RPC is stale or misspelt, and an empty entry would accept any
+// valid macaroon.
+func TestMacPermissionsCoverage(t *testing.T) {
+ t.Parallel()
+
+ prefix := "/" + Router_ServiceDesc.ServiceName + "/"
+
+ var rpcs []string
+ for _, method := range Router_ServiceDesc.Methods {
+ rpcs = append(rpcs, prefix+method.MethodName)
+ }
+ for _, stream := range Router_ServiceDesc.Streams {
+ rpcs = append(rpcs, prefix+stream.StreamName)
+ }
+
+ require.ElementsMatch(
+ t, rpcs, slices.Collect(maps.Keys(macPermissions)),
+ "Router RPCs (A) and macPermissions entries (B) differ",
+ )
+
+ for method, ops := range macPermissions {
+ require.NotEmpty(t, ops, "%s requires no permissions", method)
+ }
+}Why this scored 51/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.