Headline
CVE-2023-30845: move x-http-method-override to beginning of filter chain (#801) · GoogleCloudPlatform/esp-v2@e956701
ESPv2 is a service proxy that provides API management capabilities using Google Service Infrastructure. ESPv2 2.20.0 through 2.42.0 contains an authentication bypass vulnerability. API clients can craft a malicious X-HTTP-Method-Override
header value to bypass JWT authentication in specific cases.
ESPv2 allows malicious requests to bypass authentication if both the conditions are true: The requested HTTP method is not in the API service definition (OpenAPI spec or gRPC google.api.http
proto annotations, and the specified X-HTTP-Method-Override
is a valid HTTP method in the API service definition. ESPv2 will forward the request to your backend without checking the JWT. Attackers can craft requests with a malicious X-HTTP-Method-Override
value that allows them to bypass specifying JWTs. Restricting API access with API keys works as intended and is not affected by this vulnerability.
Upgrade deployments to release v2.43.0 or higher to receive a patch. This release ensures that JWT authentication occurs, even when the caller specifies x-http-method-override
. x-http-method-override
is still supported by v2.43.0+. API clients can continue sending this header to ESPv2.
@@ -0,0 +1,59 @@
// Copyright 2023 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.
#include “api/envoy/v11/http/header_sanitizer/config.pb.h”
#include “api/envoy/v11/http/header_sanitizer/config.pb.validate.h”
#include “envoy/registry/registry.h”
#include “source/extensions/filters/http/common/factory_base.h”
#include “src/envoy/http/header_sanitizer/filter.h”
namespace espv2 {
namespace envoy {
namespace http_filters {
namespace header_sanitizer {
constexpr const char kFilterName[] =
"com.google.espv2.filters.http.header_sanitizer";
/**
* Config registration for ESPv2 header sanitizer filter.
*/
class FilterFactory
: public Envoy::Extensions::HttpFilters::Common::FactoryBase<
::espv2::api::envoy::v11::http::header_sanitizer::FilterConfig> {
public:
FilterFactory() : FactoryBase(kFilterName) {}
private:
Envoy::Http::FilterFactoryCb createFilterFactoryFromProtoTyped(
const ::espv2::api::envoy::v11::http::header_sanitizer::FilterConfig&,
const std::string&,
Envoy::Server::Configuration::FactoryContext&) override {
return [](Envoy::Http::FilterChainFactoryCallbacks& callbacks) -> void {
auto filter = std::make_shared<Filter>();
callbacks.addStreamDecoderFilter(filter);
};
}
};
/**
* Static registration for the filter. @see RegisterFactory.
*/
static Envoy::Registry::RegisterFactory<
FilterFactory, Envoy::Server::Configuration::NamedHttpFilterConfigFactory>
register_;
} // namespace header_sanitizer
} // namespace http_filters
} // namespace envoy
} // namespace espv2