Istio leaks sensitive information in HTTP headers

istio-proxy sidecars are sending internal data to the public internet.

When an HTTP request from a container in a pod with istio-proxy sidecar is sent to a public URL that is not part of the mesh, istio-proxy sidecar adds headers with data that would otherwise not be disclosed with the destination:

kubectl exec -n x sleep-557747455f-fhq4v -c sleep -- curl -sS http://httpbin.org/headers
{
  "headers": {
    "Accept": "*/*",
    "Host": "httpbin.org",
    "User-Agent": "curl/7.78.0-DEV",
    "X-Amzn-Trace-Id": "Root=1-612b8028-2cd2c9c90b231da37d3d4a28",
    "X-B3-Sampled": "0",
    "X-B3-Spanid": "60155e0d1f600935",
    "X-B3-Traceid": "e04b11f76e48becb60155e0d1f600935",
    "X-Envoy-Attempt-Count": "1",
    "X-Envoy-Peer-Metadata": "ChkKDkFQUF9DT05UQUlORVJTEgcaBXNsZWVwChoKCkNMVVNURVJfSUQSDBoKS3ViZXJuZXRlcwoZCg1JU1RJT19WRVJTSU9OEggaBjEuMTEuMQrEAQoGTEFCRUxTErkBKrYBCg4KA2FwcBIHGgVzbGVlcAohChFwb2QtdGVtcGxhdGUtaGFzaBIMGgo1NTc3NDc0NTVmCiQKGXNlY3VyaXR5LmlzdGlvLmlvL3Rsc01vZGUSBxoFaXN0aW8KKgofc2VydmljZS5pc3Rpby5pby9jYW5vbmljYWwtbmFtZRIHGgVzbGVlcAovCiNzZXJ2aWNlLmlzdGlvLmlvL2Nhbm9uaWNhbC1yZXZpc2lvbhIIGgZsYXRlc3QKGgoHTUVTSF9JRBIPGg1jbHVzdGVyLmxvY2FsCiAKBE5BTUUSGBoWc2xlZXAtNTU3NzQ3NDU1Zi1maHE0dgoQCglOQU1FU1BBQ0USAxoBeApDCgVPV05FUhI6GjhrdWJlcm5ldGVzOi8vYXBpcy9hcHBzL3YxL25hbWVzcGFjZXMveC9kZXBsb3ltZW50cy9zbGVlcAoXChFQTEFURk9STV9NRVRBREFUQRICKgAKGAoNV09SS0xPQURfTkFNRRIHGgVzbGVlcA==",
    "X-Envoy-Peer-Metadata-Id": "sidecar~10.1.0.42~sleep-557747455f-fhq4v.x~x.svc.cluster.local"
  }
}

As you can see same request over HTTPS does not include these additional X-B3-* and X-Envoy-* headers:

kubectl exec -n x sleep-557747455f-fhq4v -c sleep -- curl -sS https://httpbin.org/headers
{
  "headers": {
    "Accept": "*/*",
    "Host": "httpbin.org",
    "User-Agent": "curl/7.78.0-DEV",
    "X-Amzn-Trace-Id": "Root=1-612b8020-26130ccd001292a418857e6e"
  }
}

Is this by design? is it possible to omit these headers?

According to Istio / Overview, x-b3-traceid and x-b3-spanid are used for tracing. Which of these headers do you think are sensitive and should be removed?
Istio telemetry may need some of these headers. cc @Pengyuan_Bian.

The concern is about X-Envoy-Peer-Metadata and X-Envoy-Peer-Metadata-Id

Concern over leaking sensitive information in headers X-Envoy-Peer-Metadata and X-Envoy-Peer-Metadata-Id · Issue #35283 · istio/istio · GitHub is created to discuss this issue. Please follow up on Concern over leaking sensitive information in headers X-Envoy-Peer-Metadata and X-Envoy-Peer-Metadata-Id · Issue #35283 · istio/istio · GitHub. Thanks!

cc @kuat