blob: 146b015edfb220cfae6de2b0ca8d106e9c58c491 [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
Hasnain Lakhani7ac79ab2025-08-25 14:40:43 -070024- Rust
Hasnain Lakhani4afb7d92025-08-25 16:09:41 -070025- Swift
Hasnain Lakhanic51ab5f2025-08-25 10:24:14 -070026
27We are working on adding fuzzers for the following languages:
28
Hasnain Lakhanic51ab5f2025-08-25 10:24:14 -070029- netstd
30
31## Fuzzer Types
32
33For each supported language, we implement at minimum:
34
351. **Deserializer Fuzzer**
36 - Takes raw fuzzer input and attempts to deserialize it into Thrift structures
37 - Tests handling of malformed/unexpected input
38 - Implemented for each supported protocol (Binary, Compact, JSON where available)
39
402. **Round-Trip Fuzzer**
41 - Deserializes fuzzer input, then re-serializes and verifies it matches
42 - Ensures data integrity through serialization cycles
43 - Tests both serialization and deserialization code paths
44
45## Building and Running the Fuzzers
46
47Each language has its own fuzzers under the `lib/<language>/test/fuzz` directory.
48The fuzzers are built when building the language-specific code (using the normal build system), as regular binaries (without fuzzing support enabled), to ensure that there are no build breakages.
49
50To ensure fuzzing can find issues as soon as possible, we will enable fuzzing support in CI once the fuzzers are stable.
51
52Currently the only convenient, formally supported build with fuzzing support enabled is the via the oss-fuzz workflow. For languages where local fuzzing is easy to do, documentation is provided along with the fuzzers.
53
54## OSS-Fuzz Integration
55
56Our fuzzers run continuously on OSS-Fuzz. To view build status:
57
581. Visit the [OSS-Fuzz Status Dashboard](https://oss-fuzz-build-logs.storage.googleapis.com/index.html)
592. Look for the "thrift" project
60
61The source code for the oss-fuzz build is [available upstream](https://github.com/google/oss-fuzz/tree/master/projects/thrift).
62
63We aim to improve the fuzzers through viewing the fuzz introspector reports, available [here](https://introspector.oss-fuzz.com/project-profile?project=thrift).
64
65*NB: The oss-fuzz integration will be significantly updated once all the language specific fuzzers are committed here.
66
67## Contributing to the fuzzers
68
69To 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,
70we would still appreciate contributions that:
71
721. Add new fuzzers for unsupported languages
732. Improve existing fuzzers
743. Add test cases to corpus
75
76If you do add or change a fuzzer, please remember to make corresponding changes to the oss-fuzz build script in case they are needed.
77
78Please see CONTRIBUTING.md for general contribution guidelines.