libsodium: add harnesses for KEM, ipcrypt, HKDF, SHA-3/XOF, pwhash, stream, secretstream, etc.#73
Open
tc-agent wants to merge 2 commits into
Open
libsodium: add harnesses for KEM, ipcrypt, HKDF, SHA-3/XOF, pwhash, stream, secretstream, etc.#73tc-agent wants to merge 2 commits into
tc-agent wants to merge 2 commits into
Conversation
Fuzzing Coverage ReportTested: project OSS-Fuzz: Fuzz Introspector · build status
Per-harness
Δ = (after − before) / before, to accommodate that denominators may change. "new" when before is 0; "deleted" when after is 0. |
tc-agent
force-pushed
the
master
branch
3 times, most recently
from
May 28, 2026 18:05
af7f9a7 to
806b281
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.
Summary
Expands the libsodium fuzzing surface with 13 new harnesses and broadens the
existing crypto_box, crypto_secretbox, and crypto_sign harnesses to exercise
their non-_easy APIs. The existing surface only covered ~8 primitives
(AEAD, box, secretbox, generichash, kdf, kx, sign, secret_key_auth);
substantial primitive families had no harness at all.
Fuzz Introspector baseline
https://introspector.oss-fuzz.com/project-profile?project=libsodium
(report dated 2026-05-19): runtime line coverage 51.89% (5524/10646),
static reachability 24.64%, function coverage 46.00%, fuzzer count 8.
https://storage.googleapis.com/oss-fuzz-coverage/libsodium/reports/20260519/linux/src/libsodium/src/libsodium/report.html
shows several whole subdirectories at very low coverage that no existing
harness reached, e.g. crypto_pwhash/ 1.45% (Argon2 / scrypt entirely
untouched), crypto_box/ 0.00%, crypto_stream/ 31.34%,
crypto_kdf/ 35.29%, sodium/ 27.46%.
New harnesses (13)
drive the encoded-string parser. Uses MIN ops/mem.
XChaCha20 XOR round-trip with offset variant.
flipped-tag verify rejection.
mult, point validation, _from_uniform, scalar reduce/negate/invert, ed25519
add/sub - all on attacker-controlled bytes.
push/pull with TAG_MESSAGE / TAG_PUSH / TAG_REKEY / TAG_FINAL mix.
through seal_open.
sodium_bin2base64/_base642bin (all 4 variants), sodium_compare/_increment/
_add/_sub/_is_zero, sodium_ip2bin.
the streaming _extract_init/_update/_final form.
_enc/_enc_deterministic, _dec, plus attacker-controlled ciphertext through
_dec to exercise the implicit-rejection branch.
xchacha20poly1305 secretbox round-trip + sealed-box variant.
one-shot vs streaming equivalence.
multiple key-length classes plus flipped-tag verify rejection.
All new harnesses gate on a selector byte from the fuzzer input so the same
input shape exercises several primitives, and they round-trip / cross-check
where applicable so libfuzzer sees a useful signal beyond "does not crash".
Modifications to existing harnesses
the precomputed _beforenm/_easy_afternm path. The _easy variants delegate
around box_curve25519xsalsa20poly1305.c, so the previous harness left it
uncovered.
crypto_secretbox/_open API to reach crypto_secretbox.c and
secretbox_xsalsa20poly1305.c.
crypto_sign/crypto_sign_open API, and the pk_to_curve25519/sk_to_curve25519/
sk_to_seed/sk_to_pk conversions.
Local coverage
After 5 minutes of fuzz_for_pr per harness:
Largest per-subdirectory deltas vs baseline (accumulated corpus):
The remaining gap is largely CPU-dispatch siblings linked into the static
library that never execute on this CPU (e.g.
argon2-fill-block-{ref,ssse3,avx512f}.c - only the AVX2 variant runs;
chacha20_ref.c, softaes.c, crypto_ipcrypt/ipcrypt_soft.c, poly1305_donna64.h,
pwhash_scryptsalsa208sha256_nosse.c, blake2b-compress-{ref,ssse3}.c).