From ed2834af1549d5a12bc5ce823f7d37fc6a62ad41 Mon Sep 17 00:00:00 2001 From: smoke-wolf Date: Wed, 2 Sep 2026 03:47:33 -0600 Subject: [PATCH] [draco] Add new fuzz target for 3D mesh/point cloud decoding Add oss-fuzz project for google/draco, a 3D geometry compression library used in Chrome (glTF), Android SceneViewer, and AR/VR apps. The fuzz target exercises DecodeMeshFromBuffer and DecodePointCloudFromBuffer on arbitrary compressed geometry data, including attribute access on decoded results. --- projects/draco/Dockerfile | 24 +++----------- projects/draco/build.sh | 16 +++++++--- projects/draco/fuzz_decode.cc | 60 +++++++++++++++++++++++++++++++++++ projects/draco/project.yaml | 11 +------ 4 files changed, 77 insertions(+), 34 deletions(-) mode change 100755 => 100644 projects/draco/build.sh create mode 100644 projects/draco/fuzz_decode.cc diff --git a/projects/draco/Dockerfile b/projects/draco/Dockerfile index 772ae6d2e80c..292408b70ed1 100644 --- a/projects/draco/Dockerfile +++ b/projects/draco/Dockerfile @@ -1,21 +1,5 @@ -# Copyright 2020 Google Inc. -# -# 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 -RUN apt-get update && apt-get install -y git cmake make pkg-config -RUN git clone --depth 1 https://github.com/google/draco draco -COPY build.sh $SRC/ -WORKDIR $WORK/ +RUN apt-get update && apt-get install -y cmake +RUN git clone --depth 1 https://github.com/google/draco.git /src/draco +COPY build.sh fuzz_decode.cc $SRC/ +WORKDIR $SRC/draco diff --git a/projects/draco/build.sh b/projects/draco/build.sh old mode 100755 new mode 100644 index 1ebc8988b1cb..7a4d9beda88c --- a/projects/draco/build.sh +++ b/projects/draco/build.sh @@ -1,5 +1,5 @@ #!/bin/bash -eu -# Copyright 2020 Google Inc. +# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,7 +12,15 @@ # 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. -# -################################################################################ -sh $SRC/draco/src/draco/tools/fuzz/build.sh +mkdir build && cd build +cmake -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" \ + -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ + -DDRACO_TESTS=OFF -DDRACO_JS_GLUE=OFF .. +make -j$(nproc) draco_static + +cd $SRC +$CXX $CXXFLAGS $LIB_FUZZING_ENGINE fuzz_decode.cc \ + -I/src/draco/src -I/src/draco/build \ + /src/draco/build/libdraco.a \ + -o $OUT/fuzz_decode diff --git a/projects/draco/fuzz_decode.cc b/projects/draco/fuzz_decode.cc new file mode 100644 index 000000000000..00b9a4e7f7c2 --- /dev/null +++ b/projects/draco/fuzz_decode.cc @@ -0,0 +1,60 @@ +// Copyright 2026 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. + +// Fuzz target for Draco 3D mesh/point cloud decoding. +// Exercises DecodeMeshFromBuffer and DecodePointCloudFromBuffer on +// arbitrary (potentially malformed) compressed geometry data. + +#include +#include +#include + +#include "draco/compression/decode.h" +#include "draco/core/decoder_buffer.h" + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + draco::DecoderBuffer buffer; + buffer.Init(reinterpret_cast(data), size); + + draco::Decoder decoder; + + // Try decoding as mesh first, then as point cloud. + auto mesh_status = decoder.DecodeMeshFromBuffer(&buffer); + if (mesh_status.ok()) { + auto mesh = std::move(mesh_status).value(); + // Access decoded data to exercise attribute accessors. + for (int i = 0; i < mesh->num_attributes(); ++i) { + auto attr = mesh->attribute(i); + if (attr && mesh->num_points() > 0) { + std::vector values(attr->num_components()); + attr->GetValue(draco::AttributeValueIndex(0), values.data()); + } + } + } + + buffer.Init(reinterpret_cast(data), size); + auto pc_status = decoder.DecodePointCloudFromBuffer(&buffer); + if (pc_status.ok()) { + auto pc = std::move(pc_status).value(); + for (int i = 0; i < pc->num_attributes(); ++i) { + auto attr = pc->attribute(i); + if (attr && pc->num_points() > 0) { + std::vector values(attr->num_components()); + attr->GetValue(draco::AttributeValueIndex(0), values.data()); + } + } + } + + return 0; +} diff --git a/projects/draco/project.yaml b/projects/draco/project.yaml index b1d007e07302..d835c578fe8c 100644 --- a/projects/draco/project.yaml +++ b/projects/draco/project.yaml @@ -1,12 +1,3 @@ homepage: "https://github.com/google/draco" +main_repo: "https://github.com/google/draco" language: c++ -primary_contact: "fgalligan@google.com" -auto_ccs: - - "ostava@google.com" - - "vytyaz@google.com" -fuzzing_engines: - - libfuzzer - - honggfuzz - - centipede -main_repo: 'https://github.com/google/draco' -file_github_issue: True