Terraform Host Pid Enabled
Description
Detects when Kubernetes configurations enable host PID namespace sharing (hostPID: true), which allows containers to see and potentially interact with processes running on the host system. This breaks container isolation and can lead to privilege escalation or information disclosure vulnerabilities.
Detection Strategy
• Scans Kubernetes resource configuration files (like Pod, Deployment, StatefulSet specs)
• Identifies resource specifications that contain container configurations
• Checks if 'hostPID' attribute is explicitly set to true in the spec section
• Reports a vulnerability when containers are configured to share the host's PID namespace
Vulnerable code example
resource "kubernetes_pod" "vulnerable_pod" {
metadata {
name = "vulnerable-pod"
}
spec {
host_pid = true # Security risk: Allows pod to access host PID namespace
container {
name = "nginx"...✅ Secure code example
resource "kubernetes_pod" "secure_pod" {
metadata {
name = "secure-pod"
labels = {
app = "web"
}
}
spec {...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.