Shared host network namespace This product is not supported for your selected
Datadog site . (
).
Id: kubernetes-shared-host-network-namespace
Platform: Kubernetes
Severity: Medium
Category: Resource Management
Learn More Description Containers should not share the host network namespace. Setting spec.hostNetwork to true causes a pod’s containers to use the node’s network namespace, exposing host network interfaces and reducing network isolation. This rule flags resources where spec.hostNetwork is true; it expects spec.hostNetwork to be false or undefined.
Compliant Code Examples apiVersion : v1
kind : Pod
metadata :
name : security-context-demo
spec :
securityContext :
runAsUser : 1000
runAsGroup : 3000
fsGroup : 2000
volumes :
- name : sec-ctx-vol
emptyDir : { }
containers :
- name : sec-ctx-demo
image : busybox
command : [ "sh" , "-c" , "sleep 1h" ]
volumeMounts :
- name : sec-ctx-vol
mountPath : /data/demo
securityContext :
allowPrivilegeEscalation : false
apiVersion : serving.knative.dev/v1
kind : Configuration
metadata :
name : dummy-config
namespace : knative-sequence
spec :
template :
spec :
hostNetwork : false
securityContext :
runAsUser : 1000
runAsGroup : 3000
fsGroup : 2000
volumes :
- name : sec-ctx-vol
emptyDir : { }
containers :
- name : sec-ctx-demo
image : busybox
command : [ "sh" , "-c" , "sleep 1h" ]
volumeMounts :
- name : sec-ctx-vol
mountPath : /data/demo
securityContext :
allowPrivilegeEscalation : false
Non-Compliant Code Examples apiVersion : v1
kind : Pod
metadata :
name : security-context-demo
spec :
hostNetwork : true
securityContext :
runAsUser : 1000
runAsGroup : 3000
fsGroup : 2000
volumes :
- name : sec-ctx-vol
emptyDir : { }
containers :
- name : sec-ctx-demo
image : busybox
command : [ "sh" , "-c" , "sleep 1h" ]
volumeMounts :
- name : sec-ctx-vol
mountPath : /data/demo
securityContext :
allowPrivilegeEscalation : false
apiVersion : serving.knative.dev/v1
kind : Configuration
metadata :
name : dummy-config
namespace : knative-sequence
spec :
template :
spec :
hostNetwork : true
securityContext :
runAsUser : 1000
runAsGroup : 3000
fsGroup : 2000
volumes :
- name : sec-ctx-vol
emptyDir : { }
containers :
- name : sec-ctx-demo
image : busybox
command : [ "sh" , "-c" , "sleep 1h" ]
volumeMounts :
- name : sec-ctx-vol
mountPath : /data/demo
securityContext :
allowPrivilegeEscalation : false