Skip to content

Commit 1391c49

Browse files
AztecBotludamad
andauthored
fix: reject VK with log_circuit_size=0 in UltraKeccak verifier (#22319)
## Summary Fixes a memory-safety vulnerability in the native UltraKeccak non-ZK verifier where a malformed verification key with `log_circuit_size = 0` causes an out-of-bounds write in `get_dyadic_powers_of_challenge`. --------- Co-authored-by: ludamad <adam.domurad@gmail.com>
1 parent ee65fa5 commit 1391c49

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

barretenberg/cpp/src/barretenberg/transcript/transcript.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ template <typename Codec_, typename HashFunction_> class BaseTranscript {
295295
template <typename ChallengeType>
296296
std::vector<ChallengeType> get_dyadic_powers_of_challenge(const std::string& label, size_t num_challenges)
297297
{
298+
BB_ASSERT(num_challenges > 0, "get_dyadic_powers_of_challenge called with num_challenges=0");
298299
ChallengeType challenge = get_challenge<ChallengeType>(label);
299300
std::vector<ChallengeType> pows(num_challenges);
300301
pows[0] = challenge;

barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ template <typename Flavor, class IO> size_t UltraVerifier_<Flavor, IO>::compute_
3030
return static_cast<size_t>(Flavor::VIRTUAL_LOG_N);
3131
} else {
3232
// Non-padded: use actual circuit size from VK (native only)
33-
return static_cast<size_t>(verifier_instance->get_vk()->log_circuit_size);
33+
const size_t log_circuit_size = static_cast<size_t>(verifier_instance->get_vk()->log_circuit_size);
34+
BB_ASSERT_GTE(
35+
log_circuit_size, static_cast<size_t>(1), "VK log_circuit_size is 0, which is invalid for any circuit");
36+
return log_circuit_size;
3437
}
3538
}
3639

0 commit comments

Comments
 (0)