Skip to content

lightningd: log entry allocation and getlog output (v26.06.7 security, 5/7) - #9511

Merged
nGoline merged 5 commits into
ElementsProject:masterfrom
nGoline:port-26.06.7-logging
Sep 15, 2026
Merged

nGoline merged 5 commits into
ElementsProject:masterfrom
nGoline:port-26.06.7-logging

Conversation

@nGoline

@nGoline nGoline commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Fifth of seven PRs forward-porting the v26.06.7 security point release onto master.

Log entry allocation, and what getlog is allowed to return.

5 commits:

  • tests: check getlog does not return io logs
  • lightningd: don't return io logs from getlog
  • tests: don't use io logs for commando's oversized reply
  • lightningd: don't allocate huge log entries on the stack
  • tests: huge log entries don't crash lightningd

One Changelog-Fixed, logging a very large message no longer crashes the node, and one Changelog-Changed, getlog no longer accepts level=io; io logs remain available in the log file via --log-level=io.

For reviewers

This is 5 commits, not the 6 in the release. lightningd: don't free() a tal pointer when a log entry is truncated is not ported, because master already has the property it restores, by a different implementation. On the release line logv() built its message with vasprintf() and called free() on the pointer cap_header() had already replaced with tal memory. Master's logv() uses tal_vfmt() throughout and passes cap_header(tmpctx, &l, take(logmsg)), whose signature is TAKES and which always returns a fresh tal allocation, and the function ends in tal_free(logmsg) with no free() anywhere. There is no malloc pointer to lose. Its regression test is ported and passes.

contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py is regenerated rather than merged, since removing io from the getlog request enum changes the serialised descriptor. The regeneration is folded into the commit that changes cln-grpc/proto/node.proto, so no commit leaves the generated file inconsistent with its source.

nGoline and others added 5 commits September 15, 2026 18:28
The io level of the log book holds raw JSON-RPC and plugin traffic,
which can contain secrets such as runes.  Marked xfail until the next
commit.

(cherry picked from commit 03be4d7)
The io level of the log book holds the raw JSON-RPC and plugin traffic,
which can contain secrets such as runes, and getlog returns the whole
log book to its caller.  Refuse level=io there: io logging remains
available in the log file, via --log-level=io.

Changelog-Changed: JSON-RPC: `getlog` no longer accepts `level=io`; io logs are only available in the log file (`--log-level=io`).
(cherry picked from commit e05c572)
test_commando needs a reply over 65535 bytes to exercise commando's
multi-message split, and used getlog level=io to get one.  getlog no
longer serves that level, so read back a 100k datastore entry instead.

(cherry picked from commit 9373b5f)
log_to_files() sized a stack VLA by the log string's length.  Callers
can log attacker-controlled strings of arbitrary size - e.g. clnrest
logging unauthenticated request parameters on rune failure - so a
single ~10MB HTTP request overflowed the stack and crashed lightningd
(SIGSEGV).

Use a fixed 1kB stack buffer for normal entries and a heap allocation
for oversized ones.

Changelog-Fixed: lightningd: logging a very large message no longer crashes the node (stack overflow).

Reported-by: Vincenzo Palazzo (Bitcoin Security Council finding 2026-08-10)
(cherry picked from commit cc90f6b)
Drive log_to_files() directly with an entry far larger than any stack buffer,
using a plugin which emits one on demand.

Nothing bounds a log entry, so testing this through clnrest is the wrong shape:
requests are now capped at 2MiB before any parameter is parsed, so an oversized
request is rejected long before it can reach the logger, and a test written that
way passes whether or not the daemon is fixed.  A plugin can hand us an entry of
any size, which is what we actually want to exercise.

(cherry picked from commit 50910c9)
@nGoline
nGoline force-pushed the port-26.06.7-logging branch from aa46443 to bfe3a06 Compare September 15, 2026 21:30
@nGoline
nGoline merged commit 7a05b8f into ElementsProject:master Sep 15, 2026
2 of 3 checks passed
@nGoline
nGoline deleted the port-26.06.7-logging branch September 15, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants