-
Notifications
You must be signed in to change notification settings - Fork 547
GEP 3779 - East/West Identity-Based Authorization #3822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6d01319
95898f1
d6cc733
78d0656
7efee83
28ef780
a244564
f384d15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,263 @@ | ||||||||
# GEP-3779: Identity Based Authz for East-West Traffic | ||||||||
|
||||||||
* Issue: [#3779](https://github.com/kubernetes-sigs/gateway-api/issues/3779) | ||||||||
* Status: Provisional | ||||||||
|
||||||||
(See [status definitions](../overview.md#gep-states).) | ||||||||
|
||||||||
|
||||||||
## TLDR | ||||||||
|
||||||||
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. | ||||||||
|
||||||||
|
||||||||
## Goals | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is any attributes other than identity and port considered? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this would mean entering the L7 space (which I think require more research about where we can standardize). So for the first iteration -- no. |
||||||||
|
||||||||
(Using the [Gateway API Personas](../../concepts/roles-and-personas.md)) | ||||||||
|
||||||||
* 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 of the workloads she controls. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. many users of k8s see k8s namespace as a security boundary . Is the namespace policy (e.g specifies which identities are allowed to talk to my namespace) a special case of the workload policy? |
||||||||
|
||||||||
* 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. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since we're introducing hierarchical policies (cluster wide overridable/non-overridable, namespace, workload, port being the scopes i could make out), should we add a goal that Ana should be able to easily and determistically figure out the effective policy for their workload (port)? feel free to resolve if this doesn't need to be called out or if it doesn't make sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a very good call. I am not sure this should be a part of this specific proposal. IMO there should be a different effort in gateway to actually help discoverability of policies, and policy attachment. Will leave this open in case others have other opinions. But its something the community had talked about many times in the past There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that the fact that overridable/non-overridable policies gets this a little more complicated to understand effective policy so thats a good point. Will review some of the prior art here, but I dont think it should be part of the first iteration |
||||||||
|
||||||||
* A way for both Ana and Chihiro to restrict the scope of the policies they deploy to specific ports. | ||||||||
LiorLieberman marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
|
||||||||
## Stretch Goals | ||||||||
|
||||||||
* 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. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is in goals and stretch goals I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the difference seems to non-overridable (goal) vs overridable (stretch goal). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah thanks, I looked at this for a while without noticing that 😆 In that case, I am not sure I understand this... "overridable/default" make sense in contexts where there is 1 policy that wins. Generally authorization policies are ALL enforced, where "any DENY means it is denied, any ALLOW means allowed, else deny". So what does it mean to have defaults and overrides, etc in this context? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same concept as a "default-deny" (allow nothing) istio policy in istio-system namespace and baselineNetworkPolicy. Does that makes sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This may not be consistent across different meshes - on Consul finer-grained ALLOW policies could permit traffic that a coarse/global DENY would blocked, and used a global DENY rule as a default rather than Istio's "allow nothing" global default syntax - precise semantics and tests will be important for conformance here. |
||||||||
|
||||||||
## Non-Goals | ||||||||
|
||||||||
* Support identity based authorization for north-south traffic or define the composition with this API. | ||||||||
|
||||||||
## Deferred Goals | ||||||||
|
||||||||
* (Potentially) Support enforcement on attributes beyond identities and ports. | ||||||||
|
||||||||
## Introduction | ||||||||
|
||||||||
Authorization is positioned as one of core mesh values. Every mesh supports some kind of east/west authorization between the workloads it controls. | ||||||||
|
||||||||
Kubernetes core provides NetworkPolicies as one way to do it. Network Policies however falls short in many ways including: | ||||||||
|
||||||||
* Network policies leverage labels as identities. | ||||||||
* Labels are mutable at runtime. This opens a path for escalating privileges | ||||||||
* 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. | ||||||||
|
||||||||
* 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 | ||||||||
|
||||||||
An identity-based authorization API is essential because it provides a structured way to control authorization between identities within the cluster. | ||||||||
|
||||||||
### State of the World | ||||||||
|
||||||||
|
||||||||
| Aspect | Istio | Linkerd | Cilium | | ||||||||
| ----- | ----- | ----- | ----- | | ||||||||
| **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) | | ||||||||
| **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).| | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small clarification about Cilium. |
||||||||
| **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 service mesh also offers a kind of AuthN where a Cilium agent on the src node, is talking to another agent on the destination node, using the pod’s spiffee identities.| | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Small technical fix for Cilium. |
||||||||
| **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, Kafka, etc. For example, a CiliumNetworkPolicy can allow only specific HTTP methods/paths on a port. | | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The Kafka support is deprecated, better to leave it out. |
||||||||
| **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). Operators must apply explicit deny rules or “default-deny” policies to block traffic. <br/><br/> `CiliumClusterwideNetworkPolicy` exists for admin enforcement.)| | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
A couple of small changes to Cilium section of this one to make it more technically correct. |
||||||||
|
||||||||
|
||||||||
Every mesh vendor has their own API of such authorization. Below we describe brief UX for different implementations: | ||||||||
|
||||||||
#### Istio | ||||||||
For the full spec and sematics of Istio AuthorizationPolicy: [Istio authorization policy docs](https://istio.io/latest/docs/reference/config/security/authorization-policy/) | ||||||||
|
||||||||
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. | ||||||||
|
||||||||
``` | ||||||||
apiVersion: security.istio.io/v1beta1 | ||||||||
kind: AuthorizationPolicy | ||||||||
metadata: | ||||||||
name: allow-sleep | ||||||||
namespace: default | ||||||||
spec: | ||||||||
selector: | ||||||||
matchLabels: | ||||||||
app: httpbin # The policy applies to pods with this label | ||||||||
action: ALLOW | ||||||||
rules: | ||||||||
- from: | ||||||||
- source: | ||||||||
principals: ["cluster.local/ns/default/sa/sleep"] | ||||||||
``` | ||||||||
|
||||||||
OR targeting a gateway for example. | ||||||||
|
||||||||
``` | ||||||||
apiVersion: security.istio.io/v1beta1 | ||||||||
kind: AuthorizationPolicy | ||||||||
metadata: | ||||||||
name: allow-sleep | ||||||||
namespace: default | ||||||||
spec: | ||||||||
targetRefs: | ||||||||
- name: waypoint | ||||||||
kind: Gateway # note: supported target Refs are Gateway, GatewayClass, Service, and ServiceEntry | ||||||||
group: gateway.networking.k8s.io | ||||||||
action: ALLOW | ||||||||
rules: | ||||||||
- from: | ||||||||
- source: | ||||||||
principals: ["cluster.local/ns/default/sa/sleep"] | ||||||||
``` | ||||||||
#### Linkerd | ||||||||
|
||||||||
For the full spec and sematics of Linkerd AuthorizationPolicy: [Linkerd authorization policy docs](https://linkerd.io/2-edge/reference/authorization-policy/) | ||||||||
|
||||||||
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. | ||||||||
|
||||||||
Linkerd Policy can by applied to two different targets. | ||||||||
|
||||||||
##### Pod Labels with Server Resource | ||||||||
|
||||||||
``` | ||||||||
apiVersion: policy.linkerd.io/v1beta1 | ||||||||
kind: Server | ||||||||
metadata: | ||||||||
namespace: default | ||||||||
name: httpbin-server | ||||||||
spec: | ||||||||
podSelector: | ||||||||
matchLabels: | ||||||||
app: httpbin | ||||||||
port: 8080 | ||||||||
proxyProtocol: HTTP/2 | ||||||||
|
||||||||
---- | ||||||||
apiVersion: policy.linkerd.io/v1beta1 | ||||||||
kind: MeshTLSAuthentication | ||||||||
metadata: | ||||||||
name: sleep-authn | ||||||||
namespace: default | ||||||||
spec: | ||||||||
identities: | ||||||||
- sleep.default.serviceaccount.identity.linkerd.cluster.local | ||||||||
---- | ||||||||
|
||||||||
apiVersion: policy.linkerd.io/v1beta1 | ||||||||
kind: AuthorizationPolicy | ||||||||
metadata: | ||||||||
name: allow-sleep | ||||||||
namespace: default | ||||||||
spec: | ||||||||
targetRef: | ||||||||
group: policy.linkerd.io | ||||||||
kind: Server | ||||||||
name: httpbin-server | ||||||||
requiredAuthenticationRefs: | ||||||||
- name: sleep-authn | ||||||||
kind: MeshTLSAuthentication | ||||||||
group: policy.linkerd.io/v1beta1 | ||||||||
|
||||||||
--- | ||||||||
``` | ||||||||
|
||||||||
##### HTTPRoutes | ||||||||
|
||||||||
``` | ||||||||
apiVersion: gateway.networking.k8s.io/v1 | ||||||||
kind: HTTPRoute | ||||||||
metadata: | ||||||||
name: httpbin-route | ||||||||
namespace: default | ||||||||
spec: | ||||||||
parentRefs: | ||||||||
- name: httpbin | ||||||||
kind: Service | ||||||||
rules: | ||||||||
- matches: | ||||||||
- path: | ||||||||
type: PathPrefix | ||||||||
value: / | ||||||||
backendRefs: | ||||||||
- name: httpbin | ||||||||
port: 80 | ||||||||
|
||||||||
----- | ||||||||
|
||||||||
apiVersion: policy.linkerd.io/v1beta1 | ||||||||
kind: MeshTLSAuthentication | ||||||||
metadata: | ||||||||
name: sleep-authn | ||||||||
namespace: default | ||||||||
spec: | ||||||||
identities: | ||||||||
- sleep.default.serviceaccount.identity.linkerd.cluster.local | ||||||||
----- | ||||||||
|
||||||||
apiVersion: policy.linkerd.io/v1beta1 | ||||||||
kind: AuthorizationPolicy | ||||||||
metadata: | ||||||||
name: allow-sleep-http | ||||||||
namespace: default | ||||||||
spec: | ||||||||
targetRef: | ||||||||
group: gateway.networking.k8s.io | ||||||||
kind: HTTPRoute | ||||||||
name: httpbin-route | ||||||||
requiredAuthenticationRefs: | ||||||||
- name: sleep-authn | ||||||||
kind: MeshTLSAuthentication | ||||||||
group: policy.linkerd.io/v1beta1 | ||||||||
--- | ||||||||
``` | ||||||||
|
||||||||
|
||||||||
#### Cilium | ||||||||
|
||||||||
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 | ||||||||
|
||||||||
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; | ||||||||
|
||||||||
See below for example. | ||||||||
|
||||||||
``` | ||||||||
apiVersion: "cilium.io/v2" | ||||||||
kind: CiliumNetworkPolicy | ||||||||
metadata: | ||||||||
name: "k8s-svc-account-policy" | ||||||||
spec: | ||||||||
endpointSelector: | ||||||||
matchLabels: | ||||||||
io.cilium.k8s.policy.serviceaccount: httpbin | ||||||||
ingress: | ||||||||
- fromEndpoints: | ||||||||
- matchLabels: | ||||||||
io.cilium.k8s.policy.serviceaccount: sleep | ||||||||
toPorts: | ||||||||
- ports: | ||||||||
- port: '80' | ||||||||
protocol: TCP | ||||||||
rules: | ||||||||
http: | ||||||||
- method: GET | ||||||||
path: "/" | ||||||||
``` | ||||||||
|
||||||||
|
||||||||
##### CiliumIdentity | ||||||||
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. | ||||||||
|
||||||||
More on https://docs.cilium.io/en/stable/internals/security-identities/ & https://docs.cilium.io/en/stable/security/network/identity/ | ||||||||
|
||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably also worth reminding everyone that GAMMA has a some implicit authorization policy already - once one or more HTTPRoutes are added to a Service, then anything that does not match something in a HTTPRoute is expected to be denied. |
||||||||
|
||||||||
## API | ||||||||
|
||||||||
|
||||||||
|
||||||||
## Conformance Details | ||||||||
|
||||||||
|
||||||||
#### Feature Names | ||||||||
|
||||||||
|
||||||||
### Conformance tests | ||||||||
|
||||||||
|
||||||||
## Alternatives | ||||||||
|
||||||||
|
||||||||
## References |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: internal.gateway.networking.k8s.io/v1alpha1 | ||
kind: GEPDetails | ||
number: 3779 | ||
name: Identity Based Authz for east-west traffic | ||
status: Provisional | ||
# Any authors who contribute to the GEP in any way should be listed here using | ||
# their GitHub handle. | ||
authors: | ||
- liorlieberman | ||
- aryan16 | ||
# references is a list of hyperlinks to relevant external references. | ||
# It's intended to be used for storing GitHub discussions, Google docs, etc. | ||
references: {} | ||
# featureNames is a list of the feature names introduced by the GEP, if there | ||
# are any. This will allow us to track which feature was introduced by which GEP. | ||
featureNames: {} | ||
# changelog is a list of hyperlinks to PRs that make changes to the GEP, in | ||
# ascending date order. | ||
changelog: {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that's not clear to me from this GEP is what types of traffic we are targeting.
Currently, GAMMA is specified to only be for HTTP traffic - that is, traffic that is routed using HTTP metadata, which requires the routing agent to have access to the unencrypted HTTP stream. So that rules out TCP, UDP, and TLS handling for GAMMA.
Is this proposal intended to cover other use cases than HTTP traffic? If so, that's a significant expansion of the current GAMMA spec, and we probably need to talk about it separately.
If not, we probably should say that explicitly, maybe via listing non-HTTP protocols in non-goals or something.