Skip to content

Add support to fuzz proto data in uber filter fuzzer#10796

Merged
mattklein123 merged 13 commits intoenvoyproxy:masterfrom
nareddyt:fuzz-proto-body
May 13, 2020
Merged

Add support to fuzz proto data in uber filter fuzzer#10796
mattklein123 merged 13 commits intoenvoyproxy:masterfrom
nareddyt:fuzz-proto-body

Conversation

@nareddyt
Copy link
Contributor

@nareddyt nareddyt commented Apr 15, 2020

Description: The uber filter fuzzer is not very efficient in fuzzing decodeData with serialized proto bodies. Add some specialized logic that allows libprotobufmutator to generate google.protobuf.Any messages. Uber filter fuzzer then uses the serialized value as the data for decodeData. This should allow better fuzz coverage in the gRPC Transcoding filter.

Risk Level: None

Testing: Ran against sample corpus with debug logs and ensured corpus was parsed correctly, correct decoder functions were called, and filters were not rejecting proto data. Ran with_libfuzzer for 5 minutes and ensured crashes were unrelated to the proto data.

Docs Changes: None

Release Notes: None

@nareddyt nareddyt marked this pull request as draft April 15, 2020 20:24
@nareddyt
Copy link
Contributor Author

@vitalybuka @asraa: Note the oneof changes the wire compatibility of the proto, resulting in the corpus breaking.

How do we handle this:

  • Just let OSS-Fuzz re-generate the corpus?
  • Or try not to make this breaking change and make the proto/fuzzer a little messier?

nareddyt added a commit to nareddyt/libprotobuf-mutator that referenced this pull request Apr 17, 2020
As discussed in envoyproxy/envoy#10796, this will allow breaking wire-compatibility changes in the input proto. The pre-existing corpus will still function, but old fields will be ignored.

Risk: Typos in the text proto will cause the fuzzer to run on an incomplete proto. Previously, this would log an error message and skip fuzzing with that test case.
vitalybuka pushed a commit to google/libprotobuf-mutator that referenced this pull request Apr 23, 2020
As discussed in envoyproxy/envoy#10796, this will allow breaking wire-compatibility changes in the input proto. The pre-existing corpus will still function, but old fields will be ignored.

Risk: Typos in the text proto will cause the fuzzer to run on an incomplete proto. Previously, this would log an error message and skip fuzzing with that test case.
@nareddyt nareddyt marked this pull request as ready for review April 23, 2020 20:40
@nareddyt nareddyt requested a review from asraa April 23, 2020 20:41
@nareddyt
Copy link
Contributor Author

FYI we found a bug in protobuf and are waiting for a fix to propagate to Github - google/libprotobuf-mutator#172

@nareddyt nareddyt force-pushed the fuzz-proto-body branch from 1eded16 to c70d817 Compare May 6, 2020 18:57
nareddyt added 6 commits May 6, 2020 12:05
Signed-off-by: Teju Nareddy <nareddyt@google.com>
Signed-off-by: Teju Nareddy <nareddyt@google.com>
Signed-off-by: Teju Nareddy <nareddyt@google.com>
Signed-off-by: Teju Nareddy <nareddyt@google.com>
Signed-off-by: Teju Nareddy <nareddyt@google.com>
Signed-off-by: Teju Nareddy <nareddyt@google.com>
@nareddyt nareddyt force-pushed the fuzz-proto-body branch from c70d817 to 07f9a9f Compare May 6, 2020 19:05
@nareddyt
Copy link
Contributor Author

nareddyt commented May 6, 2020

Sorry for the force push, I rebased instead of merging earlier

@nareddyt nareddyt changed the title [WIP] Add support to fuzz proto data in uber filter fuzzer Add support to fuzz proto data in uber filter fuzzer May 6, 2020
@nareddyt nareddyt requested a review from asraa May 6, 2020 19:06
Signed-off-by: Teju Nareddy <nareddyt@google.com>
Copy link
Contributor

@asraa asraa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this looks amazing! Some organization clean-up, but LGTM!

Signed-off-by: Teju Nareddy <nareddyt@google.com>
@nareddyt nareddyt requested a review from asraa May 12, 2020 18:00
Signed-off-by: Teju Nareddy <nareddyt@google.com>
Copy link
Contributor

@asraa asraa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This looks amazing. Really excited about it.

nareddyt added 3 commits May 12, 2020 12:34
Signed-off-by: Teju Nareddy <nareddyt@google.com>
Signed-off-by: Teju Nareddy <nareddyt@google.com>
Signed-off-by: Teju Nareddy <nareddyt@google.com>
@nareddyt nareddyt requested a review from asraa May 12, 2020 19:40
Signed-off-by: Teju Nareddy <nareddyt@google.com>
// These types are request/response from the test Bookstore service
// for the gRPC Transcoding filter.
static const std::vector<std::string> expected_types = {
"type.googleapis.com/bookstore.ListShelvesResponse",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For later, I wonder if these types can be picked up via reflection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I didn't think of that. I did some initial research and it seems feasible. Lets do that in another PR later, if we end up needing to fuzz test with proto data for any other filters.

Copy link
Contributor

@asraa asraa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you.

@mattklein123 mattklein123 merged commit 5ef1007 into envoyproxy:master May 13, 2020
@nareddyt nareddyt deleted the fuzz-proto-body branch May 13, 2020 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants