Skip to content

Commit b4794ff

Browse files
LiorLiebermanaryan16youngnick
authored
GEP 3779 - East/West Identity-Based Authorization (#3822)
* add draft authz gep e/w * add a table * fix * add cilium content * add all mesh authz model * small nits * fix * newline * Apply suggestions from code review Co-authored-by: Nick Young <[email protected]> * move cluster-admin non-overridable case to stretch goals * change stretch to tbd --------- Co-authored-by: Aryan Gupta <[email protected]> Co-authored-by: Nick Young <[email protected]>
1 parent 1a9fdd3 commit b4794ff

File tree

2 files changed

+285
-0
lines changed

2 files changed

+285
-0
lines changed

geps/gep-3779/index.md

Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
# GEP-3779: Identity Based Authz for East-West Traffic
2+
3+
* Issue: [#3779](https://github.com/kubernetes-sigs/gateway-api/issues/3779)
4+
* Status: Provisional
5+
6+
(See [status definitions](../overview.md#gep-states).)
7+
8+
9+
## TLDR
10+
11+
Provide a method for configuring Gateway API Mesh implementations to enforce east-west identity-based Authorization controls. At the time of writing this we leave Authentication for specific implementation and outside of this proposal scope.
12+
13+
14+
## Goals
15+
16+
(Using the [Gateway API Personas](../../concepts/roles-and-personas.md))
17+
18+
* A way for Ana the Application Developer to configure a Gateway API for Mesh implementation to enforce authorization policy that **allows** or **denies** identity or multiple identities to talk with some set (could be namespace or more granualr) of the workloads she controls.
19+
20+
* A way for both Ana and Chihiro to restrict the scope of the policies they deploy to specific ports.
21+
22+
## TBD Goals
23+
24+
* A way for Chihiro, the Cluster Admin, to configure a Gateway API for Mesh implementation to enforce non-overridable cluster-wide, authorization policies that **allows** or **denies** identity or multiple identities to talk with some set of the workloads in the cluster.
25+
26+
* A way for Chihiro, the Cluster Admin, to configure a Gateway API for Mesh implementation to enforce default, overridable, cluster-wide, authorization policies that **allows** or **denies** identity or multiple identities to talk with some set of the workloads in the cluster.
27+
28+
## Non-Goals
29+
30+
* Support identity based authorization for north-south traffic or define the composition with this API.
31+
32+
## Deferred Goals
33+
34+
* (Potentially) Support enforcement on attributes beyond identities and ports.
35+
36+
37+
## Introduction
38+
39+
Authorization is positioned as one of core mesh values. Every mesh supports some kind of east/west authorization between the workloads it controls.
40+
41+
Kubernetes core provides NetworkPolicies as one way to do it. Network Policies however falls short in many ways including:
42+
43+
* Network policies leverage labels as identities.
44+
* Labels are mutable at runtime. This opens a path for escalating privileges
45+
* Most implementations of network policies translate labels to IPs, this involves an eventual consistency nature which can and has lea to over permissiveness in the past.
46+
47+
* Scale. Network Policies are enforced using IPs (different selectors in the APIs get translated to IPs). This does not scale well with large clusters or beyond a single cluster
48+
49+
An identity-based authorization API is essential because it provides a structured way to control authorization between identities within the cluster.
50+
51+
52+
### State of the World
53+
54+
55+
| Aspect | Istio | Linkerd | Cilium |
56+
| ----- | ----- | ----- | ----- |
57+
| **Policy CRDs** | `AuthorizationPolicy` (APIs `security.istio.io/v1`) | `AuthorizationPolicy` (CRD `policy.linkerd.io/v1alpha1`), plus supporting CRDs (`Server`, `HTTPRoute`, `MeshTLSAuthentication`) | `CiliumNetworkPolicy` and `CiliumClusterwideNetworkPolicy` (superset of K8s NetworkPolicy) |
58+
| **Identity model** | Identities derived from mTLS peer certificates (bound to SA): <ul><li>SPIFFE-like principal `<trust-domain>/ns/<namespace>/sa/<serviceaccount>`. </li> <li>ServiceAccount name </li> <li>Namespaces</li></ul></br> identity within JWT derived from `request.auth.principal`<br/><br/>IPBlocks and x-forwarded-for ipBlocks | Identities derived from mTLS peer certificates (bound to SA trust domain `identity.linkerd.cluster.local`. Policies reference service accounts or explicit mesh identities (e.g. `webapp.identity.linkerd.cluster.local`). <br/><br/>Policies use `requiredAuthenticationRefs` to reference the entities who get authorization. This is a list of targetRefs and it can include: <ul><li>ServiceAccounts</li> <li>`MeshTLSAuthentication` - which represents a set of mesh identities either with a mesh identities strings or reference to serviceAccounts</li> <li>`NetworkAuthentication` - represents sets of IPs or subnets.</li></ul> |Cilium service mesh can leverage SPIFFE identities in certs that are used for handshake. These SPIFFEE identities are mapped to CiliumIdentities. You can read more about cilium identities in [CiliumIdentity](#CiliumIdentity). <br/><br/>Policies target abstractions like service accounts in the form of labels, pod labels, namespace label, node selectors, CIDR blocks and Cilium predefined [entities](https://docs.cilium.io/en/stable/security/policy/language/#entities-based). All policy targeting is coalesced by Cilium into one or more Cilium Identities for translation into the BPF datapath|
59+
| **Enforcement** | For Istio with sidecars - a proxy on each pod. For ambient, ztunnel node agent enforces mTLS based L4 authorization, L7 authorization is being enforced in waypoints if any. <br/><br/> Istio supports ALLOW, DENY, CUSTOM (often used for external authorization), and AUDIT. DENY policies in istio's context are used to enforce higher priority deny policies. The allow semantics is that whatever is not allowed explicitly (and assuming there is any policy for the same match) is implicitly denied | Linkerd data-plane proxy (injected into each pod). The proxy enforces policies via mTLS identity checks. <br/><br/> Linkerd supports AUDIT and ALLOW. There is not DENY policies, whats not allowed (and assuming there is any policy for the same match) is implicitly denied. | For L3/4 Ingress Rules, CiliumNetworkPolicy enforcement - an eBPF-based datapath in the Linux kernel on the destination node. If L7 http rules are specified, the packet is redirected for a node-local envoy for further enforcement.<br/><br/>Cilium supports ALLOW and DENY semantics - all policies generate audit logs. <br/><br/>Cilium service mesh also offers a kind of AuthN where a Cilium agent on the src node validates a workloads SPIFFE identity by talking to another agent on the destination node, performing the initial TLS handshake to do authentication.|
60+
| **Request Match criteria** | Policies can target a group of pods using label selector, a Gateway/Service (this means targeting a waypoint proxy) or a GatewayClass - meaning all the gateways created from this class. Policies without a label selector in a namespace implies the whole namespace is targeted. <br/><br/> Fine-grained L7 and L4 matching: HTTP/gRPC methods, paths, headers, ports, SNI, etc.Policies use logical OR over rules. <br/><br/>All match criterias are inline in the policy. See https://istio.io/latest/docs/reference/config/security/authorization-policy/#Rule-To and https://istio.io/latest/docs/reference/config/security/authorization-policy/#Rule-when | Policies can target: <ul><li>A `Server` which describes a set of pods (using fancy label match expressions), and a single port on those pods.</li> <li>A user can optionally restrict the authorization to a smaller subset of the traffic by targeting an HTTPRoute. (TODO: any plans to support sectionNames?)</li> <li> A namespace - this indicates that the policy applies to all traffic to all Servers and HTTPRoutes defined in the namespace.</li></ul> Note: We leave `ServerAuthorization` outside the scope as it planned to be deprecated (per linkerd website) | Policies can target groups of pods using label selector (`endpointSelector`), or by node-labels (`nodeSelector`). Cilium supports L7 via built-in HTTP parsing: rules can match HTTP methods, paths, etc. For example, a CiliumNetworkPolicy can allow only specific HTTP methods/paths on a port. |
61+
| **Default policies and admin policies** | If **no** ALLOW policy matches, traffic is **allowed** by default. You can deploy an overridable - default deny by default by deploying an **allow-nothing** policy in either the namespace or istio-system <br/><br/>AuthorizationPolicies in the `istio-system` namespace apply to the whole mesh and take precedence. These are not overridable by namespace-level policies. | Default inbound policy can be set at install time using `proxy.defaultInboundPolicy`. Supported values are: <ul><li>`all-unauthenticated:` allow all traffic. This is the default.</li> <li>`all-authenticated:` allow traffic from meshed clients in the same or from a different cluster (with multi-cluster).</li> <li>`cluster-authenticated:` allow traffic from meshed clients in the same cluster.</li> <li>`cluster-unauthenticated:` allow traffic from both meshed and non-meshed clients in the same cluster.</li> <li>`deny:` all traffic are denied. </li> <li>`audit:` Same as all-unauthenticated but requests get flagged in logs and metrics.</li> </ul> <br/>Users can override the default policies for namespaces/pods or by setting the [config.linkerd.io/default-inbound-policy](http://config.linkerd.io/default-inbound-policy) annotation There is no support for admin, non overridable policies. | Follows Kubernetes NetworkPolicy semantics by default: if no `CiliumNetworkPolicy` allows the traffic, it is allowed (no implicit deny). Once at least one `CiliumNetworkPolicy` or `CiliumClusterwideNetworkPolicy` allows some traffic, all other traffic is implicitly denied.
62+
<br/><br/> Operators must apply explicit deny rules or “default-deny” policies to block traffic in the absence of allow rules. <br/><br/> `CiliumClusterwideNetworkPolicy` exists for whole-cluster enforcement.)|
63+
64+
65+
Every mesh vendor has their own API of such authorization. Below we describe brief UX for different implementations:
66+
67+
#### Istio
68+
For the full spec and sematics of Istio AuthorizationPolicy: [Istio authorization policy docs](https://istio.io/latest/docs/reference/config/security/authorization-policy/)
69+
70+
Istio's AuthorizationPolicy can enforce access control by specifying allowed istio-formatted identities using the `source.principals` field, which matches authenticated service account identities via mTLS. You can also use other source constructs which are described in the table above and in https://istio.io/latest/docs/reference/config/security/authorization-policy/#Source.
71+
72+
```
73+
apiVersion: security.istio.io/v1beta1
74+
kind: AuthorizationPolicy
75+
metadata:
76+
name: allow-sleep
77+
namespace: default
78+
spec:
79+
selector:
80+
matchLabels:
81+
app: httpbin # The policy applies to pods with this label
82+
action: ALLOW
83+
rules:
84+
- from:
85+
- source:
86+
principals: ["cluster.local/ns/default/sa/sleep"]
87+
```
88+
89+
OR targeting a gateway for example.
90+
91+
```
92+
apiVersion: security.istio.io/v1beta1
93+
kind: AuthorizationPolicy
94+
metadata:
95+
name: allow-sleep
96+
namespace: default
97+
spec:
98+
targetRefs:
99+
- name: waypoint
100+
kind: Gateway # note: supported target Refs are Gateway, GatewayClass, Service, and ServiceEntry
101+
group: gateway.networking.k8s.io
102+
action: ALLOW
103+
rules:
104+
- from:
105+
- source:
106+
principals: ["cluster.local/ns/default/sa/sleep"]
107+
```
108+
#### Linkerd
109+
110+
For the full spec and sematics of Linkerd AuthorizationPolicy: [Linkerd authorization policy docs](https://linkerd.io/2-edge/reference/authorization-policy/)
111+
112+
In Linkerd, identity-based authorization is enforced using AuthorizationPolicy and MeshTLSAuthentication, where MeshTLSAuthentication specifies allowed ServiceAccounts or mTLS identities (e.g., sleep.default.serviceaccount.identity.linkerd.cluster.local), ensuring that only authenticated workloads can access a resource.
113+
114+
Linkerd Policy can by applied to two different targets.
115+
116+
##### Pod Labels with Server Resource
117+
118+
```
119+
apiVersion: policy.linkerd.io/v1beta1
120+
kind: Server
121+
metadata:
122+
namespace: default
123+
name: httpbin-server
124+
spec:
125+
podSelector:
126+
matchLabels:
127+
app: httpbin
128+
port: 8080
129+
proxyProtocol: HTTP/2
130+
131+
----
132+
apiVersion: policy.linkerd.io/v1beta1
133+
kind: MeshTLSAuthentication
134+
metadata:
135+
name: sleep-authn
136+
namespace: default
137+
spec:
138+
identities:
139+
- sleep.default.serviceaccount.identity.linkerd.cluster.local
140+
----
141+
142+
apiVersion: policy.linkerd.io/v1beta1
143+
kind: AuthorizationPolicy
144+
metadata:
145+
name: allow-sleep
146+
namespace: default
147+
spec:
148+
targetRef:
149+
group: policy.linkerd.io
150+
kind: Server
151+
name: httpbin-server
152+
requiredAuthenticationRefs:
153+
- name: sleep-authn
154+
kind: MeshTLSAuthentication
155+
group: policy.linkerd.io/v1beta1
156+
157+
---
158+
```
159+
160+
##### HTTPRoutes
161+
162+
```
163+
apiVersion: gateway.networking.k8s.io/v1
164+
kind: HTTPRoute
165+
metadata:
166+
name: httpbin-route
167+
namespace: default
168+
spec:
169+
parentRefs:
170+
- name: httpbin
171+
kind: Service
172+
rules:
173+
- matches:
174+
- path:
175+
type: PathPrefix
176+
value: /
177+
backendRefs:
178+
- name: httpbin
179+
port: 80
180+
181+
-----
182+
183+
apiVersion: policy.linkerd.io/v1beta1
184+
kind: MeshTLSAuthentication
185+
metadata:
186+
name: sleep-authn
187+
namespace: default
188+
spec:
189+
identities:
190+
- sleep.default.serviceaccount.identity.linkerd.cluster.local
191+
-----
192+
193+
apiVersion: policy.linkerd.io/v1beta1
194+
kind: AuthorizationPolicy
195+
metadata:
196+
name: allow-sleep-http
197+
namespace: default
198+
spec:
199+
targetRef:
200+
group: gateway.networking.k8s.io
201+
kind: HTTPRoute
202+
name: httpbin-route
203+
requiredAuthenticationRefs:
204+
- name: sleep-authn
205+
kind: MeshTLSAuthentication
206+
group: policy.linkerd.io/v1beta1
207+
---
208+
```
209+
210+
211+
#### Cilium
212+
213+
For the full spec and sematics of CiliumNetworkPolicy: https://docs.cilium.io/en/stable/network/kubernetes/policy/#ciliumnetworkpolicy & https://docs.cilium.io/en/stable/network/servicemesh/gateway-api/gateway-api/#cilium-s-ingress-config-and-ciliumnetworkpolicy
214+
215+
Beyond what's explained in the table above, Cilium also automatically labels each pod with its associated service account using the label io.cilium.k8s.policy.serviceaccount. This label can be used in CiliumNetworkPolicy to enforce identity-based access controls using [ServiceAccounts Based Identities](https://docs.cilium.io/en/latest/security/policy/kubernetes/#serviceaccounts) within CiliumNetworkPolicy;
216+
217+
See below for example.
218+
219+
```
220+
apiVersion: "cilium.io/v2"
221+
kind: CiliumNetworkPolicy
222+
metadata:
223+
name: "k8s-svc-account-policy"
224+
spec:
225+
endpointSelector:
226+
matchLabels:
227+
io.cilium.k8s.policy.serviceaccount: httpbin
228+
ingress:
229+
- fromEndpoints:
230+
- matchLabels:
231+
io.cilium.k8s.policy.serviceaccount: sleep
232+
toPorts:
233+
- ports:
234+
- port: '80'
235+
protocol: TCP
236+
rules:
237+
http:
238+
- method: GET
239+
path: "/"
240+
```
241+
242+
243+
##### CiliumIdentity
244+
Cilium has the concept of CiliumIdentity. Pods are assigned identities derived from their Kubernetes labels (namespace, app labels, etc.). Cilium’s policy matches based on these label-derived identities. The CiliumIdentity implementation maps an integer to a group of IP addresses (the pod IPs associated with a group of pods). This “integer” and its mapping to pod IP addresses represents the core identity primitive in Cilium.
245+
246+
More on https://docs.cilium.io/en/stable/internals/security-identities/ & https://docs.cilium.io/en/stable/security/network/identity/
247+
248+
249+
250+
## API
251+
252+
253+
254+
## Conformance Details
255+
256+
257+
#### Feature Names
258+
259+
260+
### Conformance tests
261+
262+
263+
## Alternatives
264+
265+
266+
## References

geps/gep-3779/metadata.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: internal.gateway.networking.k8s.io/v1alpha1
2+
kind: GEPDetails
3+
number: 3779
4+
name: Identity Based Authz for east-west traffic
5+
status: Provisional
6+
# Any authors who contribute to the GEP in any way should be listed here using
7+
# their GitHub handle.
8+
authors:
9+
- liorlieberman
10+
- aryan16
11+
# references is a list of hyperlinks to relevant external references.
12+
# It's intended to be used for storing GitHub discussions, Google docs, etc.
13+
references: {}
14+
# featureNames is a list of the feature names introduced by the GEP, if there
15+
# are any. This will allow us to track which feature was introduced by which GEP.
16+
featureNames: {}
17+
# changelog is a list of hyperlinks to PRs that make changes to the GEP, in
18+
# ascending date order.
19+
changelog: {}

0 commit comments

Comments
 (0)