fix: cap deserialization vector/map sizes at 256 MB to prevent OOM DoS#22283
Open
johnathan79717 wants to merge 1 commit intomerge-train/barretenbergfrom
Open
fix: cap deserialization vector/map sizes at 256 MB to prevent OOM DoS#22283johnathan79717 wants to merge 1 commit intomerge-train/barretenbergfrom
johnathan79717 wants to merge 1 commit intomerge-train/barretenbergfrom
Conversation
An attacker-controlled uint32_t size field in binary deserialization could trigger multi-GB allocations before any crypto validation. Add bounds checks on all vector::resize() and map iteration paths in serialize.hpp, matching the 256 MB cap used for decompression. Fixes AztecProtocol/barretenberg-claude#2415
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.
Summary
MAX_SERIALIZE_BYTES) before everyvector::resize()andmapiteration inserialize.hppuint32_tsize fields from triggering multi-GB allocations that crash the process via OOM before any crypto validationprivate_execution_steps.cppFixes AztecProtocol/barretenberg-claude#2415
Protected paths
All 4 deserialization entry points that read a size from untrusted input:
read(uint8_t const*&, vector<uint8_t>&)- raw pointer pathread(istream&, vector<uint8_t>&)- stream pathread(B&, vector<T, A>&)- generic vector path (checkssize * sizeof(T))read(B&, map<T, U>&)- map path (checkssize * (sizeof(T) + sizeof(U)))Test plan
serialize-tests_testspasses (2/2)