fix: audit follow-up — keystore 0600 + key_bytes zeroize + prom-exporter doc/warn#761
Conversation
|
Warning Review limit reached
More reviews will be available in 50 minutes and 36 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
Follow-up to the workspace-wide audit pass. Each finding here was re-verified against current code (per operator's "yakin kan?") before fixing. Four real defects, no theoretical ones.
Findings + fixes
sentrix-wallet (security — defense in depth)
1.
Keystore::savewrote keystore with default umask (0644 on most hosts) → world-readable file.Even with AES-GCM ciphertext over an Argon2id-derived key, leaking the file's ciphertext + salt + MAC to a co-tenant user enables offline brute-force against the password. Fix: explicit `set_permissions(0o600)` after the write on Unix. Windows keeps the default — ACL hardening is the operator's responsibility.
Added `test_save_file_mode_is_0600` so a future edit that drops the chmod fails CI.
2. Derived KDF key + plaintext private key bytes were never zeroized.
encrypt/decrypt/ the wrong-password early-return path all allocated `[u8; 32]` for the Argon2id-derived AES-GCM key on stack and left it there until the frame unwound. A core dump or post-free memory inspection could still recover the AES key (and the second-half MAC key sliced from it). Fix: `zeroize::Zeroize::zeroize()` on:The `zeroize` crate was already in workspace deps (used by other crates).
sentrix-prom-exporter (correctness + observability)
3. Module doc said "first 4 hex of latest_block_hash as u32" — actual code consumes 8 hex chars.
Code at line 222 (`if h.len() < 8`) + test asserting `0xdeadbeef` (8 chars → u32) + the metric-registration doc string at line 89 all agree on 8. Module doc line 15 was stale. Fix: update to "first 8 hex".
4. `parse_targets` silently dropped malformed `SENTRIX_TARGETS` entries.
Operator that misconfigured the env var would see the exporter run with fewer (or zero) targets and no log indication why the Grafana dashboard went dark. Fix: `warn!` on the dropped entry with the bad input + observed part count.
Self-review (per
feedback_smoke_test_and_code_review_every_change)Downgraded / not in this PR
These were initially flagged in the audit but downgraded after re-verification:
These are notes for a future hardening pass, not real defects today.
Found via
Operator-requested audit pass against workspace crates one at a time. Faucet cooldown TOCTOU (separate PR #760) was the first real bug; these are the next four after re-verifying the rest.