For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/k8s/permissive_access_to_create_pods.md.
A documentation index is available at /llms.txt.
The permission to create pods in a cluster should be restricted because it can allow privilege escalation. This rule detects Role and ClusterRole rules where verbs include “create” for the “pods” resource, or where verbs or resources use wildcard values together with non-custom API groups (empty string or “*”). When triggered, the rule reports the document, resource, and rule location containing the unsafe verb/resource combination.
Compliant Code Examples
#this code is a correct code for which the query should not find any resultapiVersion:rbac.authorization.k8s.io/v1kind:ClusterRolemetadata:name:secret-readerrules:- apiGroups:[""]resources:["pods"]verbs:["get","watch","list"]---apiVersion:rbac.authorization.k8s.io/v1kind:ClusterRolemetadata:name:secret-reader2rules:- apiGroups:[""]resources:["secrets"]verbs:["get","watch","create"]---apiVersion:rbac.authorization.k8s.io/v1kind:ClusterRolemetadata:name:secret-reader4rules:- apiGroups:[""]resources:["pods"]verbs:- "get"- "watch"
#this is a problematic code where the query should report a result(s)apiVersion:rbac.authorization.k8s.io/v1kind:ClusterRolemetadata:name:secret-readerrules:- apiGroups:- "*"resources:- "*"verbs:- get- list- watch- apiGroups:- apiextensions.k8s.ioresources:- customverbs:- create- delete- apiGroups:- "*"resources:- "*"verbs:- create- delete- get- list- patch- update- watch
#this is a problematic code where the query should report a result(s)apiVersion:rbac.authorization.k8s.io/v1kind:ClusterRolemetadata:name:secret-readerrules:- apiGroups:[""]resources:["pods"]verbs:- "get"- "watch"- "create"---apiVersion:rbac.authorization.k8s.io/v1kind:Rolemetadata:name:secret-reader2rules:- apiGroups:[""]resources:["*"]verbs:["get","watch","create"]---apiVersion:rbac.authorization.k8s.io/v1kind:ClusterRolemetadata:name:secret-reader3rules:- apiGroups:[""]resources:["pods"]verbs:["get","watch","*"]---apiVersion:rbac.authorization.k8s.io/v1kind:Rolemetadata:name:secret-reader4rules:- apiGroups:[""]resources:["*"]verbs:["get","watch","*"]---apiVersion:rbac.authorization.k8s.io/v1kind:ClusterRolemetadata:name:secret-reader5rules:- apiGroups:[""]resources:["pods"]verbs:- "get"- "watch"- "c*e"---apiVersion:rbac.authorization.k8s.io/v1kind:ClusterRolemetadata:name:secret-reader6rules:- apiGroups:[""]resources:["p*ds"]verbs:["get","watch","create"]
1
2
rulesets:- Kubernetes / Kubernetes # Rules to enforce / Kubernetes.
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.