rpcserver: skip log reading when include_log flag is not set
What changed, and why it matters
This change makes the GetDebugInfo RPC call read the log file only when explicitly requested via a new include_log flag. Previously, every call to GetDebugInfo would read the entire log file, which could be slow or consume memory if the log file was very large. The patch is a performance and resource-usage improvement, not a fix for a clear security vulnerability.
Treat as a routine performance improvement. If reviewing for security, verify that the include_log field defaults to false in the protobuf definition and that GetDebugInfo remains behind appropriate RPC authentication/authorization. No urgent action is indicated by the commit alone.
Security signals we found
Performance/resource-consumption hardening: avoids reading large files by default
RPC behavior change gated by a new request flag
No authentication or authorization changes visible in the diff
No input validation changes visible in the diff
Evidence from the diff
The rpcServer.GetDebugInfo handler now checks req.IncludeLog before calling os.ReadFile on the daemon’s log file. If the flag is false (the default), it returns only the flattened configuration map. This avoids unconditionally loading potentially large log files into memory and transmitting them over the RPC response. The change is purely additive behavior controlled by a request flag; there is no evidence in the diff of a vulnerability such as unauthorized log access, path traversal, or information disclosure beyond what the RPC already exposed.
Changed components
rpcserver.goGetDebugInfo RPC endpointlnrpc.GetDebugInfoRequest / GetDebugInfoResponseInspect captured patch +17 / −7
diff --git a/rpcserver.go b/rpcserver.go
index a55949f..84e2afa 100644
--- a/rpcserver.go
+++ b/rpcserver.go
@@ -3458,10 +3458,11 @@ func (r *rpcServer) GetInfo(_ context.Context,
}
// GetDebugInfo returns debug information concerning the state of the daemon
-// and its subsystems. This includes the full configuration and the latest log
-// entries from the log file.
+// and its subsystems. By default, this returns only the configuration. If the
+// `include_log` flag is set in the request, the latest log entries from the
+// log file are also included.
func (r *rpcServer) GetDebugInfo(_ context.Context,
- _ *lnrpc.GetDebugInfoRequest) (*lnrpc.GetDebugInfoResponse, error) {
+ req *lnrpc.GetDebugInfoRequest) (*lnrpc.GetDebugInfoResponse, error) {
flatConfig, _, err := configToFlatMap(*r.cfg)
if err != nil {
@@ -3469,6 +3470,16 @@ func (r *rpcServer) GetDebugInfo(_ context.Context,
"%w", err)
}
+ resp := &lnrpc.GetDebugInfoResponse{
+ Config: flatConfig,
+ }
+
+ // If the include_log flag is not set, we only return the config and
+ // skip the log file content which can be large.
+ if !req.IncludeLog {
+ return resp, nil
+ }
+
logFileName := filepath.Join(r.cfg.LogDir, defaultLogFilename)
logContent, err := os.ReadFile(logFileName)
if err != nil {
@@ -3476,10 +3487,9 @@ func (r *rpcServer) GetDebugInfo(_ context.Context,
logFileName, err)
}
- return &lnrpc.GetDebugInfoResponse{
- Config: flatConfig,
- Log: strings.Split(string(logContent), "\n"),
- }, nil
+ resp.Log = strings.Split(string(logContent), "\n")
+
+ return resp, nil
}
// GetRecoveryInfo returns a boolean indicating whether the wallet is started
Why this scored 18/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.