> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/compute/appsec-k8s-2.md).

# Privileged containers are admitted misconfiguration detected in code

## Rule Details

|                        |                                                        |
| ---------------------- | ------------------------------------------------------ |
| Cortex AppSec Rule ID  | APPSEC\_K8S\_2                                         |
| Category - Subcategory | Kubernetes - Access Control                            |
| Provider               | OTHER                                                  |
| Severity               | HIGH                                                   |
| Framework              | Helm, Kubernetes, Kustomize, Terraform, Terraform Plan |

## Impact

Privileged containers are containers that have all of the root capabilities of a host machine, allowing access to resources that are not accessible in ordinary containers. Running a container with a privileged flag allows users to have critical access to the host's resources. If a privileged container is compromised, it does not necessarily entail remote code execution, but it implies that an attacker will be able to run full host root with all of the available capabilities, including CAP\_SYS\_ADMIN. Common uses of privileged containers include: running a Docker daemon inside a Docker container, running a container with direct hardware access, and automating CI/CD tasks in the open-source automation server Jenkins.

## How to Fix

*Resource:* PodSecurityPolicy

* *Arguments:* privileged (Optional) When set to false, containers are unable to run processes that are essentially equivalent to root on the host.

To use a **PodSecurityPolicy** resource, the requesting user or target pod's service account must be authorized to use the policy. The preferred method is to grant access to the service account.

In the following example we use **RBAC**, a standard Kubernetes authorization mode.

A *Role* or *ClusterRole* must grant access to *use* the desired policies.

*Kind*: ClusterRole

The **ClusterRole** is then bound to the authorized service(s):

## *Kind*: ClusterRoleBinding \[source,go]

apiVersion: policy/v1beta1 kind: PodSecurityPolicy metadata: name: spec:

* privileged: false

***

apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: rules:

* apiGroups: \['policy'] resources: \['podsecuritypolicies'] verbs: \['use'] resourceNames:
*

***

apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: roleRef: kind: ClusterRole name: apiGroup: rbac.authorization.k8s.io subjects:

* kind: ServiceAccount name: namespace:

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/compute/appsec-k8s-2.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
