Fuzzing

The fuzz targets that run on engine changes and every night, what they cover, and how to reproduce a crash.

fuzz/ holds cargo-fuzz (libFuzzer) targets, kept outside the default workspace. They feed random bytes to the parts of Strig that read input you do not control.

What is covered#

TargetCoversProperty checked
dsl_parseThe policy-language parserArbitrary text.
dsl_formatThe policy formatterIdempotent: formatting twice gives what formatting once gives.
dsl_convertConversion between Blocks, Rules and ActorsRound trip between the three syntaxes.
spec_jsonEngineSpec JSONArbitrary JSON.
condition_evalCondition evaluationArbitrary conditions and values.
decideDecisionsNever an allow without a candidate grant.
sync_protocolReal-time protocol messagesArbitrary messages.
server_wireDecision-server messagesArbitrary messages.
audit_chainAudit chain verificationArbitrary records.

Run one#

You need the nightly toolchain and cargo-fuzz:

Terminal
rustup toolchain install nightly
cargo install cargo-fuzz
./fuzz/run.sh dsl_convert 120     # one target for 120 seconds, seeded from fuzz/seeds

The seeds in fuzz/seeds are versioned. The corpus libFuzzer grows (fuzz/corpus), fuzz/artifacts and fuzz/target are not.

When it finds a crash#

libFuzzer writes the input to fuzz/artifacts/<target>/. Reproduce it with:

Terminal
cargo +nightly fuzz run <target> fuzz/artifacts/<target>/<file>

Fix it with a regression test in the ordinary suite, and mention the crash in the pull request.

In CI#

The fuzz workflow runs a short round on pull requests that touch the engine, sync, server or fuzz/, and a long one every night, keeping the crash as an artifact.