Skip to content

fix(restore-session): scrub Nostr keys from log lines#835

Open
ToRyVand wants to merge 1 commit into
MostroP2P:mainfrom
ToRyVand:fix/834-scrub-nostr-keys-from-logs
Open

fix(restore-session): scrub Nostr keys from log lines#835
ToRyVand wants to merge 1 commit into
MostroP2P:mainfrom
ToRyVand:fix/834-scrub-nostr-keys-from-logs

Conversation

@ToRyVand

@ToRyVand ToRyVand commented Jul 21, 2026

Copy link
Copy Markdown

Problem

AGENTS.md:48 says: "Scrub logs that might leak invoices or Nostr keys; rotate secrets promptly if exposed."

src/app/restore_session.rs logged master_key/trade_key verbatim in 3 places (tracing::info!/tracing::warn!). master_key in 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 real PublicKey values, 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 tracing macro calls, no behavior change. Full suite still green: cargo test 1019/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 --check and cargo clippy --all-targets --all-features -- -D warnings both clean.

Closes #834

Summary by CodeRabbit

  • Bug Fixes
    • Removed sensitive key information from restore-session logs.
    • Restore-session processing and error handling remain unchanged.

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
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8f1882c4-ecbb-460d-8f6e-a43cf4ec4353

📥 Commits

Reviewing files that changed from the base of the PR and between 57b8ff5 and 055b5f4.

📒 Files selected for processing (1)
  • src/app/restore_session.rs

Walkthrough

Restore-session logging was updated to remove master_key and trade_key values from start, response, and timeout messages. Session processing, message handling, and error behavior are unchanged.

Changes

Restore-session logging

Layer / File(s) Summary
Scrub restore-session logs
src/app/restore_session.rs
Restore start, response-sent, and timeout logs no longer include Nostr key values and include log-scrubbing notes.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

  • MostroP2P/mostro#826: Both changes touch src/app/restore_session.rs, including restore-session validation and logging-related code.

Suggested reviewers: grunch

Poem

I’m a rabbit with keys tucked away,
No secrets in logs at the end of the day.
Restore starts clean,
Responses stay serene,
Timeout trails safely hop away.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: removing Nostr keys from restore-session logs.
Linked Issues check ✅ Passed The PR removes all three cleartext key logs required by issue #834 and leaves behavior unchanged.
Out of Scope Changes check ✅ Passed No unrelated code changes are described; the patch stays focused on log scrubbing in restore_session.rs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@arkanoider

Copy link
Copy Markdown
Collaborator

@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.

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.

Nostr keys logged in cleartext in restore_session.rs (violates AGENTS.md log-scrubbing guideline)

2 participants