Project: KICS (Provisioning / Security & Compliance)
File: c878abb4-cca5-4724-92b9-289be68bd47c.md

title: Privilege Escalation Allowed hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: c878abb4-cca5-4724-92b9-289be68bd47c Query name: Privilege Escalation Allowed Platform: Terraform Severity: <span style="color:#bb2124">High</span> Category: Insecure Configurations URL: Containers should not run with allowPrivilegeEscalation in order to prevent them from gaining more privileges than their parent process<br> ```tf title="Positive test num. 1 - tf file" hl_lines="108 14 47" resource "kubernetes_pod" "positive1" { metadata { name = "terraform-example" } spec { container = [ { image = "nginx:1.7.9" name = "example22" security_context = { allowprivilegeescalation = true } 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" } } initialdelayseconds = 3 period_seconds = 3 } } , { image = "nginx:1.7.9" name = "example22222" security_context = { allowprivilegeescalation = true } 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" } } initialdelayseconds = 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_pod" "positive2" { metadata { name = "terraform-example" } spec { container { image =

name = "example" security_context = { allowprivilegeescalation = true } 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" } } initialdelayseconds = 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" } } ``` ```tf title="Negative test num. 1 - tf file" resource "kubernetes_pod" "negative4" { metadata { name = "terraform-example" } spec { container = [ { image = "nginx:1.7.9" name = "example22" security_context = { allowprivilegeescalation = false } 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" } } initialdelayseconds = 3 period_seconds = 3 } } , { image = "nginx:1.7.9" name = "example22222" security_context = { allowprivilegeescalation = false } 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" } } initialdelayseconds = 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_pod" "negative5" { metadata { name = "terraform-example" } spec { container { image = "nginx:1.7.9" name = "example" security_context = { allowprivilegeescalation = false } 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" } } initialdelayseconds = 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" } } ```