blob: 08afed8ccfa1cb232758f842b1c1647dcbe6e5b1 [file] [log] [blame] [view]
Hasnain Lakhanic51ab5f2025-08-25 10:24:14 -07001# Fuzzing Apache Thrift
2
3This document describes the fuzzing infrastructure and goals for Apache Thrift.
4
5We use [OSS-Fuzz](https://github.com/google/oss-fuzz) as our primary fuzzing platform to continuously test and improve the robustness of Thrift's hand-written and generated code.
6
7## Goals
8
9With fuzzing, we are focusing on testing the following key aspects across supported languages:
10
111. Security - Testing how the generated code handles malformed/malicious input
122. Serialization round-trip correctness - Ensuring that data stays identical if we serialize then deserialize it.
13
14## Supported Languages
15
16We currently maintain fuzzers for the following languages:
17
Hasnain Lakhani9b136682025-08-25 11:54:23 -070018- Go
Hasnain Lakhanicf41a1c2025-08-25 10:55:35 -070019- c_glib (partially supported, needs round-trip support)
Hasnain Lakhani37f4e0d2025-08-25 11:21:33 -070020- C++
Hasnain Lakhani4f877ca2025-08-25 13:24:26 -070021- Java/JVM (and other JVM languages)
Hasnain Lakhaniaa183322025-08-25 13:54:33 -070022- JavaScript
Hasnain Lakhanid2743002025-08-25 14:22:15 -070023- Python
Dmytro Shteflyuk60417982026-03-14 02:12:29 -040024- Ruby
Hasnain Lakhani7ac79ab2025-08-25 14:40:43 -070025- Rust
Hasnain Lakhani4afb7d92025-08-25 16:09:41 -070026- Swift
Hasnain Lakhanic51ab5f2025-08-25 10:24:14 -070027
28We are working on adding fuzzers for the following languages:
29
Hasnain Lakhanic51ab5f2025-08-25 10:24:14 -070030- netstd
31
32## Fuzzer Types
33
34For each supported language, we implement at minimum:
35
361. **Deserializer Fuzzer**
37 - Takes raw fuzzer input and attempts to deserialize it into Thrift structures
38 - Tests handling of malformed/unexpected input
39 - Implemented for each supported protocol (Binary, Compact, JSON where available)
40
412. **Round-Trip Fuzzer**
42 - Deserializes fuzzer input, then re-serializes and verifies it matches
43 - Ensures data integrity through serialization cycles
44 - Tests both serialization and deserialization code paths
45
46## Building and Running the Fuzzers
47
48Each language has its own fuzzers under the `lib/<language>/test/fuzz` directory.
Dmytro Shteflyuk60417982026-03-14 02:12:29 -040049Build integration varies by language. C++, c_glib, Go, Rust, and Ruby wire fuzz code into their normal build systems so that code generation and build drift are caught early. Some languages also provide local runner targets or native fuzz binaries.
Hasnain Lakhanic51ab5f2025-08-25 10:24:14 -070050
51To ensure fuzzing can find issues as soon as possible, we will enable fuzzing support in CI once the fuzzers are stable.
52
Dmytro Shteflyuk60417982026-03-14 02:12:29 -040053Currently the only convenient, formally supported build with fuzzing support enabled is via the oss-fuzz workflow. For languages where local fuzzing is practical, documentation is provided alongside the fuzzers. For example, C++ builds libFuzzer binaries directly, while Ruby exposes `make` targets that wrap Ruzzy.
Hasnain Lakhanic51ab5f2025-08-25 10:24:14 -070054
55## OSS-Fuzz Integration
56
57Our fuzzers run continuously on OSS-Fuzz. To view build status:
58
591. Visit the [OSS-Fuzz Status Dashboard](https://oss-fuzz-build-logs.storage.googleapis.com/index.html)
602. Look for the "thrift" project
61
62The source code for the oss-fuzz build is [available upstream](https://github.com/google/oss-fuzz/tree/master/projects/thrift).
63
64We aim to improve the fuzzers through viewing the fuzz introspector reports, available [here](https://introspector.oss-fuzz.com/project-profile?project=thrift).
65
66*NB: The oss-fuzz integration will be significantly updated once all the language specific fuzzers are committed here.
67
68## Contributing to the fuzzers
69
70To contribute to the fuzzing effort - please look at https://issues.apache.org/jira/browse/THRIFT-5855 for the latest status and planned work. Once the ticket is closed,
71we would still appreciate contributions that:
72
731. Add new fuzzers for unsupported languages
742. Improve existing fuzzers
753. Add test cases to corpus
76
77If you do add or change a fuzzer, please remember to make corresponding changes to the oss-fuzz build script in case they are needed.
78
Dmytro Shteflyuk60417982026-03-14 02:12:29 -040079Please see CONTRIBUTING.md for general contribution guidelines.