Fuzzing

Fuzzing

The workspace ships 38 cargo-fuzz harnesses under fuzz/fuzz_targets/. The Fuzz GitHub Actions workflow runs 32 of them weekly (Monday 03:00 UTC) on libFuzzer; specialized differential and subsystem targets remain manual.

Harness inventory

Target Covers Max input len in CI
fuzz_parse_yaml The Sigma YAML parser (parse_sigma_yaml). 8192
fuzz_rule_fmt The Sigma formatter (format_yaml, format_yaml_range): idempotency, value equality, and comment and anchor preservation. 8192
fuzz_condition Condition-expression parser only. 512
fuzz_eval_matching Engine evaluation. Feeds parsed rules and constructed JSON events. 65536
fuzz_eval_matcher_diff Differential test for the matcher optimizer (optimize_any_of): runs the Aho-Corasick fast path against the naive scalar fallback on the same needles and haystacks. Not in the weekly matrix; run manually. (default)
fuzz_field_modifiers The 30+ Sigma modifiers. 256
fuzz_regex_compile The hardened regex compilation path (size and complexity caps). 1024
fuzz_pipeline_yaml Pipeline YAML parser. 4096
fuzz_pipeline_sources_yaml Dynamic source spec parser. 8192
fuzz_watchlist_request Watchlist push, replace, and delete bodies. The first byte selects the operation. The rest is JSON. Unreleased 4096
fuzz_alert_pipeline_config Alert-pipeline configuration parser. 4096
fuzz_enrichers_config Enrichers configuration parsing and validation through parse_enrichers_config: YAML deserialization, per-type key checks, template namespaces, scope, and extract compilation. Building enrichers does I/O and is not fuzzed. Seeds in fuzz/corpus/fuzz_enrichers_config/ cover each built-in type and adversarial keys. Unreleased 65536
fuzz_input_formats The line-format parser (auto-detect, JSON, syslog, logfmt, CEF, plain). 4096
fuzz_rule_tune False-positive-driven rule tuning over JSON FP and TP corpora. 65536
fuzz_draft_groups Correlation draft grouping over grouped timed events (draft_correlation). 65536
fuzz_extract_jq jq extract language. 4096
fuzz_extract_jsonpath JSONPath extract language. 4096
fuzz_extract_cel CEL extract language. 4096
fuzz_template_expand The ${source.X} template expander. 4096
fuzz_include_parse Include-directive resolution. 8192
fuzz_http_response The dynamic-pipeline HTTP-response parsing path. 65536
fuzz_lint_fix Linter auto-fix application and reparsing. Not in the weekly matrix; run manually. (default)
fuzz_scorecard_promtext Detection scorecard Prometheus text parser. Not in the weekly matrix; run manually. (default)
fuzz_disposition_record Disposition record parsing. Not in the weekly matrix; run manually. (default)
fuzz_capture_spool Disposition capture spool documents (parse_manifest, parse_provenance, parse_corpus_events). 65536
fuzz_otlp_logs_decode OTLP log ingestion: protobuf decoding of ExportLogsServiceRequest (the body of POST /v1/logs and the gRPC LogsService message) and logs_request_to_raw_events, asserting every converted record is valid JSON. Seeds in fuzz/seeds/fuzz_otlp_logs_decode/ cover every AnyValue variant, many attributes, and nesting on both sides of prost’s recursion limit. Added in v0.25.0 65536
fuzz_risk_config Risk configuration parsing. Not in the weekly matrix; run manually. (default)
fuzz_lucene_frontend Lucene reverse-conversion frontend. Not in the weekly matrix; run manually. (default)
fuzz_stix_pattern STIX pattern parsing. 4096
fuzz_taxii_envelope TAXII envelope parsing, including object-count, nesting, and string-length limits. Seeds in fuzz/seeds/fuzz_taxii_envelope/ cover a valid envelope, a truncated envelope, and an oversized envelope. Unreleased 65536
fuzz_stix_source format: stix bundle build at a fixed clock. A successful build must be an object with every observable key as an array and an indicators object. Seeds in fuzz/seeds/fuzz_stix_source/ cover the source fixtures, a truncated bundle, duplicate ids, a 300-indicator bundle, and each unsupported pattern shape. Unreleased 262144
fuzz_stix_draft Rule drafting from a STIX bundle. Bytes are parsed as a bundle or one indicator, simple observables are read out, and draft_rule_from_values emits YAML that must parse. Seeds in fuzz/seeds/fuzz_stix_draft/ cover an indicator, a title and a URL that contain YAML metacharacters, and a truncated object. Unreleased 65536
fuzz_rstix_parse_bundle The rstix::parse_bundle STIX bundle parse entrypoint. Seed locally from tests/fixtures/spec/ or a downloaded ATT&CK bundle (see rstix: Local MITRE ATT&CK corpus test). 65536
fuzz_rstix_validate_json The rstix::Validator::validate_json_str Validation Pipeline raw JSON entry (validate feature). Seeds in fuzz/seeds/fuzz_rstix_validate_json/. 65536
fuzz_mmdb_record MMDB decoding and field projection (mmdb-enrich feature): MmdbDatabase::from_bytes over arbitrary bytes, then lookups for a fixed set of IPv4 and IPv6 addresses with no projection and with a projection that includes an array index. Seeds in fuzz/corpus/fuzz_mmdb_record/ cover the synthetic fixtures, a truncated file, a metadata-marker-only file, and a file with corrupted search-tree bytes. Unreleased 65536
fuzz_dns_answer DNS answer formatting and query-name normalization (dns-enrich feature): the first input byte selects a record type, the rest goes to DnsRecordType::format_answers as a wire-format response, and valid UTF-8 input also goes to query_name for that type and for PTR. Seeds in fuzz/corpus/fuzz_dns_answer/ cover one response per stub-zone case, a truncated response, a compression-pointer loop, a response with 300 answers, and key inputs with long labels, IDNA text, and IPv6 literals. Unreleased 4096
fuzz_ruleset_resolve Named ruleset resolution: the first input byte selects a spec, overlay list, or selector; validate_spec and resolve_loaded then run against embedded fixture rules with the inline-only overlay loader. Seeds in fuzz/seeds/fuzz_ruleset_resolve/ cover each mode, an invalid glob, deeply nested custom attributes, a 240-element tag list, a null patch, and unknown keys at every level. Unreleased 4096
fuzz_ocsf_sidecar Dedup sidecar OCSF serialization, risk-event mapping, and webhook JSON bodies. Arbitrary JSON goes to dedup_summary_finding_opts and, when it is a risk event, to risk_event_finding_opts, for schema 1.1.0 or 1.3.0. The same bytes are rendered with render_webhook_body, so ${detection.ocsf} and ${correlation.ocsf} are validated, including a reference inside a string. Seeds in fuzz/corpus/fuzz_ocsf_sidecar/ cover those shapes. The ${source.X} expander does not see webhook placeholders, so the seeds live on this target. Unreleased 8192

All targets live under fuzz/fuzz_targets/. The shared Cargo.toml is fuzz/Cargo.toml; it depends on rsigma-parser, rsigma-eval, rsigma-convert, rsigma-runtime (with logfmt, cef, otlp, mmdb-enrich, dns-enrich, and stix-source features), prost, and rstix (with serde, pattern, validate, and taxii features).

Run one target locally

Prefer the pinned nightly from CI (FUZZ_TOOLCHAIN in .github/workflows/fuzz.yml, currently nightly-2026-07-23). Floating nightly can fail under ASan:

rustup toolchain install nightly-2026-07-23 --profile minimal --component llvm-tools-preview
cargo +nightly-2026-07-23 install cargo-fuzz --locked

Then from the workspace root:

cargo +nightly-2026-07-23 fuzz run fuzz_parse_yaml -- -max_len=8192 -max_total_time=60

-max_total_time=60 runs for one minute; drop it for an open-ended loop. Run output prints cov: increments as new branches are discovered; a crash dumps the offending corpus entry under fuzz/artifacts/<target>/crash-<hash>.

Reproducing a crash

cargo +nightly-2026-07-23 fuzz run fuzz_parse_yaml fuzz/artifacts/fuzz_parse_yaml/crash-deadbeef...

You can also point a regular test at the offending bytes. Reducing the input via cargo fuzz tmin <target> <crash-path> before filing an issue is appreciated.

Adding a new harness

  1. Create fuzz/fuzz_targets/fuzz_<name>.rs:

    #![no_main]
    use libfuzzer_sys::fuzz_target;
    
    fuzz_target!(|data: &[u8]| {
        let Ok(s) = std::str::from_utf8(data) else { return; };
        let _ = rsigma_parser::parse_sigma_yaml(s);
    });
    
  2. Register it in fuzz/Cargo.toml:

    [[bin]]
    name = "fuzz_<name>"
    path = "fuzz_targets/fuzz_<name>.rs"
    doc = false
    
  3. Add an entry to the matrix in .github/workflows/fuzz.yml:

    - target: fuzz_<name>
      max_len: 4096
    
  4. Open a PR. The first weekly run will exercise the new harness for the default duration (180 seconds per target; tune via workflow_dispatch input).

When to fuzz

Add a harness when you accept untrusted input and the parsing or matching code is non-trivial:

  • A new input format (CEF, EVTX, …): add to fuzz_input_formats or a sibling.
  • A new extract language: mirror the fuzz_extract_* targets.
  • A new dynamic-source data format: extend fuzz_pipeline_sources_yaml or fuzz_http_response.
  • A new binary lookup format: mirror fuzz_mmdb_record.
  • A new condition operator: extend fuzz_condition.

Differential fuzz harnesses (fuzz_eval_matcher_diff) are the canonical guard against matcher-optimizer regressions; when you touch optimize_any_of or the Aho-Corasick fast path, run the diff harness before opening a PR.

Corpus

Seed corpora are committed under fuzz/seeds/<target>/. CI restores and saves fuzz/corpus/<target> between runs (cache key fuzz-corpus-<target>-…). On failure, crashes upload as a workflow artifact named fuzz-crashes-<target> (not the corpus). Download a crash artifact to reproduce locally with cargo fuzz run <target> path/to/crash.

See also