#2520·nanoclaw

logs/nanoclaw.log captures libsignal-node SessionEntry dumps containing privKey/rootKey/chainKey buffers

Author: participoCreated May 17, 2026Updated Sep 26, 2026

Summary

logs/nanoclaw.log accumulates Signal Protocol session key material (the privKey, rootKey, and chainKey buffers inside SessionEntry objects) on every WhatsApp session close. The leak originates in a transitive dep, but the right place to filter it is NanoClaw's host startup — see scope below.

Repro

Send/receive any WhatsApp traffic with the WhatsApp channel active, then:

bash
grep -c "privKey: <Buffer" logs/nanoclaw.log

Real numbers from one install:

  • After 25h of normal operation: 459 privKey lines
  • Each SessionEntry block also includes adjacent rootKey, chainKey, pubKey, and ephemeralKeyPair fields with their own buffers

Example fragment:

SessionEntry {
    registrationId: …,
    currentRatchet: {
        ephemeralKeyPair: { pubKey: <Buffer …>, privKey: <Buffer f0 7a 4a 4f …> },
        lastRemoteEphemeralKey: <Buffer …>,
        previousCounter: 0,
        rootKey: <Buffer …>
    },
    pendingPreKey: { signedKeyId: …, baseKey: <Buffer …>, preKeyId: … }
    …
}

Where the bug originates

@whiskeysockets/libsignal-node (the Signal Protocol JS impl that Baileys depends on transitively), specifically:

node_modules/.pnpm/libsignal@<hash>/node_modules/libsignal/src/session_record.js:273
            console.info("Closing session:", session);

Node's default behaviour serialises the full session object (including the nested key Buffers) into stdout, which launchd's StandardOutPath captures into logs/nanoclaw.log.

Why this is NanoClaw's layer to fix (not libsignal-node)

  • Baileys' rc11 release notes explicitly state libsignal-node is being deprecated for licensing reasons (GPLv3 vs Baileys' MIT): "We are working on migrating away from the libsignal dep as soon as possible to our own Rust-based equivalent to prevent licensing issues." Filing upstream with libsignal-node would land in a soon-dead codebase.
  • The captured-logs surface is NanoClaw's responsibility — the host process is what captures stdout and writes it to logs/. A consumer-side filter is the cheapest durable fix.

Threat model

  • logs/ is gitignored, so the keys don't reach git remotes by default.
  • Residual exposure: Time Machine / iCloud Drive backups of the project directory; any operator pasting log excerpts into bug reports, screenshots, or chat for debugging help (the obvious "share the last 100 lines of nanoclaw.log" instinct is currently unsafe).
  • These are ephemeral ratchet keys, not the device's long-term identity key. Compromise leaks past messages in that ratchet generation, not the whole account. Real but bounded.

Proposed fix

A small console-method patch at host startup that drops or redacts known noisy libsignal output before it hits stdout. Approximately:

typescript
// src/index.ts, very early — before anything imports baileys/libsignal
const origConsoleInfo = console.info.bind(console);
const SIGNAL_NOISE = /^(Closing session:|Session already closed|Opening session)/;
console.info = (msg: unknown, ...rest: unknown[]) => {
  if (typeof msg === 'string' && SIGNAL_NOISE.test(msg)) return;
  origConsoleInfo(msg, ...rest);
};

Alternatives the maintainers may prefer:

  1. A pino transport / stream filter wrapping stdout (more invasive, more thorough — catches future noise patterns by transform rather than match)
  2. Routing libsignal-node's console output to /dev/null if Baileys lets us inject a logger (does it?). Worth checking before going the patch route — if Baileys exposes a logger override that libsignal-node also honours, this becomes one-line config rather than a runtime patch.

The SIGNAL_NOISE regex above is intentionally narrow — matches only the noisiest lines from session_record.js. Wider matching risks dropping useful logs.

Scope of impact

Every NanoClaw install with the WhatsApp channel active accumulates this. Volume scales with WhatsApp traffic — ~450 lines/day on a low-traffic personal install, more on busier ones. Other channel adapters don't pull libsignal-node, so this is WhatsApp-specific today (though any future Signal-protocol-based channel would inherit the same surface).

Related

  • Filed in parallel to memorialising the disk-log-isn't-safe-to-share lesson in this fork's napkin.
  • Same incident class as #2370 (silent attachments mount gap) and #2381 (silent agent-runner dep drift) — defensive workaround for an upstream behaviour, owned by the NanoClaw layer because that's where the captured stdout lands.

Happy to test a candidate fix.