fix(security): verify an ed25519 signature on the bootstrap archive (F5)
The chain-bootstrap download was authenticated only by a same-origin SHA-256, which anyone who can replace the archive (CDN/server compromise or a TLS break) can also replace. The RCE half of the original report is already closed — extract skips every *.conf/wallet*/.dat entry, so DRAGONX.conf/blocknotify can't be overwritten — but the archive itself was unauthenticated. Verify a detached ed25519 signature over the published .sha256 file (the archive is multi-GB; its checksum already binds the bytes, so signing the small checksum authenticates the whole download) against a pinned key. A present-but-invalid signature always fails closed; a missing one is gated by kBootstrapRequireSignature (false until bootstrap.dragonx.is publishes .sig files, then flip to true). Adds scripts/sign-bootstrap-release.sh; the secret key stays offline. Also adds regression tests: testBootstrapSignatureInterop (known-answer verify against the pinned key, fails closed on tamper/wrong-key — F5) and testEphemeralPortPick (F13). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <iomanip>
|
||||
#include "../util/logger.h"
|
||||
#include "http_download.h"
|
||||
#include "xmrig_updater.h" // util::verifyXmrigSignature (shared ed25519 verify) — F5
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
@@ -1153,9 +1154,43 @@ bool Bootstrap::verifyChecksums(const std::string& zipPath, const std::string& b
|
||||
}
|
||||
DEBUG_LOGF("[Bootstrap] SHA-256 verified: %s\n", actual.c_str());
|
||||
|
||||
// F5 — the checksum proves the archive matches a hash the server served, but not that the hash is
|
||||
// ours. Authenticate it with a detached ed25519 signature over the .sha256 content (pinned key).
|
||||
if (!verifyArchiveSignature(sha256Content, baseUrl)) return false; // keeps the archive, sets Failed
|
||||
|
||||
setProgress(State::Verifying, "Checksums verified \xe2\x9c\x93", 100.0, 100.0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Bootstrap::verifyArchiveSignature(const std::string& sha256Content, const std::string& baseUrl) {
|
||||
const std::string pubKey = kBootstrapSignaturePublicKeyBase64 ? kBootstrapSignaturePublicKeyBase64 : "";
|
||||
|
||||
HttpGetOptions opt; opt.cancel = &cancel_requested_;
|
||||
const std::string sig = httpGetString(baseUrl + "/" + kZipName + ".sha256.sig", "[bootstrap]", opt);
|
||||
if (cancel_requested_) return false;
|
||||
|
||||
if (sig.empty() || pubKey.empty()) {
|
||||
if (kBootstrapRequireSignature) {
|
||||
DEBUG_LOGF("[Bootstrap] No ed25519 signature published - refusing (signature required)\n");
|
||||
setProgress(State::Failed, "Verification failed: the bootstrap is not signed. "
|
||||
"Refusing to install an unauthenticated archive.");
|
||||
return false; // fail CLOSED; archive is KEPT
|
||||
}
|
||||
DEBUG_LOGF("[Bootstrap] No ed25519 signature published - relying on SHA-256 over TLS only\n");
|
||||
return true; // defense-in-depth not yet enforced server-side
|
||||
}
|
||||
|
||||
// Verify over the EXACT .sha256 bytes the signer signed (not the parsed hash). A present-but-invalid
|
||||
// signature is always fatal — it means the checksum we just trusted was not issued by us.
|
||||
if (!util::verifyXmrigSignature(sha256Content, sig, pubKey)) {
|
||||
DEBUG_LOGF("[Bootstrap] ed25519 signature MISMATCH - refusing\n");
|
||||
setProgress(State::Failed, "Verification failed: the bootstrap signature did not match the pinned "
|
||||
"release key. Refusing to install.");
|
||||
return false; // fail CLOSED; archive is KEPT
|
||||
}
|
||||
DEBUG_LOGF("[Bootstrap] ed25519 signature verified against the pinned key\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace dragonx
|
||||
|
||||
Reference in New Issue
Block a user