Skip to content

Commit f190f05

Browse files
authored
fuzz: fix oss crash on http utility function (envoyproxy#11687)
Commit Message: Fix crash on initializeAndValidateOptions fuzz test the crash occurred because validateCustomSettingsParameters does not allow duplicate custom settings identifiers and the fuzzer fed it an input that had duplicates. fixed by catching expected exceptions from duplicate custom settings identifiers. Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23616 Signed-off-by: Sam Flattery <[email protected]>
1 parent 549d30e commit f190f05

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

test/common/http/utility_corpus/clusterfuzz-testcase-minimized-utility_fuzz_test-5091558495092736

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/common/http/utility_corpus/valid

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/common/http/utility_fuzz_test.cc

+22-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,28 @@ DEFINE_PROTO_FUZZER(const test::common::http::UtilityTestCase& input) {
7979
}
8080
case test::common::http::UtilityTestCase::kInitializeAndValidate: {
8181
const auto& options = input.initialize_and_validate();
82-
Http2::Utility::initializeAndValidateOptions(options);
82+
try {
83+
Http2::Utility::initializeAndValidateOptions(options);
84+
} catch (EnvoyException& e) {
85+
absl::string_view msg = e.what();
86+
// initializeAndValidateOptions throws exceptions for 4 different reasons due to malformed
87+
// settings, so check for them and allow any other exceptions through
88+
if (absl::StartsWith(
89+
msg, "server push is not supported by Envoy and can not be enabled via a SETTINGS "
90+
"parameter.") ||
91+
absl::StartsWith(
92+
msg, "the \"allow_connect\" SETTINGS parameter must only be configured through the "
93+
"named field") ||
94+
absl::StartsWith(
95+
msg, "inconsistent HTTP/2 custom SETTINGS parameter(s) detected; identifiers =") ||
96+
absl::EndsWith(
97+
msg, "HTTP/2 SETTINGS parameter(s) can not be configured through both named and "
98+
"custom parameters")) {
99+
ENVOY_LOG_MISC(trace, "Caught exception {} in initializeAndValidateOptions test", e.what());
100+
} else {
101+
throw EnvoyException(e.what());
102+
}
103+
}
83104
break;
84105
}
85106

0 commit comments

Comments
 (0)