fix(chat,rpc): address adversarial review of the chat backlog
Four confirmed findings from the review pass: SECURITY — B7 was incomplete: - The single-key Export dialog (key_export_dialog) still used plain call() for z_exportkey/dumpprivkey/z_exportviewingkey — a live spending-key leak on the most common per-address export path, missed by the B7 commit. - callSecret() zeros the raw body but the parsed json holds its OWN heap copy of the secret; several callers did .get<string>() on a temporary json and freed that copy un-wiped. Fix: add RPCClient::callSecretString() — returns the bare-string result with BOTH the raw body AND the json node zeroed, so callers can't forget. Route key_export_dialog (×2), exportPrivateKey, and export_all_keys (×2) through it; scrub the z_exportmnemonic json node in seed_wallet_creator (object result); also wipe the transient key copies, the displayed s_key on reset, and the aggregated export-all `keys` buffer. CHAT: - Jump-to-latest pill: SetCursorScreenPos moved the parent cursor and never restored it, so the composer footer rendered ~8px too high while scrolled up. Save + restore the cursor around the pill. - New-message toast: gating on a chatUnreadCount() watermark delta could be swallowed when an outgoing echo (wall-clock) pushed the seen-watermark past a later reply's block time. ingest() now reports the cids it appended; the toast fires when any is a non-muted conversation — skew-proof, still mute-aware. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "export_all_keys_dialog.h"
|
||||
#include "../../app.h"
|
||||
#include <sodium.h> // sodium_memzero — wipe exported key material from memory (B7)
|
||||
#include "../../rpc/rpc_client.h"
|
||||
#include "../../rpc/rpc_worker.h"
|
||||
#include "../../util/i18n.h"
|
||||
@@ -180,13 +181,12 @@ void ExportAllKeysDialog::render(App* app)
|
||||
for (const auto& addr : z_addrs) {
|
||||
try {
|
||||
rpc::RPCClient::TraceScope trace("Settings / Export all keys");
|
||||
auto result = rpc->callSecret("z_exportkey", {addr}); // zero the raw body too (B7)
|
||||
if (result.is_string()) {
|
||||
keys += "# Address: " + addr + "\n";
|
||||
keys += result.get<std::string>() + "\n\n";
|
||||
exported++; // count only real successes (locked/failed keys don't count)
|
||||
}
|
||||
} catch (...) {}
|
||||
std::string k = rpc->callSecretString("z_exportkey", {addr}); // scrubs raw body + json node (B7)
|
||||
keys += "# Address: " + addr + "\n";
|
||||
keys += k + "\n\n";
|
||||
exported++; // count only real successes (locked/failed keys don't count)
|
||||
if (!k.empty()) sodium_memzero(&k[0], k.size()); // wipe the transient copy
|
||||
} catch (...) {} // non-string / locked key → skip (not counted)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,13 +196,12 @@ void ExportAllKeysDialog::render(App* app)
|
||||
for (const auto& addr : t_addrs) {
|
||||
try {
|
||||
rpc::RPCClient::TraceScope trace("Settings / Export all keys");
|
||||
auto result = rpc->callSecret("dumpprivkey", {addr}); // zero the raw body too (B7)
|
||||
if (result.is_string()) {
|
||||
keys += "# Address: " + addr + "\n";
|
||||
keys += result.get<std::string>() + "\n\n";
|
||||
exported++; // count only real successes (locked/failed keys don't count)
|
||||
}
|
||||
} catch (...) {}
|
||||
std::string k = rpc->callSecretString("dumpprivkey", {addr}); // scrubs raw body + json node (B7)
|
||||
keys += "# Address: " + addr + "\n";
|
||||
keys += k + "\n\n";
|
||||
exported++; // count only real successes (locked/failed keys don't count)
|
||||
if (!k.empty()) sodium_memzero(&k[0], k.size()); // wipe the transient copy
|
||||
} catch (...) {} // non-string / locked key → skip (not counted)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,6 +218,7 @@ void ExportAllKeysDialog::render(App* app)
|
||||
writeOk = true;
|
||||
}
|
||||
}
|
||||
if (!keys.empty()) sodium_memzero(&keys[0], keys.size()); // don't leave every key in freed heap
|
||||
|
||||
return [exported, total, filepath, writeOk]() {
|
||||
s_exported_count = exported;
|
||||
|
||||
Reference in New Issue
Block a user