What changed, and why it matters
This commit fixes places where sensitive secret data (private key material and one-time derivation scalars) was left in memory after use instead of being securely erased. In three files, the patch adds explicit memory wipes or switches a temporary buffer to a locked, auto-scrubbing container. If an attacker could read the process's memory or capture a core dump, leftover secret values could leak. The patch is defensive and partial—it addresses additional cases beyond an earlier fix, suggesting the project is still finding spots that were missed.
Treat as a security-hardening fix with defensive value. Review whether all other secret-holding local variables in these call paths are wiped, and consider static analysis or code review for remaining missing memwipe() sites. No immediate emergency response is indicated because exploitation requires memory-read access, but the fix should be included in releases promptly.
Security signals we found
Adds memwipe() for secret scalars after cryptographic use
Replaces stack buffer with mlocked+scrubbed container for subaddress secret derivation input
Wipes Borromean signature ai nonces after proof generation
Commit message frames change as 'fix more cases of missing memory wipes', implying prior incomplete remediation
Touches private-key derivation paths in crypto.cpp and device_default.cpp
Evidence from the diff
The diff adds memwipe() calls for local scalar variables in crypto::derive_public_key, derive_secret_key, and derive_subaddress_public_key (src/crypto/crypto.cpp), and for the Borromean ai array in proveRange (src/ringct/rctSigs.cpp). It also replaces a stack-allocated char buffer in device_default::get_subaddress_secret_key with an epee::mlocked<tools::scrubbed<std::array<…>>> container, which both locks the page from swap and scrubs it on destruction. These are cleanup fixes for sensitive intermediate values; they reduce the window where secrets remain in RAM and may be paged to swap or retained in freed stack frames.
Changed components
src/crypto/crypto.cppsrc/device/device_default.cppsrc/ringct/rctSigs.cppInspect captured patch +10 / −6
### src/crypto/crypto.cpp
@@ -295,6 +295,7 @@ namespace crypto {
ge_add(&point4, &point1, &point3);
ge_p1p1_to_p2(&point5, &point4);
ge_tobytes(&derived_key, &point5);
+ memwipe(&scalar, sizeof(scalar));
return true;
}
@@ -304,6 +305,7 @@ namespace crypto {
assert(sc_check(&base) == 0);
derivation_to_scalar(derivation, output_index, scalar);
sc_add(&unwrap(derived_key), &unwrap(base), &scalar);
+ memwipe(&scalar, sizeof(scalar));
}
bool crypto_ops::derive_subaddress_public_key(const public_key &out_key, const key_derivation &derivation, std::size_t output_index, public_key &derived_key) {
@@ -322,6 +324,7 @@ namespace crypto {
ge_sub(&point4, &point1, &point3);
ge_p1p1_to_p2(&point5, &point4);
ge_tobytes(&derived_key, &point5);
+ memwipe(&scalar, sizeof(scalar));
return true;
}
### src/device/device_default.cpp
@@ -209,15 +209,15 @@ namespace hw {
}
crypto::secret_key device_default::get_subaddress_secret_key(const crypto::secret_key &a, const cryptonote::subaddress_index &index) {
- char data[sizeof(config::HASH_KEY_SUBADDRESS) + sizeof(crypto::secret_key) + 2 * sizeof(uint32_t)];
- memcpy(data, config::HASH_KEY_SUBADDRESS, sizeof(config::HASH_KEY_SUBADDRESS));
- memcpy(data + sizeof(config::HASH_KEY_SUBADDRESS), &a, sizeof(crypto::secret_key));
+ epee::mlocked<tools::scrubbed<std::array<char, sizeof(config::HASH_KEY_SUBADDRESS) + sizeof(crypto::secret_key) + 2 * sizeof(uint32_t)>>> data;
+ memcpy(data.data(), config::HASH_KEY_SUBADDRESS, sizeof(config::HASH_KEY_SUBADDRESS));
+ memcpy(data.data() + sizeof(config::HASH_KEY_SUBADDRESS), &a, sizeof(crypto::secret_key));
uint32_t idx = SWAP32LE(index.major);
- memcpy(data + sizeof(config::HASH_KEY_SUBADDRESS) + sizeof(crypto::secret_key), &idx, sizeof(uint32_t));
+ memcpy(data.data() + sizeof(config::HASH_KEY_SUBADDRESS) + sizeof(crypto::secret_key), &idx, sizeof(uint32_t));
idx = SWAP32LE(index.minor);
- memcpy(data + sizeof(config::HASH_KEY_SUBADDRESS) + sizeof(crypto::secret_key) + sizeof(uint32_t), &idx, sizeof(uint32_t));
+ memcpy(data.data() + sizeof(config::HASH_KEY_SUBADDRESS) + sizeof(crypto::secret_key) + sizeof(uint32_t), &idx, sizeof(uint32_t));
crypto::secret_key m;
- crypto::hash_to_scalar(data, sizeof(data), m);
+ crypto::hash_to_scalar(data.data(), sizeof(data), m);
return m;
}
### src/ringct/rctSigs.cpp
@@ -555,6 +555,7 @@ namespace rct {
addKeys(C, C, sig.Ci[i]);
}
sig.asig = genBorromean(ai, sig.Ci, CiH, b);
+ memwipe(ai, sizeof(ai));
return sig;
}
Why this scored 51/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.