Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage-based fuzzing for network message processing, (de)serialization #2299

Closed
1 task
Tracked by #3247 ...
dconnolly opened this issue Jun 14, 2021 · 1 comment
Closed
1 task
Tracked by #3247 ...
Labels
A-devops Area: Pipelines, CI/CD and Dockerfiles A-network Area: Network protocol updates or fixes A-rust Area: Updates to Rust code C-security Category: Security issues I-heavy Problems with excessive memory, disk, or CPU usage I-invalid-data Zebra relies on invalid or untrusted data, or sends invalid data

Comments

@dconnolly
Copy link
Contributor

dconnolly commented Jun 14, 2021

Motivation

We currently test network message (de)serialization and processing to a degree with structured property-based testing and unit testing. Structured proptests utilize test data that is correct, up to a point. While this is useful testing, we do want to cover more edge cases and abstraction/assumption mismatches.

Solution

We'd like to set up a coverage-based fuzzing harness to exercise network message (de)serialization and processing. Fuzzing helps find logic and correctness bugs, even in a memory-safe language like Rust.

cargo-fuzz is the defacto standard tool, it wraps libFuzzer and has support for other fuzzing libraries, and builds well into a cargo crate/workspace.

They have a handy book to get started. There is also recent support for something closer to proptests, with structure-aware fuzzing.

auto-fuzz-test exists, but may collide with our use of proptest::Arbitrary or make code difficult to parse for humans.

We should at least:

  • Have a test harness for shoving random bytes into Message implementations of ZcashDeserialize, From, etc

We can run this coverage are purely part of our CI, or we can consider integrating our fuzzing harnesses into oss-fuzz, for free, continuous fuzzing.

Alternatives

Keep pushing non-coverage-guided random data though code paths with our proptest framework. This may get us less bang for our buck.

Related Work

Merging the coverage data from coverage-based fuzzing with the rest of our test coverage data is possible, as they use the same llvm internals under the hood, but may be annoying should be easy with CodeCov, could be considered out of scope for this ticket.

#2298 is very similar.

@dconnolly dconnolly added C-enhancement Category: This is an improvement S-needs-triage Status: A bug report needs triage A-devops Area: Pipelines, CI/CD and Dockerfiles A-rust Area: Updates to Rust code P-Low and removed C-enhancement Category: This is an improvement S-needs-triage Status: A bug report needs triage labels Jun 14, 2021
@teor2345 teor2345 added A-network Area: Network protocol updates or fixes C-enhancement Category: This is an improvement C-security Category: Security issues I-invalid-data Zebra relies on invalid or untrusted data, or sends invalid data I-heavy Problems with excessive memory, disk, or CPU usage S-needs-triage Status: A bug report needs triage and removed C-enhancement Category: This is an improvement labels Jun 14, 2021
@dconnolly dconnolly added P-Medium and removed P-Low labels Jun 14, 2021
@mpguerra mpguerra removed the S-needs-triage Status: A bug report needs triage label Jun 17, 2021
@gustavovalverde gustavovalverde removed their assignment May 24, 2022
@teor2345
Copy link
Contributor

This isn't on our forward planning lists, we can re-open it if it is.

@teor2345 teor2345 closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-devops Area: Pipelines, CI/CD and Dockerfiles A-network Area: Network protocol updates or fixes A-rust Area: Updates to Rust code C-security Category: Security issues I-heavy Problems with excessive memory, disk, or CPU usage I-invalid-data Zebra relies on invalid or untrusted data, or sends invalid data
Projects
None yet
Development

No branches or pull requests

4 participants