-
Notifications
You must be signed in to change notification settings - Fork 277
Add DPU node identity RBAC: impersonation and group subject #2927
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: master
Are you sure you want to change the base?
Changes from all commits
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,63 @@ | ||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||
| # Grant lease permissions to the DPU service account so the DPU can renew | ||||||||||||||||||||||||||||||||||||
| # the health check lease in the openshift-ovn-kubernetes namespace. | ||||||||||||||||||||||||||||||||||||
| apiVersion: rbac.authorization.k8s.io/v1 | ||||||||||||||||||||||||||||||||||||
| kind: RoleBinding | ||||||||||||||||||||||||||||||||||||
| metadata: | ||||||||||||||||||||||||||||||||||||
| {{ if .NETWORK_NODE_IDENTITY_ENABLE }} | ||||||||||||||||||||||||||||||||||||
| name: openshift-ovn-kubernetes-node-dpu-service-identity-limited | ||||||||||||||||||||||||||||||||||||
| {{ else }} | ||||||||||||||||||||||||||||||||||||
| name: openshift-ovn-kubernetes-node-dpu-service-limited | ||||||||||||||||||||||||||||||||||||
| {{ end }} | ||||||||||||||||||||||||||||||||||||
| namespace: openshift-ovn-kubernetes | ||||||||||||||||||||||||||||||||||||
| roleRef: | ||||||||||||||||||||||||||||||||||||
| apiGroup: rbac.authorization.k8s.io | ||||||||||||||||||||||||||||||||||||
| kind: Role | ||||||||||||||||||||||||||||||||||||
| name: openshift-ovn-kubernetes-node-limited | ||||||||||||||||||||||||||||||||||||
| subjects: | ||||||||||||||||||||||||||||||||||||
| {{ if .NETWORK_NODE_IDENTITY_ENABLE }} | ||||||||||||||||||||||||||||||||||||
| - kind: Group | ||||||||||||||||||||||||||||||||||||
| name: system:ovn-nodes | ||||||||||||||||||||||||||||||||||||
| apiGroup: rbac.authorization.k8s.io | ||||||||||||||||||||||||||||||||||||
| {{ else }} | ||||||||||||||||||||||||||||||||||||
| - kind: ServiceAccount | ||||||||||||||||||||||||||||||||||||
| name: ovn-kubernetes-node-dpu-service | ||||||||||||||||||||||||||||||||||||
| namespace: openshift-ovn-kubernetes | ||||||||||||||||||||||||||||||||||||
| {{ end }} | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| {{ if .NETWORK_NODE_IDENTITY_ENABLE }} | ||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||
| # Allow the DPU service account to impersonate node users and groups | ||||||||||||||||||||||||||||||||||||
| # so it can act on behalf of the DPU host node. | ||||||||||||||||||||||||||||||||||||
| apiVersion: rbac.authorization.k8s.io/v1 | ||||||||||||||||||||||||||||||||||||
| kind: ClusterRole | ||||||||||||||||||||||||||||||||||||
| metadata: | ||||||||||||||||||||||||||||||||||||
| name: openshift-ovn-kubernetes-node-dpu-host-impersonator | ||||||||||||||||||||||||||||||||||||
| rules: | ||||||||||||||||||||||||||||||||||||
| - apiGroups: [""] | ||||||||||||||||||||||||||||||||||||
| resources: | ||||||||||||||||||||||||||||||||||||
| - users | ||||||||||||||||||||||||||||||||||||
| verbs: | ||||||||||||||||||||||||||||||||||||
| - impersonate | ||||||||||||||||||||||||||||||||||||
| - apiGroups: [""] | ||||||||||||||||||||||||||||||||||||
| resources: | ||||||||||||||||||||||||||||||||||||
| - groups | ||||||||||||||||||||||||||||||||||||
| verbs: | ||||||||||||||||||||||||||||||||||||
| - impersonate | ||||||||||||||||||||||||||||||||||||
| resourceNames: | ||||||||||||||||||||||||||||||||||||
| - system:nodes | ||||||||||||||||||||||||||||||||||||
| - system:authenticated | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+42
to
+49
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. 🧩 Analysis chain🏁 Script executed: # Find the file mentioned in the review
find . -name "dpu-rbac.yaml" -o -name "*dpu*rbac*" | head -20Repository: openshift/cluster-network-operator Length of output: 124 🏁 Script executed: # Check if the file exists and get its context
ls -la bindata/network/ovn-kubernetes/ 2>/dev/null | grep -i dpuRepository: openshift/cluster-network-operator Length of output: 141 🏁 Script executed: # Search for NETWORK_NODE_IDENTITY_ENABLE to understand the conditional logic
rg "NETWORK_NODE_IDENTITY_ENABLE" -A 5 -B 5Repository: openshift/cluster-network-operator Length of output: 32328 🏁 Script executed: # Search for system:ovn-nodes to understand its usage in RBAC
rg "system:ovn-nodes" -B 3 -A 3Repository: openshift/cluster-network-operator Length of output: 2218 🏁 Script executed: # Search for the RoleBinding that grants lease access
rg "openshift-ovn-kubernetes-node-limited" -B 5 -A 5Repository: openshift/cluster-network-operator Length of output: 8347 🏁 Script executed: cat -n bindata/network/ovn-kubernetes/dpu-rbac.yamlRepository: openshift/cluster-network-operator Length of output: 2187 🏁 Script executed: # Search for the impersonation ClusterRole mentioned in the test
rg "openshift-ovn-kubernetes-node-dpu-host-impersonator" -A 20 -B 2Repository: openshift/cluster-network-operator Length of output: 4132 🏁 Script executed: cat -n pkg/network/ovn_kubernetes_dpu_host_test.go | head -120Repository: openshift/cluster-network-operator Length of output: 4414 🏁 Script executed: # Find the test case definition and structure
rg "TestOVNKubernetesDPU|expectImpersonation" -B 5 -A 10 | head -80Repository: openshift/cluster-network-operator Length of output: 3717 🏁 Script executed: # Get more detail on the test to see if it validates the rules content
rg "TestOVNKubernetesDPURBAC" -A 100 | grep -A 50 "rule0"Repository: openshift/cluster-network-operator Length of output: 1335
When NETWORK_NODE_IDENTITY_ENABLE is true, the DPU RoleBinding grants lease permissions to the Suggested fix - apiGroups: [""]
resources:
- groups
verbs:
- impersonate
resourceNames:
+ - system:ovn-nodes
- system:nodes
- system:authenticated📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||
| apiVersion: rbac.authorization.k8s.io/v1 | ||||||||||||||||||||||||||||||||||||
| kind: ClusterRoleBinding | ||||||||||||||||||||||||||||||||||||
| metadata: | ||||||||||||||||||||||||||||||||||||
| name: openshift-ovn-kubernetes-node-dpu-host-impersonator | ||||||||||||||||||||||||||||||||||||
| roleRef: | ||||||||||||||||||||||||||||||||||||
| apiGroup: rbac.authorization.k8s.io | ||||||||||||||||||||||||||||||||||||
| kind: ClusterRole | ||||||||||||||||||||||||||||||||||||
| name: openshift-ovn-kubernetes-node-dpu-host-impersonator | ||||||||||||||||||||||||||||||||||||
| subjects: | ||||||||||||||||||||||||||||||||||||
| - kind: ServiceAccount | ||||||||||||||||||||||||||||||||||||
| name: ovn-kubernetes-node-dpu-service | ||||||||||||||||||||||||||||||||||||
| namespace: openshift-ovn-kubernetes | ||||||||||||||||||||||||||||||||||||
| {{ end }} | ||||||||||||||||||||||||||||||||||||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: openshift/cluster-network-operator
Length of output: 124
🏁 Script executed:
Repository: openshift/cluster-network-operator
Length of output: 109
🏁 Script executed:
Repository: openshift/cluster-network-operator
Length of output: 1127
🏁 Script executed:
Repository: openshift/cluster-network-operator
Length of output: 2187
🏁 Script executed:
Repository: openshift/cluster-network-operator
Length of output: 114
🏁 Script executed:
sed -n '470,490p' ./pkg/network/ovn_kubernetes.goRepository: openshift/cluster-network-operator
Length of output: 1076
🏁 Script executed:
rg -i "dpuhostmode|dpuhost" --context=5Repository: openshift/cluster-network-operator
Length of output: 36646
🏁 Script executed:
rg -i "dpuhostnodeusers"Repository: openshift/cluster-network-operator
Length of output: 60
🏁 Script executed:
rg -i "system:node:" --context=3Repository: openshift/cluster-network-operator
Length of output: 60
🏁 Script executed:
sed -n '460,490p' ./pkg/network/ovn_kubernetes.goRepository: openshift/cluster-network-operator
Length of output: 1553
🏁 Script executed:
Repository: openshift/cluster-network-operator
Length of output: 489
🏁 Script executed:
Repository: openshift/cluster-network-operator
Length of output: 2391
🏁 Script executed:
rg "type OVNConfigBoostrapResult struct" -A 20 ./pkg/bootstrap/types.goRepository: openshift/cluster-network-operator
Length of output: 883
Restrict
usersimpersonation to specificsystem:node:*principals.The rule at lines 37-41 permits
ovn-kubernetes-node-dpu-serviceto impersonate any user in the cluster. This is inconsistent with thegroupsrule (lines 42-48), which correctly restricts impersonation tosystem:nodesandsystem:authenticated. Arbitrary user impersonation turns a DPU pod compromise into cluster-wide privilege escalation.Add a
DPUHostNodeUsersfield to the render data inpkg/network/ovn_kubernetes.go(populate before line 477) by transforming each node name fromDpuHostModeNodesintosystem:node:<nodeName>format, then update the RBAC template to includeresourceNamesfor the users rule:Suggested fix
In
pkg/network/ovn_kubernetes.go, populatedata.Data["DPUHostNodeUsers"]with the transformed node names (e.g.,system:node:node-1) before renderingdpu-rbac.yaml.🤖 Prompt for AI Agents