@@ -1944,6 +1944,42 @@ class Http2FrameIntegrationTest : public testing::TestWithParam<FrameIntegration
1944
1944
}
1945
1945
};
1946
1946
1947
+ TEST_P (Http2FrameIntegrationTest, UpstreamRemoteMalformedFrameEndstreamWith1xxHeader) {
1948
+ config_helper_.addConfigModifier (
1949
+ [&](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
1950
+ hcm) -> void { hcm.set_proxy_100_continue (true ); });
1951
+ beginSession ();
1952
+ FakeRawConnectionPtr fake_upstream_connection;
1953
+
1954
+ // Start a request and wait for it to reach the upstream.
1955
+ sendFrame (Http2Frame::makeRequest (1 , " host" , " /path/to/long/url" ));
1956
+ ASSERT_TRUE (fake_upstreams_[0 ]->waitForRawConnection (fake_upstream_connection));
1957
+ const Http2Frame settings_frame = Http2Frame::makeEmptySettingsFrame ();
1958
+ ASSERT_TRUE (fake_upstream_connection->write (std::string (settings_frame)));
1959
+
1960
+ test_server_->waitForGaugeEq (" cluster.cluster_0.upstream_rq_active" , 1 );
1961
+
1962
+ // A malformed frame is translated to 103 header with END_STREAM by the underlying codec.
1963
+ // Typically we should get a protocol error, but this should not crash Envoy.
1964
+ // PAYLOAD_LENGTH: \x05
1965
+ // FRAME_TYPE: \x01
1966
+ // FLAGS: \x32
1967
+ // STREAM_ID: \x01
1968
+ // ASCII: \x31, \x30, \x33 for 1, 0, 3 respectively
1969
+ const std::vector<uint8_t > header_frame = {
1970
+ 0x00 , 0x00 , 0x05 , 0x01 , 0x32 , 0x00 , 0x00 , 0x00 , 0x01 , 0x2d , 0xfe , 0xff , 0x01 , 0x10 ,
1971
+ 0x00 , 0x00 , 0x05 , 0x09 , 0x0d , 0x00 , 0x00 , 0x00 , 0x01 , 0x09 , 0x03 , 0x31 , 0x30 , 0x33 };
1972
+ const std::string header_frame_str (reinterpret_cast <const char *>(header_frame.data ()),
1973
+ header_frame.size ());
1974
+ ASSERT_TRUE (fake_upstream_connection->write (header_frame_str));
1975
+
1976
+ const Http2Frame response = readFrame ();
1977
+ EXPECT_EQ (Http2Frame::Type::Headers, response.type ());
1978
+
1979
+ tcp_client_->close ();
1980
+ test_server_->waitForGaugeEq (" http.config_test.downstream_rq_active" , 0 );
1981
+ }
1982
+
1947
1983
TEST_P (Http2FrameIntegrationTest, MaxConcurrentStreamsIsRespected) {
1948
1984
const int kTotalRequests = 101 ;
1949
1985
config_helper_.addConfigModifier (
0 commit comments