Harden untrusted payload parsing against out-of-bounds access - #9
Merged
Conversation
Validate buffers in CreateReadonly, thread received size through field and vector accessors, clamp hostile string lengths and element counts, and fix ProtoBuffer overflow so malicious wire data cannot read past the buffer.
Make presence, nested-message slots, string size/data, fixed-array counts, vector BaseOffset/capacity, and union discriminators size-aware so hostile payloads cannot read past the received buffer.
libFuzzer found UnionInt64Field::Get SEGVing on hostile inflated full_size; route union primitives through MessageRuntime::ToAddress. Pin cpp_toolbelt to the ToAddress sizeof-fit fix and keep ASan crash inputs as regression corpus.
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
CreateReadonlybefore dereferencing any field offsetsbuffer_sizethroughMessageRuntimefor size-aware string reads and element-count clampingProtoBuffer::Checkinteger overflow on hostile wire lengthsPhaserTest.HostilePayloadIsBoundedcpp_toolbeltto dallison/cpp_toolbelt#26 viagit_overrideuntil 2.1.3 is publishedTest plan
bazel test //... -//phaser:perf_test(macOS)bazel test //... -//phaser:perf_test(Linux via Colima/Ubuntu 24.04)bazel test --config=asan //... -//phaser:perf_test(Linux — ASan hangs on local macOS clang)Dependency
Requires merging and releasing cpp_toolbelt#26, then replacing the temporary
git_overridewith acpp_toolbeltversion bump.