RBAC permits attaching to containers

Access to pods/attach can expose a running container’s output and allow interaction with its process.

Description

Limit production pods/attach access to staff who need to interact with a running container. It connects to the existing process’s output and can send input when standard input is enabled. Starting a new command uses pods/exec.

Potential impact

The output can contain sensitive data. Input to an interactive process can also affect work already in progress.

Remediation

Remove pods/attach from roles that do not need it. Restrict production debugging to approved accounts and procedures, and check whether another role or binding still grants access.

Examples

Both Roles belong to my-namespace; their RoleBindings are omitted.

Before

yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: my-namespace
  name: allow-attach
rules:
  - apiGroups: [""]
    resources: ["pods", "pods/attach"]
    verbs: ["get", "list", "create"]

After

yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: my-namespace
  name: allow-attach-neg
rules:
  - apiGroups: [""]
    resources: ["pods"]
    verbs: ["get", "list", "create"]

The second role omits pods/attach but still permits get, list and create on Pods. Review the existing role bindings and whether Pod creation is needed.

References