@@ -925,6 +925,54 @@ TEST_F(InspectorSocketTest, HostIpTooManyOctetsChecked) {
925
925
expect_handshake_failure ();
926
926
}
927
927
928
+ TEST_F (InspectorSocketTest, HostIpInvalidOctalOctetStartChecked) {
929
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
930
+ " Host: 08.1.1.1:9229\r\n\r\n " ;
931
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
932
+ INVALID_HOST_IP_REQUEST.length ());
933
+ expect_handshake_failure ();
934
+ }
935
+
936
+ TEST_F (InspectorSocketTest, HostIpInvalidOctalOctetMidChecked) {
937
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
938
+ " Host: 1.09.1.1:9229\r\n\r\n " ;
939
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
940
+ INVALID_HOST_IP_REQUEST.length ());
941
+ expect_handshake_failure ();
942
+ }
943
+
944
+ TEST_F (InspectorSocketTest, HostIpInvalidOctalOctetEndChecked) {
945
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
946
+ " Host: 1.1.1.009:9229\r\n\r\n " ;
947
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
948
+ INVALID_HOST_IP_REQUEST.length ());
949
+ expect_handshake_failure ();
950
+ }
951
+
952
+ TEST_F (InspectorSocketTest, HostIpLeadingZeroStartChecked) {
953
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
954
+ " Host: 01.1.1.1:9229\r\n\r\n " ;
955
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
956
+ INVALID_HOST_IP_REQUEST.length ());
957
+ expect_handshake_failure ();
958
+ }
959
+
960
+ TEST_F (InspectorSocketTest, HostIpLeadingZeroMidChecked) {
961
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
962
+ " Host: 1.1.001.1:9229\r\n\r\n " ;
963
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
964
+ INVALID_HOST_IP_REQUEST.length ());
965
+ expect_handshake_failure ();
966
+ }
967
+
968
+ TEST_F (InspectorSocketTest, HostIpLeadingZeroEndChecked) {
969
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
970
+ " Host: 1.1.1.01:9229\r\n\r\n " ;
971
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
972
+ INVALID_HOST_IP_REQUEST.length ());
973
+ expect_handshake_failure ();
974
+ }
975
+
928
976
TEST_F (InspectorSocketTest, HostIPNonRoutable) {
929
977
const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
930
978
" Host: 0.0.0.0:9229\r\n\r\n " ;
@@ -933,4 +981,36 @@ TEST_F(InspectorSocketTest, HostIPNonRoutable) {
933
981
expect_handshake_failure ();
934
982
}
935
983
984
+ TEST_F (InspectorSocketTest, HostIPv6NonRoutable) {
985
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
986
+ " Host: [::]:9229\r\n\r\n " ;
987
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
988
+ INVALID_HOST_IP_REQUEST.length ());
989
+ expect_handshake_failure ();
990
+ }
991
+
992
+ TEST_F (InspectorSocketTest, HostIPv6NonRoutableDual) {
993
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
994
+ " Host: [::0.0.0.0]:9229\r\n\r\n " ;
995
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
996
+ INVALID_HOST_IP_REQUEST.length ());
997
+ expect_handshake_failure ();
998
+ }
999
+
1000
+ TEST_F (InspectorSocketTest, HostIPv4InSquareBrackets) {
1001
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
1002
+ " Host: [127.0.0.1]:9229\r\n\r\n " ;
1003
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
1004
+ INVALID_HOST_IP_REQUEST.length ());
1005
+ expect_handshake_failure ();
1006
+ }
1007
+
1008
+ TEST_F (InspectorSocketTest, HostIPv6InvalidAbbreviation) {
1009
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
1010
+ " Host: [:::1]:9229\r\n\r\n " ;
1011
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
1012
+ INVALID_HOST_IP_REQUEST.length ());
1013
+ expect_handshake_failure ();
1014
+ }
1015
+
936
1016
} // anonymous namespace
0 commit comments