Add OSS-Fuzz integration for msgpack-ruby#15340
Open
tranquac wants to merge 1 commit intogoogle:masterfrom
Open
Add OSS-Fuzz integration for msgpack-ruby#15340tranquac wants to merge 1 commit intogoogle:masterfrom
tranquac wants to merge 1 commit intogoogle:masterfrom
Conversation
|
tranquac is integrating a new project: |
f717ed3 to
854068a
Compare
|
LGTM |
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.
Project
msgpack-ruby — the Ruby gem for the MessagePack binary serialization format.
ext/msgpack/— 12 source files, ~3,945 LOCmsgpack-con OSS-Fuzz covers a C++ header-only library; msgpack-ruby's C extension is completely independent code not covered by any existing projectFuzz targets
fuzz_unpack—MessagePack.unpackAPI variantsExercises
factory_class.c → unpacker_class.c → unpacker.cwith 5 option combinations:symbolize_keys: true—rb_str_intern()on every map keyfreeze: true—rb_obj_freeze()on each objectallow_unknown_ext: true—ExtensionValueconstruction pathkey_cache: true—rstring_cache_fetch/build_interned_string(sorted VALUE array + MEMMOVE in buffer.h)fuzz_unpack_stream— StreamingUnpackerAPIExercises
unpacker_class.cstreaming methods with 5 variants:Unpacker#feed_each(default)feed_eachwithsymbolize_keys: truefeed+each(iterator path)feed+loop { read }(directUnpacker_readpath)feed_eachwithkey_cache: trueLocal test results
Known finding: DoS via unchecked pre-allocation
Both fuzz targets consistently discover a resource exhaustion condition:
Root cause:
ext/msgpack/unpacker.c:339callsrb_str_buf_new(length)wherelengthcomes directly from the msgpack header (str32/bin32 can specify up to 4GB). This allocation happens before checking whether that much data is available in the buffer. A 5-byte crafted message can force a 4GB allocation attempt, causing server-side OOM/DoS.This is an intentional finding — the harnesses are configured with
rss_limit_mb=4096(via.optionsfiles) to allow the fuzzer to continue beyond this known condition and discover additional bugs (memory corruption, use-after-free) in the C extension.Maintainer acknowledgment
Upstream issue: msgpack/msgpack-ruby#388