diff --git a/src/stratum.cpp b/src/stratum.cpp index 42e31a10d..16736e6e2 100644 --- a/src/stratum.cpp +++ b/src/stratum.cpp @@ -1334,7 +1334,16 @@ UniValue stratum_mining_submit(StratumClient& client, const UniValue& params) if (job_id_str.length() == 63) { fEWBFJobIDFixNeeded = true; for(const auto& hexDigit : hexDigits) { - ret = uint256(ParseHex(job_id_str + hexDigit)); + // ParseHex() stops at the first non-hex character and returns a SHORT vector + // without signalling an error, and base_blob(const std::vector&) + // asserts vch.size() == 32. Constructing without checking therefore lets any + // 63-character job_id containing a non-hex byte abort the daemon -- from an + // unauthenticated client, before any other validation. Skip bad candidates + // instead; if none of the 16 completions parse, ret stays null, misses + // work_templates below, and the handler returns false cleanly. + std::vector vch = ParseHex(job_id_str + hexDigit); + if (vch.size() != 32) continue; + ret = uint256(vch); if (work_templates.count(ret)) break; } }