Skip to content

Commit

Permalink
tls: disable TLS inspector injection (#14404)
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Barrella tabarr@google.com

Additional Description: See the issue for context
Risk Level: Medium
Testing: Unit tests
Docs Changes: I didn't see injection mentioned at https://www.envoyproxy.io/docs/envoy/latest/configuration/listeners/listener_filters/tls_inspector or from grepping for "inject" in docs/
Release Notes:
Runtime guard: envoy.reloadable_features.disable_tls_inspector_injection
Fixes #13601

Signed-off-by: Taylor Barrella <tabarr@google.com>
  • Loading branch information
tbarrella authored Dec 15, 2020
1 parent 0cb98ff commit 5dc58a6
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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

0 comments on commit 5dc58a6

Please sign in to comment.