When using the gRPC validation features within the Gateway it appears that incorrectly formatted JWT headers are ignored these are then allowed to flow into the services. In the following case we have a poorly formatted value getting past the gateway.
Is this a problem.
Client View
grpc_cli call $CLUSTER_INGRESS dev.cognizant_ai.experiment.Service.Get "uid: '1'" --metadata authorization:"Bearer 1"
connecting to aa39e9512911911e9b04006555a6c797-546098767.us-west-2.elb.amazonaws.com:80
Sending client initial metadata:
authorization : Bearer 1
Received trailing metadata from server:
date : Mon, 17 Jun 2019 17:48:34 GMT
server : istio-envoy
x-envoy-upstream-service-time : 1
Rpc failed with status code 16, error message: square/go-jose: compact JWS format must have three parts token="...arer 1" stack="[auth.go:136 auth.go:192 experimentsrv.pb.go:416 server.go:900 server.go:1122 server.go:617]"
Application service view
metadata.MD{"x-b3-traceid":[]string{"be8d87a1d4059fab20fa7f1b6100d40f"}, "grpc-accept-encoding":[]string{"identity,deflate,gzip"}, "accept-encoding":[]string{"identity,gzip"}, "x-envoy-external-address":[]string{"100.96.1.1"}, "x-forwarded-client-cert":[]string{"By=spiffe://cluster.local/ns/default/sa/default;Hash=d84eb4500c490da5b446c8d8624a3a871f7806d2edff227274077ea8d69156ec;Subject=\"\";URI=spiffe://cluster.local/ns/istio-system/sa/istio-ingressgateway-service-account"}, "authorization":[]string{"Bearer 1"}, "x-forwarded-for":[]string{"100.96.1.1"}, "x-request-id":[]string{"63dc3828-6529-43e5-98ab-6e9d9ef9aa86"}, ":authority":[]string{"aa39e9512911911e9b04006555a6c797-546098767.us-west-2.elb.amazonaws.com:80"}, "x-forwarded-proto":[]string{"http"}, "x-b3-spanid":[]string{"a44b08f39f64c5a7"}, "x-b3-sampled":[]string{"0"}, "user-agent":[]string{"grpc-c++/1.21.2 grpc-c/7.0.0 (linux; chttp2; gandalf)"}, "x-b3-parentspanid":[]string{"20fa7f1b6100d40f"}}
JWT values that are empty or missing are rejected at the gateway.
grpc_cli call $CLUSTER_INGRESS dev.cognizant_ai.experiment.Service.Get "uid: '1'"
connecting to aa39e9512911911e9b04006555a6c797-546098767.us-west-2.elb.amazonaws.com:80
Received trailing metadata from server:
date : Mon, 17 Jun 2019 17:49:16 GMT
server : istio-envoy
x-envoy-upstream-service-time : 0
Rpc failed with status code 16, error message: invalid security token
Correctly formatted Bearer values appear to be tested and if invalid the requests never terminate on the service.
grpc_cli call $CLUSTER_INGRESS dev.cognizant_ai.experiment.Service.Get "uid: '1'"
connecting to aa39e9512911911e9b04006555a6c797-546098767.us-west-2.elb.amazonaws.com:80
Received trailing metadata from server:
date : Mon, 17 Jun 2019 17:49:16 GMT
server : istio-envoy
x-envoy-upstream-service-time : 0
Rpc failed with status code 16, error message: invalid security token