fix(restore-session): scrub Nostr keys from log lines#835
Conversation
master_key/trade_key were logged verbatim in 3 tracing calls, violating AGENTS.md's "scrub logs that might leak invoices or Nostr keys" guideline. master_key in particular is the user's persistent Nostr identity, not a per-trade ephemeral key — if these info/warn logs reach an external aggregator, anyone with log access could correlate "this identity restored a session at this timestamp" in cleartext. Closes MostroP2P#834
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughRestore-session logging was updated to remove ChangesRestore-session logging
Estimated code review effort: 1 (Trivial) | ~3 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@grunch what do you think? We can remove that printout of keys I suppose. It's a good practise also in the restore case imo. |
Problem
AGENTS.md:48says: "Scrub logs that might leak invoices or Nostr keys; rotate secrets promptly if exposed."src/app/restore_session.rsloggedmaster_key/trade_keyverbatim in 3 places (tracing::info!/tracing::warn!).master_keyin particular is the user's persistent Nostr identity, not a per-trade ephemeral key — every successful restore-session request hits this path in production (the hex-format validation guards always pass for realPublicKeyvalues, so this isn't a rare branch). If these logs reach an external aggregator, anyone with log access can correlate "this identity restored a session at this timestamp" in cleartext.Solution
Dropped the key from all 3 log lines. The surrounding message (action + outcome) is still useful for debugging without the identifying value.
Tests
No test asserted on log content before or after — the fix only removes an interpolated value from 3
tracingmacro calls, no behavior change. Full suite still green:cargo test1019/1020 passing (the 1 failure is a pre-existing, unrelated local-environment issue — a fixed-port test server colliding with something already bound to :8080, same as on other recent PRs).cargo fmt --checkandcargo clippy --all-targets --all-features -- -D warningsboth clean.Closes #834
Summary by CodeRabbit