turbot/steampipe-mod-kubernetes-compliance

Control: Job containers should not have privileged access

Description

Containers in a Job should not have privileged access. To prevent security issues, it is recommended that you do not run privileged containers in your environment. Instead, provide granular permissions and capabilities to the container environment. Giving containers full access to the host can create security flaws in your production environment.

Usage

Run the control in your terminal:

powerpipe control run kubernetes_compliance.control.job_container_privilege_disabled

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run kubernetes_compliance.control.job_container_privilege_disabled --share

SQL

This control uses a named query:

select
coalesce(uid, concat(path, ':', start_line)) as resource,
case
when (c -> 'securityContext' ->> 'privileged')::bool then 'alarm'
else 'ok'
end as status,
case
when (c -> 'securityContext' ->> 'privileged')::bool then c ->> 'name' || ' privileged container.'
else c ->> 'name' || ' not privileged container.'
end as reason,
name as job_name
, coalesce(context_name, '') as context_name, namespace, source_type, coalesce(path || ':' || start_line || '-' || end_line, '') as path
from
kubernetes_job,
jsonb_array_elements(template -> 'spec' -> 'containers') as c;

Tags