fuzz: add fuzz_qos_provider target for the sysdef XML parser - #2442
Open
glaziermag wants to merge 1 commit into
Open
fuzz: add fuzz_qos_provider target for the sysdef XML parser#2442glaziermag wants to merge 1 commit into
glaziermag wants to merge 1 commit into
Conversation
The system-definition parser (dds_sysdef_parser.c) and the QoS provider that drives it have no fuzz coverage: none of the seven existing targets reach dds_sysdef_init_sysdef_str(). Drives the public dds_create_qos_provider() API, then the keyed dds_qos_provider_get_qos() lookup using literal library::profile names from the seed corpus, since that lookup matches keys with strcmp. Only the inline-XML form is fuzzed. dds_create_qos_provider() treats an argument not starting with '<' as a filesystem path, and sending fuzzer bytes down that branch would make the target depend on the filesystem. Guarded on ENABLE_QOS_PROVIDER, which drops dds_qos_provider.c from the build when OFF. No change to fuzz/oss-fuzz-build.sh is needed; it already finds build/bin/fuzz_*, copies fuzz/*.options and zips seed corpora. Signed-off-by: glaziermag <leuping@gmail.com>
glaziermag
force-pushed
the
pr/fuzz-qos-provider
branch
from
August 6, 2026 00:12
18b9c7a to
4211458
Compare
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.
Adds a libFuzzer target for the system-definition XML parser, driven through the public QoS provider
API.
src/core/ddsc/src/dds_sysdef_parser.canddds_qos_provider.ccurrently have no fuzz coverage —none of the seven existing targets reach
dds_sysdef_init_sysdef_str(). (The sharedddsrt_xmlp_*tokenizer in
src/ddsrt/src/xmlparser.cis already exercised, viafuzz_config_initon the DDSIconfig path; what is uncovered is the sysdef callback layer above it and the QoS provider.)
Design notes
Inline XML only.
read_sysdef— reached fromdds_create_qos_provider— treats an argumentstarting with
<as an inline document and anything else as a filesystem path(
dds_qos_provider.c:29-40). The target rejects anything not starting with<, so fuzzer bytesnever reach the
fopenbranch; otherwise the target would depend on the filesystem and stop beingreproducible.
Guarded on
ENABLE_QOS_PROVIDERinfuzz/CMakeLists.txt. This is load-bearing rather thancosmetic: with the option OFF,
src/core/ddsc/CMakeLists.txtdropsdds_qos_provider.cfrom thesources and the public header from the install set, so the target would fail to compile and link.
add_subdirectory(src)runs beforeadd_subdirectory(fuzz), so the cache entry is visible.Keyed lookup uses literal names.
dds_qos_provider_get_qosmatches keys withstrcmpagainst"<library>::<profile>", so the target queries"L::P"and"OurLibrary::ProfileA", which are thenames in the seed corpus. A wildcard would never resolve.
No change needed to
fuzz/oss-fuzz-build.sh. It already findsbuild/bin/fuzz_*, copiesfuzz/*.options, and zipsfuzz_*_seed_corpus/directories recursively, so the target, its.optionsfile and its corpus are picked up as-is.Seed corpus derives from
src/core/ddsc/tests/sysdef_qos_library.xmlplus documents exercisingthe base64
user_data/topic_data/group_datapolicies, a reader-history profile, and<dds/>.Verification
infra/helper.py build_fuzzers cyclonedds <tree>andcheck_build cyclonedds— both exit 0;fuzz_qos_providerbuilt alongside the seven existing targets, with its.optionsandseed_corpus.zipin$OUT. This is the default engine and sanitizer only (libfuzzer + address);I have not built the afl, honggfuzz or UBSan configurations that
project.yamlalso lists.the binary's ~35,000 instrumented edges; 20 minutes of fuzzing on top only reached 831, so most of
what the target finds early comes from the seeds rather than from mutation.
It reproduces two open issues immediately
Flagging this so it isn't a surprise after merge. The target finds both within seconds:
dds_create_qos_provider()NULL-derefs on a document that opens no root element<value>payloads of length ≡ 2 (mod 4) #2441 —b64_decode()reads one byte past the heap buffer for<value>payloads of length ≡ 2(mod 4)
(#2440 is also triggered by an empty file, which this target can't submit since it requires a
leading
<; the element-free document is the form it finds.)Both issues carry a suggested fix. Sequencing is yours — landing fixes first and this second is a
perfectly sensible order.
What the local run does and doesn't show
A 20-minute run (macOS/arm64, ASan,
-fork=2) produced ~4,600 crash artifacts. I triaged a400-artifact sample: 364 were the #2440 SEGV, 36 the #2441 over-read, nothing else. I did not triage
the remainder, and I have not run this on Linux/x86_64 or under UBSan — so please read that as a
sample rather than a clean bill of health.