feat: add fuzzing harness and infrastructure #442
Merged
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.
All Submissions:
New Feature Submissions:
Changes to Core Features:
🔍 What This PR Does
This PR introduces native fuzz testing support to CryptoLib. The implementation is designed to help uncover memory safety issues and logic bugs across core security-related APIs. This is in response to Issue #369.
🧪 Included in This PR
A fuzzing harness (
fuzz_harness.c
) based onLLVMFuzzerTestOneInput
, targeting 7 critical API functions:Crypto_TC_ApplySecurity
Crypto_TC_ProcessSecurity
Crypto_TM_ApplySecurity
Crypto_TM_ProcessSecurity
Crypto_AOS_ApplySecurity
Crypto_AOS_ProcessSecurity
Crypto_TC_Parse_Check_FECF
Persistent mode support with a
reset_cryptolib()
to ensure state isolation per fuzz iteration.Corpus generation script (
generate_corpus.py
) to seed fuzzing campaigns with protocol-valid frames across TC, TM, and AOS.Multithreaded fuzzing launcher (
run-fuzz-multithreaded.sh
) using AFL++ best practices:screen
sessionsafl-whatsup
Build script (
build-fuzz.sh
) compiling 4 fuzz-targeted instrumented builds:-march=native
, AVX2/FMA,-flto
, etc.CMake integration via
ENABLE_FUZZING
toggle.🧪 How to Test These Changes
cd fuzz/scripts ./build-fuzz.sh
cd ../ python generate_corpus.py
📌 Additional Notes
The fuzzing corpus currently uses a basic randomized generator. There is room for future enhancement using protocol-aware or coverage-guided corpus generation techniques.
This was developed as part of my master’s thesis, which focuses on evaluating the security of open-source software for satellite systems. Although designed as a PoC, it has reached ~78% code coverage and already helped uncover multiple vulnerabilities (
CVE-2025-29909
,CVE-2025-29910
,CVE-2025-29911
,CVE-2025-29912
,CVE-2025-29913
).The implementation needs some improvements to be extended or integrated into a CI/CD pipeline with further performance and coverage optimizations.