Skip to content

fuzz: add a fuzzer for the C API - #320

Merged
hyperrealm merged 1 commit into
hyperrealm:masterfrom
matiasnadasecurity-ux:fuzz-config-api
Nov 29, 2026
Merged

hyperrealm merged 1 commit into
hyperrealm:masterfrom
matiasnadasecurity-ux:fuzz-config-api

Conversation

@matiasnadasecurity-ux

Copy link
Copy Markdown
Contributor

Follow-up to #319, as agreed there. Thanks for the quick answer, Mark.

This adds config_api_fuzzer next to config_read_fuzzer in fuzz/. The existing fuzzer parses a configuration, looks up a setting, sets or adds one float, writes the result and removes that setting. The new one drives more of the C API on a parsed tree: typed setters and getters, element access, path lookups, element removal, output formats and options, hooks, and a config_write() → config_read() round trip.

  • Inputs that contain @include are skipped, so the fuzzer never opens files.
  • Written output larger than 16 KiB is not read back, so that deeply nested inputs do not time out.
  • It has its own install() line in fuzz/CMakeLists.txt: removing that line takes it out of OSS-Fuzz.
  • fuzz/build.sh builds its seeds from tests/testdata and installs a small dictionary. The existing fuzzer and its build lines are not changed.

Testing: with OSS-Fuzz's infra/helper.py, build_fuzzers and check_build pass with the address and undefined sanitizers (libFuzzer) and with AFL and honggfuzz (address). Short ASan and UBSan runs of the new fuzzer found no crashes.

Coverage: in a 7-minute local run the new fuzzer covered 1,109 lines of lib/libconfig.c and 681 of lib/scanner.c. The public OSS-Fuzz coverage report of November 25 shows 762 and 581 for those files, so it reaches at least about 430 lines of lib/ that are not covered there today.

Once I am on auto_ccs (a separate pull request in google/oss-fuzz), I will look at this fuzzer's reports first, as offered in #319.

The fuzzer was written and tested with AI tools (Claude), with a separate AI review.

config_read_fuzzer parses a configuration, looks up a setting, sets or
adds one float, writes the result and removes that setting. This adds
config_api_fuzzer, which drives more of the C API on a parsed tree:
typed setters and getters, element access, path lookups, element
removal, output formats and options, and a config_write() ->
config_read() round trip.

Inputs that contain "@include" are skipped, so the fuzzer never opens
files. Written output larger than 16 KiB is not read back, so that
deeply nested inputs do not time out.

The new fuzzer has its own install() line in fuzz/CMakeLists.txt, so it
can be taken out of OSS-Fuzz by removing that line. Its seeds are built
from tests/testdata in fuzz/build.sh.

Follow-up to hyperrealm#319.

Signed-off-by: Matías Scatarelli <matiasnada.security@gmail.com>
@hyperrealm
hyperrealm merged commit 262cc21 into hyperrealm:master Nov 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants