istio: ServiceEntry captures traffic that doesn't match host?

Is this the right place to submit this?

  • This is not a security vulnerability or a crashing bug
  • This is not a question about how to use Istio

Bug Description

If I define the following service entry, and then watch traffic from my pod literally anything over 443 is captured and matches the entry.

apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: test
spec:
  exportTo:
  - .
  hosts:
  - sts.us-east-2.amazonaws.com
  - '*.s3.dualstack.us-east-2.amazonaws.com'
  location: MESH_EXTERNAL
  ports:
  - name: https
    number: 443
    protocol: TLS
  resolution: NONE

Hit a different endpoint:

$ curl https://www.google.com

Observe the traffic logs in the istio-proxy container:

[2024-02-22T07:00:21.655Z] "- - -" 0 - - - "-" 883 24794 136 - "-" "-" "-" "-" "[2607:f8b0:4009:81b::2004]:443" outbound|443||*.s3.dualstack.us-east-2.amazonaws.com [2600:1f16:40:5306:1f57::10]:43380 [2607:f8b0:4009:81b::2004]:443 [2600:1f16:40:5306:1f57::10]:43364 www.google.com -

Why is the *.s3.dualstack.us-east-2.amazonaws.com host showing up here? Why is the ServiceEntry matching for any reason? It appears to do this for any traffic over port 443.

Version

EKS 1.29
Istio 1.20.3


ENABLE_NATIVE_SIDECARS: true
ISTIO_ENABLE_IPV4_OUTBOUND_LISTENER_FOR_IPV6_CLUSTERS: true

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

Here is the culprit: https://github.com/istio/istio/commit/ce053f0bb0fad42cc15c98ac49aa0e11f7482c9c#diff-b054376d40667db7823124715d25d44bbc43b6f9cc2dee26117cfa5a3f1c7435R59. Very subtle and unintended.

With the / vs without we hit different paths: https://github.com/istio/istio/blob/1963196b26c31585874e81633df1393558625e77/pilot/pkg/networking/core/v1alpha3/listener.go#L815.

If CIDR is set, it lets us pass this if: https://github.com/istio/istio/blob/65d15b6b616ac969f2a354a990599fd908ba3b28/pilot/pkg/networking/core/v1alpha3/tls.go#L206. Without it, we fail since 0.0.0.0 != ::.

That being said , I think the proper fix is not to add the / back but to make the svcListenAddress == actualWildcard correct

cc @keithmattix @zhlsunshine