Redact UnifiedPush identifiers in logs#30
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
WalkthroughUnifiedPushService now generates a per-instance random salt and uses salted BLAKE3 hashing to redact device identifiers in logs. Registration, unregistration, and notification log messages are updated to use this redaction. Documentation explicitly states the privacy guarantee: raw device IDs and endpoint prefixes are excluded from server logs. ChangesDevice ID Redaction for Privacy
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/push/unifiedpush.rs (1)
166-176:⚠️ Potential issue | 🟠 Major | ⚡ Quick winDrop or sanitize the remote response body from this error log.
Line 176 still logs
response.text()verbatim. Since UnifiedPush endpoints are attacker-controlled, a failing endpoint can echo the endpoint URL or other identifiers back intoerror_text, which puts the privacy guarantee from this PR back at risk.Suggested fix
- let error_text = response.text().await.unwrap_or_default(); - error!("UnifiedPush error: {} - {}", status, error_text); + let _ = response.text().await; + error!("UnifiedPush error: {}", status);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/push/unifiedpush.rs` around lines 166 - 176, The error log currently includes the full remote response body (response.text()/error_text) and may also echo attacker-controlled identifiers like device_token; update the UnifiedPush failure path (the code around self.client.post(device_token)... handling the response variable) to stop logging the raw response body: either omit error_text entirely from error!("UnifiedPush error: ..."), or replace it with a sanitized/trimmed excerpt (e.g., limit to N characters, remove URLs/identifiers, or replace with a fixed "<remote-response-suppressed>" token) and ensure device_token or payload contents are not logged; keep the status code in the log for diagnostics.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/push/unifiedpush.rs`:
- Around line 166-176: The error log currently includes the full remote response
body (response.text()/error_text) and may also echo attacker-controlled
identifiers like device_token; update the UnifiedPush failure path (the code
around self.client.post(device_token)... handling the response variable) to stop
logging the raw response body: either omit error_text entirely from
error!("UnifiedPush error: ..."), or replace it with a sanitized/trimmed excerpt
(e.g., limit to N characters, remove URLs/identifiers, or replace with a fixed
"<remote-response-suppressed>" token) and ensure device_token or payload
contents are not logged; keep the status code in the log for diagnostics.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a7220e06-92e7-4d2d-a43e-45406959fafd
📒 Files selected for processing (2)
docs/unifiedpush.mdsrc/push/unifiedpush.rs
AndreaDiazCorreia
left a comment
There was a problem hiding this comment.
Nice work on the redaction. One change request before merging: please reuse the existing notify_log_salt from src/main.rs instead of generating a new salt inside UnifiedPushService::new(). You can pass it through the constructor (UnifiedPushService::new(config, client, log_salt)), the same way it is already injected into TokenStore, the Nostr listener and AppState. The original issue asked for the same salt and algorithm as log_pubkey, and sharing the process-wide salt keeps a single source of randomness and matches the pattern already used in the rest of the codebase.
Summary
Privacy validation
Source/sink/control: UnifiedPush device_id and endpoint URL values reached operator logs in src/push/unifiedpush.rs. Registration and unregistration now log only a salted 8-hex correlator using the same helper as pubkey logging, and send_to_token no longer logs any endpoint prefix.
Original issue no longer reproduces:
Refs #14
Tests
Summary by CodeRabbit
Release Notes