The MeshTrafficPermission policy controls which workloads can connect to a destination
workload. It has two parts:
spec.targetRef selects the destination proxies that enforce the policy.
spec.rules[].default lists the callers to allow or deny.
The destination’s proxy identifies each caller by the SPIFFE ID in its mTLS certificate.
Client IP addresses and client data plane tags don’t affect access.
MeshIdentity gives workloads their identities and certificates.
Both the caller and the destination need an identity for an mTLS connection. Define the
permissions first, or at the same time as enabling identity on the destination.
Authorization on mTLS connections is default-deny. If no applicable permission allows a
caller, the destination proxy denies it, so you don’t need a deny-all policy.
These rules apply only to mTLS connections. A destination without a workload identity has no
mTLS listener to protect. If MeshTLS permits plaintext, plaintext
connections bypass MeshTrafficPermission. Use Strict mode when the destination must accept
only authenticated, authorized traffic.
Replace default.zone-1.mesh.local in the examples on this page with the trust domain in the
caller’s issued certificate. The trust domain is the part between spiffe:// and the next
/. For a Bundled issuer with automatic trust creation, MeshTrust.spec.trustDomain publishes
that value. For example, with payments.eu.mesh.local, set
rules[].default.allow[].spiffeID.value to spiffe://payments.eu.mesh.local/ns/storefront/sa.
The following example allows callers in the storefront namespace to reach destination
proxies labeled app: orders, using the default Kubernetes identity path:
targetRef selects the orders proxies that enforce the policy.
rules[].default.allow lists the caller identities those proxies accept. Other callers are
denied unless another applicable policy allows them, and a matching deny still wins.
Prefix matches identities that start with the value. Ending it at /ns/storefront/sa
covers only the service accounts in storefront.
Prefix is a plain string comparison, not a namespace selector. A prefix ending at
/ns/storefront also matches /ns/storefront-test/sa/client. The value must be a valid SPIFFE
ID, so it can’t end in /. To match one namespace only, end the prefix at /sa, or name each
caller with type: Exact.
The policy has no to array, because the destination proxy enforces access control inbound.
Every service account in the namespace, with the default Kubernetes path. A prefix ending at /ns/storefront would also match storefront-test.
Trust-domain prefix
spiffe://default.zone-1.mesh.local
Every identity in the trust domain, and in any trust domain whose name starts with the same string, such as default.zone-1.mesh.local-test. A trailing / isn’t a valid SPIFFE ID.
By default, identity paths use the following formats:
/ns/<namespace>/sa/<service-account> on Kubernetes
/workload/<workload> on Universal, for example
spiffe://default.zone-1.mesh.local/workload/frontend
If MeshIdentity.spec.spiffeID.path customizes the path, match the path the caller actually
receives. Read the trust domain from the caller’s certificate.
MeshTrust publishes that domain and its CA certificates so peers
can verify the identity. Trusting an identity doesn’t grant access.
With the default MeshIdentity template, the trust domain is <mesh>.<zone>.mesh.local, so each
zone has its own. To allow callers from several zones, add a spiffeID match for each zone’s
trust domain. For more information, see
MeshIdentity in multi-zone meshes.
To control which external destinations callers reach through zone egress, use the
SNI matcher.
For mTLS traffic, the proxy decides authorization in the following order:
A request matching any deny is denied.
Otherwise, a request matching any allow or allowWithShadowDeny is allowed.
A request matching nothing is denied.
Every deny in every applicable policy is evaluated before any allow, so a narrower allow
can’t override a deny. YAML list order doesn’t matter.
Allows add up across policies. If one policy allows storefront and another allows
payments to reach orders, both can reach it. If a third policy denies storefront on
orders, only payments remains allowed.
Only policies that cover the destination and its selected inbound or listener count. A deny on
an admin port doesn’t deny access on other ports.
Do not write a mesh-wide deny-all and then allow services back in. A blanket deny matches
every client, and no allow can re-open it.
Protected mTLS connections are already denied unless explicitly allowed. Start with the
allow entries you need, and add deny entries for exceptions to broader allows.
Use a deny as an exception to an allow. The following example accepts every client in the
trust domain except the legacy namespace and one service account:
allowWithShadowDeny allows a matching client and records a shadow-deny decision. Unless an
enforced deny matches, it grants access, so adding it for a blocked group opens access.
The following example observes the effect of denying legacy, which the broader allow already
covers:
For TCP listeners, use envoy.filters.network.rbac in the two metadata operators. For more
information, see Envoy RBAC metadata fields.
Send requests from legacy and check the destination’s log. The shadow field reports
denied, and policy identifies the matching MeshTrafficPermission by its KRI, for example kri_mtp_default___shadow-deny-legacy_ (kri_mtp_<mesh>_<zone>_<namespace>_<name>_).
Check policy as well as shadow. When no shadow entry matches, the log still reports
denied, with policy default. A shadow_denied counter alone doesn’t tell you how many
callers matched.
When the traffic is safe to block, move its matcher from allowWithShadowDeny to deny and
keep the existing allow entries.
Every identified workload the policy reaches, and the zone egress listeners of mesh-scoped zone proxies when the policy is in the system namespace or on the global control plane.
kind: Dataplane with labels
Matching destination proxies only.
kind: Dataplane with labels and sectionName
One named inbound of those proxies only.
MeshTrafficPermission has no to array, so a policy created in an application namespace
is always workload-owner scoped: kind: Mesh reaches every proxy in that namespace,
not the whole mesh. To authorize across namespaces in one zone, create the policy in
kong-mesh-system of that zone’s control plane. To authorize across zones,
create it on the global control plane. For more information, see
Policy scope.
targetRef.sectionName applies the rules to one named inbound and leaves the other ports
alone. To find the inbound names, read spec.networking.inbound[] from the destination’s
Dataplane:
kubectl get dataplanes.kuma.io DESTINATION_DATAPLANE -n DESTINATION_NAMESPACE -o jsonpath='{.spec.networking.inbound}'
Copied!
Copy the inbound’s name into targetRef.sectionName. If it has no name, use its port as a
quoted string, such as "8080". On Kubernetes, the inbound name is the name of the container
port that the Service targetPort resolves to, not the Service port name, and the port is the
container port. On Universal, read the inbounds with
kumactl get dataplane DESTINATION_DATAPLANE -m MESH -o yaml.
The following example denies observability on the admin inbound, even when
another policy allows that namespace:
MeshTrafficPermission applies to the zone egress listeners of a mesh-scoped zone proxy. It has
no effect on zone ingress listeners, which pass TLS through without terminating it. Select the
proxy role and zone with targetRef.labels, and the listener with targetRef.sectionName.
sectionName matches the listener’s name in Dataplane.networking.listeners[]. On Kubernetes,
the listener takes its name from the zone proxy Service port name, or the Service port number
when the port is unnamed, so a Helm install with default values uses 10002 for zone egress.
On Universal, use the name from the zone proxy’s Dataplane, or its port when it has no name.
Read the listener names instead of assuming the defaults:
kubectl get dataplanes.kuma.io ZONE_PROXY_DATAPLANE -n kong-mesh-system -o jsonpath='{.spec.networking.listeners}'
Copied!
The examples in this section use "10002", the listener name of a Helm install with default
values. On Universal, replace it with the listener name from your zone proxy’s Dataplane.
Zone egress is default-deny. When the zone proxy has a workload identity and no
MeshTrafficPermission selects its egress listener, every connection through zone egress is
denied. A policy with kind: Mesh, or no targetRef, in the system namespace or on the global
control plane also selects the egress listeners. An existing mesh-wide allow already opens
zone egress to the callers it matches, and a mesh-wide deny blocks those callers on zone
egress too. Zone egress terminates the caller’s mTLS connection, so spiffeID matchers identify the
caller there, as they do on an inbound. The following example lets every workload in the trust
domain use zone egress:
On zone egress, sni matches the destination name in the TLS handshake. It identifies the
requested destination, not the caller. It accepts only type: Exact, and the value must be a
DNS subdomain.
To find the value, read the snis field of the MeshExternalService. In the GUI, open the service under Services > Mesh External Services and view its YAML in Universal format. From the control plane API, run curl -s http://<control-plane>:5681/meshes/<mesh>/meshexternalservices/<name> | jq -r '.snis[].sni'. Copy the entry for the port you want into rules[].default.deny[].sni.value.
The value follows the format sni.extsvc.<mesh>[.<zone>[.<namespace>]].<name>.<port>, where zone and namespace are present only for a MeshExternalService created in a zone. It is an internal routing name, not the external service’s public hostname.
The following example denies traffic to one external service through zone egress:
This deny is an exception to applicable allow entries, such as the one in
allow-mesh-through-zone-egress. It doesn’t allow anything by itself.
To restrict which callers reach an external service, set spiffeID and sni in the same
allow entry. A connection matches the entry only when both match. The following example lets
only the service accounts in storefront reach external-service-kube through zone egress:
Without a broader allow on the egress listener, such as allow-mesh-through-zone-egress or a
mesh-wide allow, only storefront reaches external-service-kube, and zone egress denies
every other external service.
Test from an allowed caller and a caller that should be denied, using new connections:
Confirm that the destination has an identity and that the test uses mTLS.
Confirm that targetRef selects the destination proxy and, if set, the intended
sectionName.
Check the caller’s issued certificate with kumactl inspect dataplane CALLER_DATAPLANE --type config-dump. Confirm that the SPIFFE
URI in its subject alternative names matches the policy’s Exact or Prefix value.
Send the same request from both callers. Confirm that the allowed caller reaches the
application and the denied caller doesn’t. If a request fails unexpectedly, check the
destination proxy’s logs.
To tell a proxy denial from an application error, add the following to the destination’s
access-log format:
HTTP: %RESPONSE_CODE_DETAILS%. A proxy denial returns 403, and the value starts with
rbac_access_denied_matched_policy. For more information, see
Envoy’s HTTP RBAC diagnostics.
TCP: %CONNECTION_TERMINATION_DETAILS%. A denial closes the connection. For more
information, see Envoy’s network RBAC diagnostics.
If TLS fails before authorization, check the certificate, identity, and trust configuration
first. An allow entry can’t fix a failed TLS handshake.
Unexpected result
Check
An intended caller is denied
Compare its full issued identity with the matcher, then look for a deny in another applicable policy.
An unintended caller is allowed
Look for broader allows, allowWithShadowDeny entries, and prefixes without a path boundary. Confirm that the connection uses mTLS.
A port-specific policy has no effect
Compare sectionName with the inbound name, or its port number if it has no name.
Every request appears shadow-denied
shadow_effective_policy_id. The value default doesn’t mean your restriction matched.