TIS1108 - JWT Claim Based Routing Without RequestAuthentication
JWT claim based routing is used without a corresponding RequestAuthentication configuration.
To securely use JWT claims in routing decisions, add a RequestAuthentication to validate the JWTs, or remove the JWT claim based routing if validation is not possible.
Examples
-
VirtualServiceConfiguring JWT Claim Based Routing WithoutRequestAuthenticationapiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: jwt-claim-routing
namespace: example-namespace
spec:
hosts:
- "my-app.example.com"
http:
- match:
- headers:
x-jwt-claim:
exact: "admin"
route:
- destination:
host: "my-app-service.example-namespace.svc.cluster.local"Explanation: The
VirtualServiceconfiguration attempts to route based on a JWT claim (x-jwt-claimheader), but there is no correspondingRequestAuthenticationto validate and extract JWT claims. This means that the routing rule cannot be effectively enforced, as the claims are not verified by Istio.
Recommendation
Add a RequestAuthentication resource to validate JWTs, or remove the JWT claim based routing to avoid incorrect or insecure routing.
-
Add
RequestAuthenticationto Validate JWT ClaimsAdd a
RequestAuthenticationto validate the JWT claims before using them in the routing configuration.apiVersion: security.istio.io/v1beta1
kind: RequestAuthentication
metadata:
name: jwt-auth
namespace: example-namespace
spec:
selector:
matchLabels:
app: my-app
jwtRules:
- issuer: "https://secure.token.service"
jwksUri: "https://secure.token.service/.well-known/jwks.json"Explanation: The
RequestAuthenticationresource ensures that JWTs are validated, allowing theVirtualServiceto route based on verified claims. -
Remove JWT Claim Based Routing
If JWT claim based routing is not needed, remove the related configuration to avoid insecure routing behavior.
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: jwt-claim-routing
namespace: example-namespace
spec:
hosts:
- "my-app.example.com"
http:
- route:
- destination:
host: "my-app-service.example-namespace.svc.cluster.local"Explanation: Removing the JWT claim based routing ensures that the configuration remains secure without relying on unvalidated claims for routing decisions.