-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Improve thrift fuzzing support #13874
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
Open
mhlakhani
wants to merge
3
commits into
google:master
Choose a base branch
from
mhlakhani:thrift_fuzzing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM gcr.io/oss-fuzz-base/base-builder | ||
|
||
RUN apt-get update && apt-get install -y libssl-dev pkg-config autoconf automake libtool bison flex wget make zip cmake libglib2.0-dev patchelf | ||
|
||
#Install Boost from source | ||
RUN wget https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz && \ | ||
tar xzf boost_1_87_0.tar.gz && \ | ||
cd boost_1_87_0 && \ | ||
./bootstrap.sh --with-toolset=clang && \ | ||
./b2 clean && \ | ||
./b2 toolset=clang -j$(nproc) install && \ | ||
cd .. && \ | ||
rm -rf boost_1_87_0 | ||
|
||
COPY build.sh default.options $SRC/ | ||
|
||
RUN git clone --depth 1 https://github.com/apache/thrift.git | ||
|
||
WORKDIR $SRC/thrift |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash -eu | ||
# Copyright 2025 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
################################################################################ | ||
|
||
export ASAN_OPTIONS=detect_leaks=0 | ||
|
||
# Build and install the compiler (disable other languages to save time) | ||
./bootstrap.sh | ||
./configure --enable-static --disable-shared --with-cpp=no --with-c_glib=yes --with-python=no --with-py3=no --with-go=no --with-rs=no --with-java=no --with-nodejs=no --with-dotnet=no --with-kotlin=no | ||
make -j$(nproc) | ||
make install | ||
|
||
# Build c_glib library and fuzzers | ||
pushd lib/c_glib/test/fuzz | ||
make check | ||
for i in $(find . -maxdepth 1 -type f -executable -printf "%f\n"); do | ||
cp $i $OUT/$i | ||
cp $SRC/default.options $OUT/"$i".options; | ||
# Set rpath so fuzzers can find libraries | ||
patchelf --set-rpath '$ORIGIN/lib' $OUT/$i | ||
done | ||
popd | ||
|
||
# Copy libraries over for the c_glib fuzzers | ||
mkdir -p $OUT/lib | ||
cp /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 $OUT/lib/ | ||
cp /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 $OUT/lib/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[libfuzzer] | ||
detect_leaks=0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
homepage: "https://thrift.apache.org/" | ||
language: c | ||
primary_contact: "[email protected]" | ||
auto_ccs: | ||
- "[email protected]" | ||
- "[email protected]" | ||
|
||
fuzzing_engines: | ||
- libfuzzer | ||
- afl | ||
- honggfuzz | ||
- centipede | ||
sanitizers: | ||
- address | ||
- undefined | ||
|
||
main_repo: 'https://github.com/apache/thrift' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM gcr.io/oss-fuzz-base/base-builder | ||
|
||
RUN apt-get update && apt-get install -y libssl-dev pkg-config autoconf automake libtool bison flex wget make zip cmake | ||
|
||
# Install Boost from source | ||
RUN wget https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz && \ | ||
tar xzf boost_1_87_0.tar.gz && \ | ||
cd boost_1_87_0 && \ | ||
./bootstrap.sh --with-toolset=clang && \ | ||
./b2 clean && \ | ||
./b2 toolset=clang -j$(nproc) install && \ | ||
cd .. && \ | ||
rm -rf boost_1_87_0 | ||
|
||
COPY build.sh $SRC/ | ||
|
||
RUN git clone --depth 1 https://github.com/apache/thrift.git | ||
|
||
WORKDIR $SRC/thrift |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
homepage: "https://thrift.apache.org/" | ||
language: c++ | ||
primary_contact: "[email protected]" | ||
auto_ccs: | ||
- "[email protected]" | ||
- "[email protected]" | ||
|
||
fuzzing_engines: | ||
- libfuzzer | ||
- afl | ||
- honggfuzz | ||
- centipede | ||
sanitizers: | ||
- address | ||
- undefined | ||
|
||
main_repo: 'https://github.com/apache/thrift' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2025 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
################################################################################ | ||
|
||
FROM gcr.io/oss-fuzz-base/base-builder-go | ||
|
||
RUN apt-get update && apt-get install -y libssl-dev pkg-config autoconf automake libtool bison flex wget make | ||
|
||
# Install Boost from source | ||
RUN wget https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz && \ | ||
tar xzf boost_1_87_0.tar.gz && \ | ||
cd boost_1_87_0 && \ | ||
./bootstrap.sh --with-toolset=clang && \ | ||
./b2 clean && \ | ||
./b2 toolset=clang -j$(nproc) install && \ | ||
cd .. && \ | ||
rm -rf boost_1_87_0 | ||
|
||
COPY build.sh $SRC/ | ||
|
||
RUN git clone --depth 1 https://github.com/apache/thrift.git | ||
|
||
WORKDIR $SRC/thrift |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash -eu | ||
# Copyright 2025 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
################################################################################ | ||
|
||
export ASAN_OPTIONS=detect_leaks=0 | ||
|
||
if [[ ! -z "${CXX:-}" ]]; then | ||
export CXX="${CXX//-lresolv/}" | ||
fi | ||
|
||
# Build and install the compiler... | ||
# Disable other languages to save on compile time | ||
./bootstrap.sh | ||
# ... this forces go to be downloaded/installed, otherwise the configure script chokes when running go version | ||
go version | ||
./configure --enable-static --disable-shared --with-cpp=no --with-c_glib=no --with-python=no --with-py3=no --with-go=yes --with-rs=no --with-java=no --with-nodejs=no --with-dotnet=no --with-kotlin=no | ||
make -j$(nproc) | ||
|
||
pushd lib/go/test/fuzz | ||
|
||
make gopathfuzz | ||
compile_go_fuzzer . FuzzTutorial fuzz_tutorial | ||
compile_go_fuzzer . FuzzParseBinary fuzz_parse_binary | ||
compile_go_fuzzer . FuzzParseCompact fuzz_parse_compact | ||
compile_go_fuzzer . FuzzParseJson fuzz_parse_json | ||
compile_go_fuzzer . FuzzRoundtripBinary fuzz_roundtrip_binary | ||
compile_go_fuzzer . FuzzRoundtripCompact fuzz_roundtrip_compact | ||
compile_go_fuzzer . FuzzRoundtripJson fuzz_roundtrip_json | ||
|
||
popd |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
homepage: "https://thrift.apache.org/" | ||
language: go | ||
primary_contact: "[email protected]" | ||
auto_ccs: | ||
- "[email protected]" | ||
- "[email protected]" | ||
- "[email protected]" | ||
|
||
fuzzing_engines: | ||
- libfuzzer | ||
sanitizers: | ||
- address | ||
|
||
main_repo: 'https://github.com/apache/thrift' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM gcr.io/oss-fuzz-base/base-builder-jvm | ||
|
||
RUN apt-get update && apt-get install -y libssl-dev pkg-config autoconf automake libtool bison flex wget make ant zip curl | ||
|
||
# Install Boost from source | ||
RUN wget https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz && \ | ||
tar xzf boost_1_87_0.tar.gz && \ | ||
cd boost_1_87_0 && \ | ||
./bootstrap.sh --with-toolset=clang && \ | ||
./b2 clean && \ | ||
./b2 toolset=clang -j$(nproc) install && \ | ||
cd .. && \ | ||
rm -rf boost_1_87_0 | ||
|
||
# Download and install Gradle | ||
RUN cd /usr/local && \ | ||
curl -L https://services.gradle.org/distributions/gradle-8.13-bin.zip -o gradle-8.13-bin.zip && \ | ||
unzip gradle-8.13-bin.zip && \ | ||
rm gradle-8.13-bin.zip | ||
|
||
ENV GRADLE_HOME=/usr/local/gradle-8.13 | ||
ENV PATH=$PATH:$GRADLE_HOME/bin | ||
|
||
COPY build.sh $SRC/ | ||
|
||
RUN git clone --depth 1 https://github.com/apache/thrift.git | ||
|
||
WORKDIR $SRC/thrift |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash -eu | ||
# Copyright 2025 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
################################################################################ | ||
|
||
export ASAN_OPTIONS=detect_leaks=0 | ||
|
||
# Build and install the compiler (disable other languages to save time) | ||
./bootstrap.sh | ||
./configure --enable-static --disable-shared --with-cpp=no --with-c_glib=no --with-python=no --with-py3=no --with-go=no --with-rs=no --with-java=yes --with-nodejs=no --with-dotnet=no --with-kotlin=no | ||
make -j$(nproc) | ||
make install | ||
|
||
# Build Java library and fuzzers | ||
pushd lib/java | ||
make check | ||
cp build/libs/*.jar $OUT/ | ||
|
||
# Dynamically find the built jar files to be version-agnostic | ||
MAIN_JAR=$(find build/libs -name "libthrift-*.jar" -not -name "*-test.jar" -not -name "*-sources.jar" -not -name "*-javadoc.jar" | head -n1 | xargs basename) | ||
TEST_JAR=$(find build/libs -name "libthrift-*-test.jar" | head -n1 | xargs basename) | ||
|
||
# Verify jars were found | ||
if [[ -z "$MAIN_JAR" || -z "$TEST_JAR" ]]; then | ||
echo "Error: Could not find required jar files" | ||
echo "Main jar: $MAIN_JAR" | ||
echo "Test jar: $TEST_JAR" | ||
echo "Available jars:" | ||
find build/libs -name "*.jar" | ||
exit 1 | ||
fi | ||
|
||
PROJECT_JARS="$MAIN_JAR $TEST_JAR" | ||
echo "Using jars: $PROJECT_JARS" | ||
|
||
RUNTIME_CLASSPATH=$(echo $PROJECT_JARS | xargs printf -- "$OUT/%s:"):$JAZZER_API_PATH | ||
|
||
# Package each fuzzer | ||
for fuzzer in $(find $SRC -name '*Fuzzer.java'); do | ||
fuzzer_basename=$(basename -s .java $fuzzer) | ||
echo "#!/bin/bash | ||
# LLVMFuzzerTestOneInput for fuzzer detection. | ||
this_dir=\$(dirname \"\$0\") | ||
if [[ \"$@\" =~ (^| )-runs=[0-9]+($| ) ]]; then | ||
mem_settings='-Xmx1900m:-Xss900k' | ||
else | ||
mem_settings='-Xmx2048m:-Xss1024k' | ||
fi | ||
export JVM_LD_LIBRARY_PATH=$JAVA_HOME/lib/server | ||
export PATH=$JAVA_HOME/bin:$PATH | ||
LD_LIBRARY_PATH=\"$JVM_LD_LIBRARY_PATH\":\$this_dir \ | ||
\$this_dir/jazzer_driver --agent_path=\$this_dir/jazzer_agent_deploy.jar \ | ||
--cp=$RUNTIME_CLASSPATH \ | ||
--target_class=org.apache.thrift.test.fuzz.$fuzzer_basename \ | ||
--jvm_args=\"\$mem_settings:-Djava.awt.headless=true\" \ | ||
\$@" > $OUT/$fuzzer_basename | ||
chmod +x $OUT/$fuzzer_basename | ||
done | ||
popd |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
homepage: "https://thrift.apache.org/" | ||
language: jvm | ||
primary_contact: "[email protected]" | ||
auto_ccs: | ||
- "[email protected]" | ||
- "[email protected]" | ||
|
||
fuzzing_engines: | ||
- libfuzzer | ||
sanitizers: | ||
- address | ||
|
||
main_repo: 'https://github.com/apache/thrift' |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's something wrong with these fuzzers and I am not sure if I'm doing something stupid (probably am) or if there's an oss-fuzz bug.
Concretely, I can build and run these fuzzers fine locally if I do e.g.
this outputs something like
Notably, you can see
org.apache.thrift.test.fuzz.ParseJSONFuzzer
was instrumented!However, if I run
python3 infra/helper.py check_build thrift-java
it fails, with an error like the below, complaining about the exact same class