Workload mounting with sensitive OS directory This product is not supported for your selected
Datadog site . (
).
Id: terraform-kubernetes-workload-mounting-with-sensitive-os-directory
Provider: Kubernetes
Platform: Terraform
Severity: High
Category: Insecure Configurations
Learn More Description A workload is mounting a volume that targets a sensitive host OS directory via host_path. Mounting directories such as /etc, /proc, /root, or /usr can expose host files and compromise container-host isolation. This rule flags host_path mounts that target these sensitive OS directories.
Compliant Code Examples resource "kubernetes_pod" "test3" {
metadata {
name = "terraform-example3"
}
spec {
container {
image = "nginx:1.7.9"
name = "example"
env {
name = "environment"
value = "test"
}
port {
container_port = 8080
}
liveness_probe {
http_get {
path = "/nginx_status"
port = 80
http_header {
name = "X-Custom-Header"
value = "Awesome"
}
}
initial_delay_seconds = 3
period_seconds = 3
}
}
dns_config {
nameservers = [ "1.1.1.1" , "8.8.8.8" , "9.9.9.9" ]
searches = [ "example.com" ]
option {
name = "ndots"
value = 1
}
option {
name = "use-vc"
}
}
dns_policy = "None"
}
}
resource "kubernetes_persistent_volume" "test4" {
metadata {
name = "terraform-example4"
}
spec {
container {
image = "nginx:1.7.9"
name = "example"
env {
name = "environment"
value = "test"
}
port {
container_port = 8080
}
liveness_probe {
http_get {
path = "/nginx_status"
port = 80
http_header {
name = "X-Custom-Header"
value = "Awesome"
}
}
initial_delay_seconds = 3
period_seconds = 3
}
}
dns_config {
nameservers = [ "1.1.1.1" , "8.8.8.8" , "9.9.9.9" ]
searches = [ "example.com" ]
option {
name = "ndots"
value = 1
}
option {
name = "use-vc"
}
}
dns_policy = "None"
}
}
Non-Compliant Code Examples resource "kubernetes_pod" "test1" {
metadata {
name = "terraform-example1"
}
spec {
container {
image = "nginx:1.7.9"
name = "example"
env {
name = "environment"
value = "test"
}
port {
container_port = 8080
}
liveness_probe {
http_get {
path = "/nginx_status"
port = 80
http_header {
name = "X-Custom-Header"
value = "Awesome"
}
}
initial_delay_seconds = 3
period_seconds = 3
}
}
dns_config {
nameservers = [ "1.1.1.1" , "8.8.8.8" , "9.9.9.9" ]
searches = [ "example.com" ]
option {
name = "ndots"
value = 1
}
option {
name = "use-vc"
}
}
volume {
host_path {
path = "/var/log"
}
}
dns_policy = "None"
}
}
resource "kubernetes_persistent_volume" "test2" {
metadata {
name = "terraform-example2"
}
spec {
container {
image = "nginx:1.7.9"
name = "example"
env {
name = "environment"
value = "test"
}
port {
container_port = 8080
}
liveness_probe {
http_get {
path = "/nginx_status"
port = 80
http_header {
name = "X-Custom-Header"
value = "Awesome"
}
}
initial_delay_seconds = 3
period_seconds = 3
}
}
dns_config {
nameservers = [ "1.1.1.1" , "8.8.8.8" , "9.9.9.9" ]
searches = [ "example.com" ]
option {
name = "ndots"
value = 1
}
option {
name = "use-vc"
}
}
volume {
host_path {
path = "/var/log"
}
}
dns_policy = "None"
}
}