Skip to content

Commit 2626941

Browse files
authored
fix(restore-session): scrub Nostr keys from log lines (#835)
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 #834
1 parent abd9f3a commit 2626941

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/app/restore_session.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ pub async fn restore_session_action(
2626
return Err(MostroCantDo(CantDoReason::InvalidPubkey));
2727
}
2828

29-
tracing::info!(
30-
"Starting background restore session for master key: {}",
31-
master_key
32-
);
29+
// No key in the log line — master_key is the user's persistent Nostr
30+
// identity, not a per-trade ephemeral one (AGENTS.md: scrub Nostr keys
31+
// from logs).
32+
tracing::info!("Starting background restore session");
3333

3434
// Create a new manager for this specific restore session
3535
let manager = RestoreSessionManager::new();
@@ -99,7 +99,8 @@ async fn send_restore_session_response(
9999
)
100100
.await;
101101

102-
tracing::info!("Restore session response sent to user {}", trade_key,);
102+
// No key in the log line (AGENTS.md: scrub Nostr keys from logs).
103+
tracing::info!("Restore session response sent to user");
103104

104105
Ok(())
105106
}
@@ -112,7 +113,8 @@ async fn send_restore_session_timeout(trade_key: &str) -> Result<(), MostroError
112113
// Send timeout message without payload since Text doesn't exist
113114
enqueue_restore_session_msg(None, trade_pubkey).await;
114115

115-
tracing::warn!("Restore session timed out for user: {}", trade_key);
116+
// No key in the log line (AGENTS.md: scrub Nostr keys from logs).
117+
tracing::warn!("Restore session timed out for user");
116118

117119
Ok(())
118120
}

0 commit comments

Comments
 (0)