chore: crypto primitives external audit response 1#22272
Open
johnathan79717 wants to merge 1 commit intomerge-train/barretenbergfrom
Open
chore: crypto primitives external audit response 1#22272johnathan79717 wants to merge 1 commit intomerge-train/barretenbergfrom
johnathan79717 wants to merge 1 commit intomerge-train/barretenbergfrom
Conversation
ddfb651 to
1d0754e
Compare
In WASM builds, BB_NO_EXCEPTIONS is defined which routes throw_or_abort to std::abort(), killing the WASM process on any error with no recovery. The fix: don't compile the C++ definition of throw_or_abort_impl for WASM builds (#ifndef __wasm__). The header already declares it as a WASM_IMPORT from the JS environment, where it throws a catchable JS Error. With the competing C++ definition removed, the JS import is used, and errors propagate as JS exceptions back to the TS caller instead of aborting the process.
ea7899c to
4de984d
Compare
ludamad
approved these changes
Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Audit Context
Addresses finding #2 from the "Aztec - Cryptographic Primitives" external audit: WASM Process DOS via Oversized Polynomial in Prover Commit Path.
In WASM builds,
BB_NO_EXCEPTIONSis defined. The C++throw_or_abort_impldefinition callsabort_with_message()which terminates the WASM process on any error. Meanwhile, the header (throw_or_abort_impl.hpp) declares the same function as aWASM_IMPORTfrom JavaScript, where it throws a catchable JSError. But the local C++ definition takes priority over the import, so the JS throw is never used.Changes Made
#ifndef __wasm__. In WASM builds, the JS-provided import (which throws a catchable JSError) is used instead. The header already declares it asWASM_IMPORT("throw_or_abort_impl")with the comment "For a WASM build, this is provided by the JavaScript environment."Before: Any
throw_or_abortin WASM callsabort_with_message()->std::abort()-> WASM process dies, PXE crashes.After:
throw_or_abortin WASM calls the JS import which throwsnew Error(msg). The JS caller catches this as a normal exception. The WASM instance stays alive for subsequent requests.Checklist
bbapi_tests --gtest_filter=CBind.*(2 passed)