test(fuzz): libFuzzer harness for the v4 colblock decoder (+ 2 UB fixes it found)#84
Merged
Conversation
…es it found) Add a libFuzzer harness (tests/fuzz/fuzz_colblock.cpp, VV_BUILD_FUZZERS CMake option, clang) that fuzzes decode_colblock() directly — the LociSSD v4 codec decoder that reads attacker-controlled offsets/lengths out of a decompressed chunk (the class hardened in #71). Fuzzing the pure function (no per-iteration file I/O) gives high coverage of every codec path under ASan+UBSan. A 24.04 CI step builds it with clang and runs a 45 s deterministic smoke. It immediately found two undefined-behaviour bugs reachable via a crafted file, both now fixed: - Empty block (n_rows = 0): AppendValues / memcpy were handed the null data() of an empty vector — UB. Skip the zero-length append (the builder's Finish() yields the correct empty array). - DELTA / LENGTH coordinate reconstruction accumulated in int64, so adversarial deltas overflowed (signed overflow is UB). Accumulate in uint64 (defined wraparound); legitimate bounded coordinates are unchanged. decode_colblock is now non-static so the harness can call it (declared in include/vv/vvfuzz.hpp — not the public reader surface). Legitimate v4/v4.1 output is byte-identical; the decoder runs clean over 37 M fuzz iterations. Suite 375. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
The other half of the systemic memory-safety pair (after the ASan/UBSan gate in #80): a libFuzzer harness over
decode_colblock— the LociSSD v4 codec decoder that reads attacker-controlled offsets/lengths out of a decompressed chunk (the class hardened in #71). It fuzzes the pure function directly (no per-iteration file I/O), so coverage of every codec path (RAW / DELTA / LENGTH / DICT / FRONTCODE / ARENA / BOOL + the null-bitmap prefix) is high and fast (~150k exec/s).tests/fuzz/fuzz_colblock.cpp+-DVV_BUILD_FUZZERS=ON(clang), reusing vv's exact reader-dep link list.decode_colblockis now non-static (declared ininclude/vv/vvfuzz.hpp— not the public reader surface).Bugs it found (both fixed, both crafted-file-reachable)
n_rows = 0) —AppendValues/memcpywere handed the nulldata()of an empty vector → UB (null pointer passed as argument 2 ... declared never null). Skip the zero-length append.int64overflow — coordinate reconstruction accumulated inint64, so adversarial deltas overflowed (signed overflow is UB). Accumulate inuint64(defined wraparound).Verification
🤖 Generated with Claude Code