Repository navigation
test(fuzz): libFuzzer harnesses for split_command_to_args + monitor + RESP parsers - #421
Conversation
… RESP parsers Wires three coverage-guided libFuzzer harnesses for memtier_benchmark's in-process parsers so we catch the next adversarial-input bug (like the 19.97 MB MONITOR-input VLA stack overflow fixed in redis#405) without waiting for it to land in a real workload. Targets (tests/fuzz/): - split_command_to_args_fuzz: drives bytes into arbitrary_command::command and calls split_command_to_args(). Catches stack/heap overflows on the scratch buffer (the redis#405 bug), \xNN decode bugs, and unterminated-quote loops. - monitor_input_fuzz: writes input to a tmpfile each iteration and calls monitor_command_list::load_from_file(). Catches preamble-parsing edge cases, missing quotes, multi-MB lines. - redis_protocol_fuzz: feeds bytes through an evbuffer into protocol_factory(PROTOCOL_RESP2/RESP3)->parse_response(), looping until drained or a 64-iteration cap. Routes through the factory because the concrete redis_protocol class lives in protocol.cpp's TU. Build wiring: - New `--enable-fuzz` configure flag (configure.ac); requires clang++, errors out otherwise. Exposes a `FUZZ_ENABLED` automake conditional. - Makefile.am gains a `FUZZ_ENABLED` block that builds three noinst_PROGRAMS with -fsanitize=fuzzer,address,undefined -fno-omit-frame-pointer -g -O1. Re-compiles config_types.cpp / protocol.cpp / command_meta.cpp into the fuzz objects so the sanitizer flags don't leak into the main binary's build. - Default `./configure && make` is unaffected: the conditional only fires under --enable-fuzz. Tiny shim (tests/fuzz/fuzz_stubs.cpp): - Stubs benchmark_log() / benchmark_log_file_line() / is_redis_protocol() so we don't drag in memtier_benchmark.cpp (main, libevent loop, stats stack, ...). Also provides dead-stub overrides for object_generator vtable slots referenced via monitor_command_list::get_random_command — the fuzzers never call them. Seed corpora (tests/fuzz/corpus/{split,monitor,resp}/): - split: basic SET, quoted/single-quoted values, \xNN decodes, malformed hex, embedded NUL, unterminated quotes, a 1.5 KB long-quoted string (libFuzzer grows it from there), escape mixes, whitespace-heavy. - monitor: redis MONITOR lines, the `[ proxy ... ]` preamble shape, unterminated quotes, lone quote, embedded NUL, comment-then-cmd. - resp: RESP2 simple/error/integer/bulk/null/array, *1\r\n nested chain, $INT_MAX bulk-length header, negative length, truncated bulk; RESP3 map / push (`>`) / attribute (`|`) / double / big-number / pipelined. First byte selects RESP2 vs RESP3. CI (.github/workflows/fuzz-smoke.yml): - Matrix over the three targets. Installs clang, autoreconf, configures with --enable-fuzz, builds the target, runs it for `-max_total_time=60 -rss_limit_mb=2048 -timeout=25 -max_len=33554432` on the seed corpus. `max_len=32 MiB` keeps the original 19.97 MB MONITOR line reachable per the issue's acceptance criterion. - Uploads crash-*/leak-*/timeout-*/oom-* artifacts on failure. Validation: - All three fuzzers build cleanly: `CC=clang CXX=clang++ ./configure --enable-fuzz && make split_command_to_args_fuzz monitor_input_fuzz redis_protocol_fuzz`. - Default `./configure && make` still produces a working memtier_benchmark. - Each fuzzer runs 30 s on the seed corpus with exit 0 when the config_types.cpp VLA is heap-promoted (i.e. with redis#405 applied). - Load-bearing acceptance: with the VLA still in place (config_types.cpp:520 `char buffer[command_len];`), running the split_command_to_args_fuzz against a 20 MB long-quoted-string seed reproduces the stack overflow within milliseconds: AddressSanitizer: stack-overflow ... in arbitrary_command::split_command_to_args() Re-applying the std::vector<char> fix from redis#405 makes the same 20 MB input run cleanly. This is precisely the regression we wanted the fuzzer to catch. - Fuzzers also surface latent UBSan-recoverable diagnostics on master (split: VLA-of-zero on empty input; resp: signed integer overflow in protocol.cpp:642 m_bulk_len + 2 when bulk-length is near LONG_MAX). These are reported but don't fail CI under default UBSan recover mode; follow-up PRs can address them. Fixes redis#407 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
| @@ -0,0 +1,3 @@ | |||
| >2 | |||
| +pubsub | |||
| +msg | |||
There was a problem hiding this comment.
RESP3 seed corpus files missing protocol selector byte
Medium Severity
The RESP3 seed corpus files (11–15) are missing the dedicated protocol selector byte that the harness expects. The harness in redis_protocol_fuzz.cpp consumes data[0] as a selector (data[0] & 0x01 chooses RESP3 vs RESP2) and feeds data + 1 to the parser. RESP2 seeds correctly use a leading space (0x20) as this selector byte, but RESP3 seeds start directly with the RESP type prefix (%, >, |, ,, (). This causes two problems: the type prefix is consumed as the selector (so the parser never sees it), and for >, |, ,, ( the low bit is 0, so RESP2 is selected instead of RESP3. The intended RESP3 map/push/attribute/double/bignum code paths are never exercised by the seeds.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 8f1ac0d. Configure here.
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review: performance (haiku 4.5)
- libFuzzer harnesses (local-dev tools): Three in-process fuzzer targets (
split_command_to_args_fuzz,monitor_input_fuzz,redis_protocol_fuzz). Built only under--enable-fuzz(off by default). No production binary impact. - Smoke fuzz in CI: Proposed
fuzz-smoke.ymlruns each target 60 s with-max_len=33554432. Adds ~5 min wall-clock per PR (3 targets × 60 s = 180 s ≈ 3 min on modest hardware). Acceptable for parser hardening. - No malloc churn in harness: libFuzzer mutation loop is in-process; cost is CPU-bound, not allocation-bound.
Verdict: Approve — dev tools only, opt-in CI job.
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review: docs & commit message (haiku 4.5)
• Title uses Conventional Commits correctly: test(fuzz): subject.
• Opens with Fixes #407 — correct (issue dedicated to libFuzzer harnesses).
• Test plan comprehensive: three harnesses build with sanitizer flags, seed corpora enumerated, CI workflow documented with timeouts and artifact uploads.
• New configure flag --enable-fuzz and FUZZ_ENABLED automake conditional introduced. Build wiring verified: default ./configure && make unaffected, conditional-only under --enable-fuzz.
• No AGENTS.md documentation of --enable-fuzz flag. Developers discovering this would need to read the PR body or the diff.
Verdict: Comment — missing AGENTS.md update documenting --enable-fuzz configure flag and build instructions.
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review: security (opus 4.7)
- Fuzz harnesses are in-process (libFuzzer), reading bytes from libFuzzer's mutator — no network listeners, no external trust boundary. The corpus seeds in
tests/fuzz/corpus/{split,monitor,resp}/are local inputs only; libFuzzer extends them incorpus/at runtime but that directory is per-CI-ephemeral. No exfiltration channel. monitor_input_fuzz.cppusesmkstemp(tmpl)withtmpl[] = "/tmp/mbfuzz_monitor_XXXXXX"— secure tempfile creation, no symlink-attack window.unlinkafter each iteration prevents disk-fill DoS during long fuzz runs.- The fuzz binaries link with
-fsanitize=fuzzer,address,undefinedand-O1. These flags do NOT leak into the mainmemtier_benchmarkbuild (the noinst_PROGRAMS block is isolated underif FUZZ_ENABLED). Verified by reading the Makefile.am block; the shared sources are re-compiled per harness rather than reusing top-level objects. fuzz_stubs.cppprovides no-opbenchmark_log*andis_redis_protocolthat exactly mirror production semantics for the protocol-type predicate. Theobject_generatorstubs callabort()if ever reached — this means a future change that causes monitor parsing to call intoget_random_command()will deterministically abort the fuzzer (a noisy false positive); acceptable for the current scope but a footgun if the call graph expands.- CI workflow runs in a matrix; each harness gets a fresh runner.
-rss_limit_mb=2048 -timeout=25 -max_len=33554432are reasonable bounds — a 32 MiB input cap prevents libFuzzer from hammering the process with multi-GB inputs that could OOM the runner. - Crash artifacts (
crash-*/leak-*/timeout-*/oom-*) are uploaded ONLY on failure withretention-days: 7. These are byte sequences derived from the in-tree corpus + libFuzzer mutations; no risk of leaking secrets because the fuzzers never read env / files outside/tmp. Confirmed. -fsanitize=fuzzer,address,undefinedtogether is supported by clang, but ASan + libFuzzer share the alt stack mentioned in PR #416 — fine for fuzz-only builds, and the production binary stays clean.- The PR description honestly flags two UBSan-recover-mode findings (
config_types.cpp:520VLA-of-zero,protocol.cpp:642signed-overflow) as deferred. UBSan in recover mode is correct for a smoke fuzzer; flipping to halt_on_error for nightly is a follow-up. - No untrusted memtier binary execution — only the in-tree build is used.
Verdict: Approve
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review: design & API choices (sonnet 4.6)
--enable-fuzzas a separateconfigure.acflag is the correct scope boundary. It is clang-only, adds non-trivial sanitizer CXXFLAGS, and buildsnoinst_PROGRAMSthat should never ship in a distribution package. Keeping it fully orthogonal to the default build avoids contamination of the main binary's flags.fuzz_stubs.cppsymbol shim is an acceptable short-term approach, but itsobject_generatorvtable stubs constitute a parallel partial re-implementation of the real class. Ifmonitor_command_listever calls a slot that the stub leaves as a no-op without logging, the harness will silently under-exercise the target. A comment listing exactly which slots are stubbed and why (not just "dead-stub") would make this maintainable.- Corpus split between #421 (
tests/fuzz/corpus/monitor/) and #422 (tests/fuzz/monitor_input_corpus/) is a naming collision risk. Two separate PRs create two separate monitor corpus directories undertests/fuzz/. After both merge,monitor_input_fuzz(the in-process harness) andfuzz_monitor_input.py(the black-box driver) will each seed from their own corpus with no shared exchange. A singletests/fuzz/corpus/monitor/shared by both harnesses, or at minimum a README linking them, would prevent seed drift. - RESP2/RESP3 dispatch by
data[0] & 0x01is clever but opaque. The first fuzz byte being a protocol-selector is not a libFuzzer convention; it means the corpus seeds must all start with\x00or\x01to be meaningful. The current seeds do respect this (they're committed in the diff), but the constraint should be documented in the harness source so future seed authors don't accidentally create RESP2-seed files that the fuzzer treats as RESP3. kMaxParseIterations = 64cap on the parse loop is sound, prevents infinite loops on partial frames, and the value is documented with the rationale. Good.
Verdict: Comment (address corpus directory naming collision with #422 before merge)
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review: edge cases & failure modes (opus 4.7)
tests/fuzz/monitor_input_fuzz.cpp:34-46—mkstemp+ write +load_from_file(tmpl)per iteration leaves the tmpfile alive untilunlink(tmpl)at line 46. Ifload_from_filecallsabort()(assertion path) the tmp file is never unlinked; long fuzz runs accumulate/tmp/mbfuzz_monitor_*files. Worse: libFuzzer's-detect_leaks=1flags the lingering fd. Useunlinkimmediately aftercloseand pass/dev/fd/N(or write into/dev/shmand accept the leak as the failure signature).tests/fuzz/monitor_input_fuzz.cpp:38-43—ssize_t written = write(fd, data, size); (void)written;— discards short writes. On a tmpfs ENOSPC the fuzzer corpus is silently truncated and the fuzz iteration runs against a different input than libFuzzer thinks it ran against; a reproducer becomes non-reproducible. At minimum checkwritten < 0and skip.tests/fuzz/redis_protocol_fuzz.cpp:46-83—set_keep_value(true)causes parse_response to allocate mbulk trees. The loop callsparse_response()up to 64 times. After the FIRST successful parsem_last_responseholds an mbulk; the SECOND iteration'sparse_responsecallsm_last_response.clear()(protocol.cpp:518) which deletes the previous tree. Good — no leak. BUT: onrc < 0youbreakanddelete proto_insttriggers~protocol_responsewhich then triggers the iterative~mbulk_size_elfrom PR #415. Test only exercises that path indirectly; consider a fixture that drivesrc<0to confirm.tests/fuzz/redis_protocol_fuzz.cpp:32—kMaxParseIterations = 64. A pathological input of*0\r\n*0\r\n...produces 64 zero-element arrays per iteration and libFuzzer reports "slow" but never crashes. Not a correctness bug, but the bound is wrong relative to the comment "spin libFuzzer past its -timeout=25s backstop" — at 25s you want a per-call cap not a per-iteration cap.tests/fuzz/split_command_to_args_fuzz.cpp:33-35— empty input:cmd.command.assign(reinterpret_cast<const char*>(data), 0)→ empty string →command_len == 0→std::vector<char> buffer(0)(PR #415 fix) →buffer.data()returns either NULL or a valid empty pointer. Downstreamarg(buffer, 0)is passed tocommand_argwhich doesmemcpy(NULL, ..., 0)— defined per C11 §7.24.1 only if both are non-NULL. UBSan may flag. Passbuffer.empty() ? "" : buffer.data()..github/workflows/fuzz-smoke.yml:78-85—-max_len=33554432(32 MiB) per fuzz iteration plus-rss_limit_mb=2048. With ASAN's 3-4x overhead a 32 MiB input throughsplit_command_to_argspeaks well over 2 GiB; libFuzzer kills the process without-of-memorywhichset +ekeeps from being a CI failure even thoughexit "$rc"propagates rc=71 (OOM). The artifact upload runs but the crash is mis-classified.tests/fuzz/fuzz_stubs.cpp:50-53—object_generator::clone() { abort(); }is called frommonitor_command_list::get_random_command(via random_range). Fuzz harnesses never call get_random_command but if a future harness does,abort()looks like a crash. Document or prefer__builtin_trap+#pragma message.configure.ac:108-117—--enable-fuzzrequires clang++ but doesn't check the clang version supports-fsanitize=fuzzer. clang < 6 ships without libFuzzer;make split_command_to_args_fuzzfails late with a cryptic linker error rather than a configure-time message.
Verdict: Comment
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review: code style & readability (sonnet 4.6)
_CPPFLAGSassigned the same variable as_CXXFLAGSinMakefile.am:split_command_to_args_fuzz_CPPFLAGS = $(memtier_fuzz_cxxflags)assigns C++ compiler flags (including-fsanitize=…and-std=c++11) to the C preprocessor flags slot. In Automake these are distinct:_CPPFLAGSshould carry only-I…and-D…defines; compiler/linker flags belong in_CXXFLAGS. The variable namememtier_fuzz_cxxflagsalso signals the mismatch. Splitting into amemtier_fuzz_cppflags(-I$(srcdir)) andmemtier_fuzz_cxxflags(the sanitizer / std / opt flags) would be semantically correct and prevent unexpected flag propagation if automake ever uses the distinction.fuzz-smoke.ymlcomment quality is good. The inline comment explaining-max_len=33554432and its link to the acceptance criterion in issue #407 is exactly the kind of "why this number" annotation that prevents future breakage.fuzz_stubs.cpppurpose is well-described in the Makefile block comment.- Corpus file naming (
01_basic_monitor,02_redis_monitor_line, etc.) is systematic and readable. - Commit message is a single Conventional Commit with accurate scope and a useful parenthetical listing all three targets.
Verdict: Comment
fcostaoliveira
left a comment
There was a problem hiding this comment.
Review: correctness & latent bugs (opus 4.7)
tests/fuzz/monitor_input_fuzz.cpp:LLVMFuzzerTestOneInputcallsmkstemp(tmpl)followed byclose(fd)immediately and then opens by path viaload_from_file(). Race: betweenclose()andfopen()another process could replace the file via the predictable-prefix/tmp/mbfuzz_monitor_XXXXXX(XXXXXX is random but a target who can guess will get there). Acceptable for fuzzing; just call out the test-only TOCTOU.tests/fuzz/monitor_input_fuzz.cpp:38(void) written; // Ignore short writes— a short write on/tmpis essentially impossible, but if it does happen,load_from_filereads a partial corpus and the fuzzer's coverage feedback corresponds to an input it didn't actually run. Minor.tests/fuzz/redis_protocol_fuzz.cpp:88-91After a successfulparse_response()(returns 1), the loop iterates again without clearing the previously-parsed response. The comment at line 88 hints at this but no clear actually happens. Ifparse_responseretains state inm_last_responseand the next iteration calls it without clearing, the second response's mbulk tree may attach to the first's parent — leak path. The protocol code's contract is unclear here; ifparse_responsealways allocates a freshm_last_responseinternally, the leak is in the parser not the harness.tests/fuzz/fuzz_stubs.cpp:67-77object_generator::clone()etc. callabort(). If any code path linked into the fuzzer (e.g.monitor_command_list::get_random_command) calls these even on an unrelated/invalid path libFuzzer mutators reach, abort() reports as a false-positive crash. The author claims these are never called fromload_from_file, but the corpus mutations are wide.Makefile.am:194-200memtier_fuzz_cxxflagssets-fsanitize=fuzzer,address,undefinedbut also-Werror=vla(fromconfigure.acchange in PR #415 if merged). The protocol/config_types files would fail to build under fuzz config until #415's VLA fixes also land. Merge ordering risk between #415 and #421..github/workflows/fuzz-smoke.yml:81-82Upload-artifacts looks forcrash-*,leak-*etc. at the repo root, but libFuzzer writes crash files to the cwd of the fuzzer invocation. The workflow runs./$TARGET corpus/ ...from the repo root — so crash files land at the root, which matches the upload paths. OK.tests/fuzz/redis_protocol_fuzz.cpp:75-76set_keep_value(true)may leak when~abstract_protocoldoesn't clean upm_last_response. Worth confirming the destructor chain callsclear()on the response. If not, every iteration leaks the parsed mbulk tree under ASAN, which would surface as the fuzzer running out of memory inside the libFuzzer 2 GB rss limit and reporting an OOM — not a false positive per se, but noisy.- The fuzz harness compiles
config_types.cppindependently with-fsanitize=address,undefinedso the empty-input case (buffer.assign(NULL, 0)) is OK. Butarbitrary_command cmd("X")constructs with a literal thenassign(data, 0)clears it — split_command_to_args on an empty string should return cleanly.
Verdict: Comment
…uzzer-parser-harnesses
Pushing back on this one — the corpus is actually correct, the bugbot misread the hex dumps: ``` The RESP2 selector is 0x00, not 0x20 (space). The harness selector logic is So the RESP3 map/push/attribute/double/bignum paths ARE exercised by the seeds. No action needed. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Reviewed by Cursor Bugbot for commit f3d2c9f. Configure here.
| @@ -0,0 +1,3 @@ | |||
| >2 | |||
| +pubsub | |||
| +msg | |||
There was a problem hiding this comment.
RESP3 corpus seeds select wrong protocol and lack CRLF
Medium Severity
The RESP3 seed corpus files have two compounding problems that make them completely ineffective. First, the fuzzer in redis_protocol_fuzz.cpp consumes the first byte as a protocol selector via data[0] & 0x01, but 4 of 5 RESP3 seeds start with even-valued bytes (> 0x3E, | 0x7C, , 0x2C, ( 0x28), so they incorrectly select RESP2 instead of RESP3. Only % (0x25) in file 11 is odd. Second, all RESP3 seeds use \n line endings, but the parser calls evbuffer_readln with EVBUFFER_EOL_CRLF_STRICT, which requires \r\n. Combined, these seeds provide zero coverage of RESP3 parser paths (map, push, attribute, double, big-number).
Additional Locations (2)
Reviewed by Cursor Bugbot for commit f3d2c9f. Configure here.
* ci: declare workflow-level contents: read on 6 workflows Pins the default GITHUB_TOKEN to contents: read on the workflows in .github/workflows/ that don't call a GitHub API beyond the initial checkout. The other workflows in this directory are left implicit because they need write scopes that a maintainer is better placed to declare. Motivation: CVE-2025-30066 (March 2025 tj-actions/changed-files compromise) exfiltrated GITHUB_TOKEN from workflow logs. Per-workflow caps bound runtime authority irrespective of repo or org default, give drift protection if the default ever widens, and are credited per-file by the OpenSSF Scorecard Token-Permissions check. YAML validated locally with yaml.safe_load. Signed-off-by: Arpit Jain <[email protected]> * ci: also declare contents: read on fuzz-smoke + soak-nightly workflows Extends the PR to cover the two workflows that landed after it was first opened (fuzz-smoke.yml from PR #421, soak-nightly.yml from PR #423). After the merge with master, dockers.yml + the two new ones are the only files where the permissions block is still missing. --------- Signed-off-by: Arpit Jain <[email protected]> Co-authored-by: fcostaoliveira <[email protected]>


Fixes #407
Summary
Wires three coverage-guided libFuzzer harnesses for memtier_benchmark's in-process parsers so we catch the next adversarial-input bug (like the 19.97 MB MONITOR-input VLA stack overflow fixed in #405) without waiting for it to land in a real workload.
Targets (
tests/fuzz/)split_command_to_args_fuzz— drives arbitrary bytes intoarbitrary_command::commandand callssplit_command_to_args(). Catches stack/heap overflows on the scratch buffer (the fix(arbitrary-command): heap-allocate split-token buffer to avoid VLA stack overflow #405 bug),\xNNdecode bugs, unterminated-quote loops.monitor_input_fuzz— writes each input to atmpfile()and callsmonitor_command_list::load_from_file(). Catches preamble-parsing edge cases, missing quotes, multi-MB lines.redis_protocol_fuzz— feeds bytes through anevbufferintoprotocol_factory(PROTOCOL_RESP2/RESP3)->parse_response(), looping until drained or a 64-iteration cap. Routes through the factory because the concreteredis_protocolclass lives inprotocol.cpp's TU (not exposed viaprotocol.h).Build wiring
--enable-fuzzconfigure flag (configure.ac); requiresclang++, errors out otherwise. Exposes aFUZZ_ENABLEDautomake conditional.Makefile.amgains aFUZZ_ENABLEDblock that builds threenoinst_PROGRAMSwith-fsanitize=fuzzer,address,undefined -fno-omit-frame-pointer -g -O1. Re-compilesconfig_types.cpp/protocol.cpp/command_meta.cppinto the fuzz objects so the sanitizer flags don't leak into the main binary's build../configure && makeis unaffected; the conditional only fires under--enable-fuzz.Tiny shim (
tests/fuzz/fuzz_stubs.cpp)benchmark_log()/benchmark_log_file_line()/is_redis_protocol()so we don't drag inmemtier_benchmark.cpp(main, libevent loop, stats stack, ...). Also provides dead-stub overrides forobject_generatorvtable slots referenced viamonitor_command_list::get_random_command— the fuzzers never call them.Seed corpora (
tests/fuzz/corpus/{split,monitor,resp}/)\xNNdecodes, malformed hex, embedded NUL, unterminated quotes, a 1.5 KB long-quoted string (libFuzzer grows it from there), escape mixes, whitespace-heavy.[ proxy ... ]preamble shape, unterminated quotes, lone quote, embedded NUL, comment-then-cmd.*1\r\nnested chain,$INT_MAXbulk-length header, negative length, truncated bulk; RESP3 map / push (>) / attribute (|) / double / big-number / pipelined. First byte selects RESP2 vs RESP3.CI (
.github/workflows/fuzz-smoke.yml)clang, runsautoreconf -ivf,./configure --enable-fuzz,make $TARGET -j, then./$TARGET corpus/ -max_total_time=60 -rss_limit_mb=2048 -timeout=25 -max_len=33554432.max_len=32 MiBkeeps the original 19.97 MB MONITOR line reachable per the issue's acceptance criterion.crash-*/leak-*/timeout-*/oom-*artifacts on failure.Test plan
./configure && make(no flags) still buildsmemtier_benchmarkcleanly —--enable-fuzzpath does not perturb the default release/debug build.CC=clang CXX=clang++ ./configure --enable-fuzz && make split_command_to_args_fuzz monitor_input_fuzz redis_protocol_fuzzbuilds all three harnesses with the expected sanitizer link line.make format-checkclean on the staged sources (fuzz_stubs.cpp, three*_fuzz.cpp).config_types.cpp:520VLA is heap-promoted (i.e. with fix(arbitrary-command): heap-allocate split-token buffer to avoid VLA stack overflow #405 applied).char buffer[command_len];on the pre-fix(arbitrary-command): heap-allocate split-token buffer to avoid VLA stack overflow #405 master), running./split_command_to_args_fuzzagainst a 20 MB long-quoted-string input reproduces the stack overflow within milliseconds:std::vector<char> buffer(command_len);fix from fix(arbitrary-command): heap-allocate split-token buffer to avoid VLA stack overflow #405 makes the same 20 MB input run cleanly. The fuzzer correctly distinguishes the buggy and fixed states — exactly the regression-detection signal we wanted.Notes / judgment calls
-max_total_time=60smoke can theoretically grow the mutator's input past the 8 MB stack and trip the original VLA crash on a tree without fix(arbitrary-command): heap-allocate split-token buffer to avoid VLA stack overflow #405 applied. The PR intentionally lands the harness wiring without modifying the parser; fix(arbitrary-command): heap-allocate split-token buffer to avoid VLA stack overflow #405 is the corresponding fix. Once fix(arbitrary-command): heap-allocate split-token buffer to avoid VLA stack overflow #405 merges, the fuzz-smoke CI on this branch is fully green; until then, the smoke is a no-op on the long-quoted-string mutation path but still exercises the rest of the corpus.-fsanitize=undefineddefaults to "report, continue", so two latent diagnostics show up in the 30 s smoke on current master but don't fail the job: (a)config_types.cpp:520VLA-of-zero on the empty input libFuzzer always tests, and (b)protocol.cpp:642signed-integer overflow inm_bulk_len + 2when bulk-length is nearLONG_MAX. Both are real findings (the second one is a fresh parser bug the harness surfaced on its first run) and are good candidates for follow-up PRs; I left them off this PR per the "no parser changes" scope constraint.redis_protocolshim.redis_protocolis file-local toprotocol.cpp, but it's reachable viaprotocol_factory(enum PROTOCOL_TYPE)which is exposed inprotocol.h. No header changes were needed — the harness selects RESP2/RESP3 via the first input byte and goes through the factory.🤖 Generated with Claude Code
Note
Low Risk
Test and CI-only wiring; production parser sources are exercised but not modified, and fuzz builds are opt-in via
--enable-fuzz.Overview
Adds libFuzzer in-process harnesses and CI so parser regressions (e.g. huge MONITOR / command-split inputs) are caught before they hit real workloads.
Build: New
--enable-fuzz(clang++ only) builds threenoinsttargets with ASan/UBSan/fuzzer flags on a separate compile ofconfig_types.cpp,protocol.cpp, andcommand_meta.cpp, plusfuzz_stubs.cppfor logging /is_redis_protocol/object_generatorsymbols—default./configure && makeis unchanged..gitignoreand.gitattributestreat fuzz binaries andtests/fuzz/corpus/**appropriately.Harnesses:
split_command_to_args_fuzz→arbitrary_command::split_command_to_args();monitor_input_fuzz→monitor_command_list::load_from_file()via temp files;redis_protocol_fuzz→protocol_factory+parse_response()with RESP2/RESP3 selected by the first input byte. Seed corpora undertests/fuzz/corpus/{split,monitor,resp}/.CI:
.github/workflows/fuzz-smoke.ymlmatrix-runs each target for 60s with-max_len=32 MiB(issue #407 acceptance) and uploads crash/leak artifacts on failure.Reviewed by Cursor Bugbot for commit f3d2c9f. Bugbot is set up for automated code reviews on this repo. Configure here.