Skip to content
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

tls: disable TLS inspector injection #14404

Merged
merged 2 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Minor Behavior Changes
* http: upstream protocol will now only be logged if an upstream stream was established.
* jwt_authn filter: added support of Jwt time constraint verification with a clock skew (default to 60 seconds) and added a filter config field :ref:`clock_skew_seconds <envoy_v3_api_field_extensions.filters.http.jwt_authn.v3.JwtProvider.clock_skew_seconds>` to configure it.
* kill_request: enable a way to configure kill header name in KillRequest proto.
* listener: injection of the :ref:`TLS inspector <config_listener_filters_tls_inspector>` has been disabled by default. This feature is controlled by the runtime guard `envoy.reloadable_features.disable_tls_inspector_injection`.
* memory: enable new tcmalloc with restartable sequences for aarch64 builds.
* mongo proxy metrics: swapped network connection remote and local closed counters previously set reversed (`cx_destroy_local_with_active_rq` and `cx_destroy_remote_with_active_rq`).
* performance: improve performance when handling large HTTP/1 bodies.
Expand Down
1 change: 1 addition & 0 deletions source/common/runtime/runtime_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ constexpr const char* runtime_features[] = {
"envoy.reloadable_features.allow_response_for_timeout",
"envoy.reloadable_features.consume_all_retry_headers",
"envoy.reloadable_features.check_ocsp_policy",
"envoy.reloadable_features.disable_tls_inspector_injection",
"envoy.reloadable_features.disallow_unbounded_access_logs",
"envoy.reloadable_features.early_errors_via_hcm",
"envoy.reloadable_features.enable_dns_cache_circuit_breakers",
Expand Down
3 changes: 3 additions & 0 deletions source/server/listener_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ bool anyFilterChain(
}

bool needTlsInspector(const envoy::config::listener::v3::Listener& config) {
if (Runtime::runtimeFeatureEnabled("envoy.reloadable_features.disable_tls_inspector_injection")) {
return false;
}
return anyFilterChain(config,
[](const auto& filter_chain) {
const auto& matcher = filter_chain.filter_chain_match();
Expand Down
31 changes: 31 additions & 0 deletions test/server/listener_manager_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3296,7 +3296,33 @@ TEST_F(ListenerManagerImplWithRealFiltersTest, MultipleFilterChainsWithOverlappi
"overlapping matching rules are defined");
}

TEST_F(ListenerManagerImplWithRealFiltersTest, TlsFilterChainWithTlsInspectorInjectionDisabled) {
const std::string yaml = TestEnvironment::substitute(R"EOF(
address:
socket_address: { address: 127.0.0.1, port_value: 1234 }
filter_chains:
- filter_chain_match:
transport_protocol: "tls"
- filter_chain_match:
# empty
)EOF",
Network::Address::IpVersion::v4);

EXPECT_CALL(server_.api_.random_, uuid());
EXPECT_CALL(listener_factory_, createListenSocket(_, _, _, {true}));
manager_->addOrUpdateListener(parseListenerFromV3Yaml(yaml), "", true);
EXPECT_EQ(1U, manager_->listeners().size());

// Make sure there are no listener filters (i.e. no automatically injected TLS Inspector).
Network::ListenerConfig& listener = manager_->listeners().back().get();
Network::FilterChainFactory& filterChainFactory = listener.filterChainFactory();
Network::MockListenerFilterManager manager;
EXPECT_CALL(manager, addAcceptFilter_(_, _)).Times(0);
EXPECT_TRUE(filterChainFactory.createListenerFilterChain(manager));
}

TEST_F(ListenerManagerImplWithRealFiltersTest, TlsFilterChainWithoutTlsInspector) {
auto tls_inspector_injection_enabled_guard = enableTlsInspectorInjectionForThisTest();
const std::string yaml = TestEnvironment::substitute(R"EOF(
address:
socket_address: { address: 127.0.0.1, port_value: 1234 }
Expand Down Expand Up @@ -3327,6 +3353,7 @@ TEST_F(ListenerManagerImplWithRealFiltersTest, TlsFilterChainWithoutTlsInspector
// Test the tls inspector is not injected twice when the deprecated name is used.
TEST_F(ListenerManagerImplWithRealFiltersTest,
DEPRECATED_FEATURE_TEST(TlsFilterChainWithDeprecatedTlsInspectorName)) {
auto tls_inspector_injection_enabled_guard = enableTlsInspectorInjectionForThisTest();
const std::string yaml = TestEnvironment::substitute(R"EOF(
address:
socket_address: { address: 127.0.0.1, port_value: 1234 }
Expand Down Expand Up @@ -3358,6 +3385,7 @@ TEST_F(ListenerManagerImplWithRealFiltersTest,
}

TEST_F(ListenerManagerImplWithRealFiltersTest, SniFilterChainWithoutTlsInspector) {
auto tls_inspector_injection_enabled_guard = enableTlsInspectorInjectionForThisTest();
const std::string yaml = TestEnvironment::substitute(R"EOF(
address:
socket_address: { address: 127.0.0.1, port_value: 1234 }
Expand Down Expand Up @@ -3386,6 +3414,7 @@ TEST_F(ListenerManagerImplWithRealFiltersTest, SniFilterChainWithoutTlsInspector
}

TEST_F(ListenerManagerImplWithRealFiltersTest, AlpnFilterChainWithoutTlsInspector) {
auto tls_inspector_injection_enabled_guard = enableTlsInspectorInjectionForThisTest();
const std::string yaml = TestEnvironment::substitute(R"EOF(
address:
socket_address: { address: 127.0.0.1, port_value: 1234 }
Expand Down Expand Up @@ -3414,6 +3443,7 @@ TEST_F(ListenerManagerImplWithRealFiltersTest, AlpnFilterChainWithoutTlsInspecto
}

TEST_F(ListenerManagerImplWithRealFiltersTest, CustomTransportProtocolWithSniWithoutTlsInspector) {
auto tls_inspector_injection_enabled_guard = enableTlsInspectorInjectionForThisTest();
const std::string yaml = TestEnvironment::substitute(R"EOF(
address:
socket_address: { address: 127.0.0.1, port_value: 1234 }
Expand Down Expand Up @@ -4689,6 +4719,7 @@ TEST_F(ListenerManagerImplForInPlaceFilterChainUpdateTest, TraditionalUpdateIfAn

TEST_F(ListenerManagerImplForInPlaceFilterChainUpdateTest,
TraditionalUpdateIfImplicitTlsInspectorChanges) {
auto tls_inspector_injection_enabled_guard = enableTlsInspectorInjectionForThisTest();

EXPECT_CALL(*worker_, start(_));
manager_->startWorkers(guard_dog_);
Expand Down
8 changes: 8 additions & 0 deletions test/server/listener_manager_impl_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,14 @@ class ListenerManagerImplTest : public testing::Test {
return scoped_runtime;
}

ABSL_MUST_USE_RESULT
auto enableTlsInspectorInjectionForThisTest() {
auto scoped_runtime = std::make_unique<TestScopedRuntime>();
Runtime::LoaderSingleton::getExisting()->mergeValues(
{{"envoy.reloadable_features.disable_tls_inspector_injection", "false"}});
return scoped_runtime;
}

NiceMock<Api::MockOsSysCalls> os_sys_calls_;
TestThreadsafeSingletonInjector<Api::OsSysCallsImpl> os_calls_{&os_sys_calls_};
Api::OsSysCallsImpl os_sys_calls_actual_;
Expand Down