Kubernetes auditing
Table of Contents
Expand all | Collapse all
-
- Getting started
- System Requirements
- Cluster Context
-
- Prisma Cloud Container Images
- Kubernetes
- Deploy the Prisma Cloud Console on Amazon ECS
- Console on Fargate
- Onebox
- Alibaba Cloud Container Service for Kubernetes (ACK)
- Azure Container Service (ACS) with Kubernetes
- Azure Kubernetes Service (AKS)
- Amazon Elastic Kubernetes Service (EKS)
- IBM Kubernetes Service (IKS)
- OpenShift v4
-
- Defender Types
- Manage your Defenders
- Redeploy Defenders
- Uninstall Defenders
-
- Deploy Orchestrator Defenders on Amazon ECS
- Automatically Install Container Defender in a Cluster
- Deploy Prisma Cloud Defender from the GCP Marketplace
- Deploy Defenders as DaemonSets
- VMware Tanzu Application Service (TAS) Defender
- Deploy Defender on Google Kubernetes Engine (GKE)
- Google Kubernetes Engine (GKE) Autopilot
- Deploy Defender on OpenShift v4
-
- Agentless Scanning Modes
-
- Onboard AWS Accounts for Agentless Scanning
- Onboard Azure Accounts for Agentless Scanning
- Configure Agentless Scanning for Azure
- Onboard GCP Accounts for Agentless Scanning
- Configure Agentless Scanning for GCP
- Onboard Oracle Cloud Infrastructure (OCI) Accounts for Agentless Scanning
- Configure Agentless Scanning for Oracle Cloud Infrastructure (OCI)
- Agentless Scanning Results
-
- Rule ordering and pattern matching
- Backup and restore
- Custom feeds
- Configuring Prisma Cloud proxy settings
- Prisma Cloud Compute certificates
- Configure scanning
- User certificate validity period
- Enable HTTP access to Console
- Set different paths for Defender and Console (with DaemonSets)
- Authenticate to Console with Certificates
- Configure custom certs from a predefined directory
- Customize terminal output
- Collections
- Tags
- Logon settings
- Reconfigure Prisma Cloud
- Subject Alternative Names
- WildFire Settings
- Log Scrubbing
- Clustered-DB
- Permissions by feature
-
- Logging into Prisma Cloud
- Integrating with an IdP
- Integrate with Active Directory
- Integrate with OpenLDAP
- Integrate Prisma Cloud with Open ID Connect
- Integrate with Okta via SAML 2.0 federation
- Integrate Google G Suite via SAML 2.0 federation
- Integrate with Azure Active Directory via SAML 2.0 federation
- Integrate with PingFederate via SAML 2.0 federation
- Integrate with Windows Server 2016 & 2012r2 Active Directory Federation Services (ADFS) via SAML 2.0 federation
- Integrate Prisma Cloud with GitHub
- Integrate Prisma Cloud with OpenShift
- Non-default UPN suffixes
- Compute user roles
- Assign roles
-
- Prisma Cloud Vulnerability Feed
- Scanning Procedure
- Vulnerability Management Policies
- Vulnerability Scan Reports
- Scan Images for Custom Vulnerabilities
- Base images
- Vulnerability Explorer
- CVSS scoring
- CVE Viewer
-
- Configure Registry Scans
- Scan images in Alibaba Cloud Container Registry
- Scan images in Amazon Elastic Container Registry (ECR)
- Scan images in Azure Container Registry (ACR)
- Scan images in Docker Registry v2 (including Docker Hub)
- Scan Images in GitLab Container Registry
- Scan images in Google Artifact Registry
- Scan images in Google Container Registry (GCR)
- Scan images in Harbor Registry
- Scan images in IBM Cloud Container Registry
- Scan Images in JFrog Artifactory Docker Registry
- Scan Images in Sonatype Nexus Registry
- Scan images in OpenShift integrated Docker registry
- Scan Images in CoreOS Quay Registry
- Trigger registry scans with Webhooks
- Configure VM image scanning
- Configure code repository scanning
- Malware scanning
- Windows container image scanning
- Serverless Functions Scanning
- VMware Tanzu Blobstore Scanning
- Scan App-Embedded workloads
- Troubleshoot Vulnerability Detection
-
- Compliance Explorer
- Enforce compliance checks
- CIS Benchmarks
- Prisma Cloud Labs compliance checks
- Serverless functions compliance checks
- Windows compliance checks
- DISA STIG compliance checks
- Custom compliance checks
- Trusted images
- Host scanning
- VM image scanning
- App-Embedded scanning
- Detect secrets
- OSS license management
-
- Alert mechanism
- AWS Security Hub
- Cortex XDR alerts
- Cortex XSOAR alerts
- Email alerts
- Google Cloud Pub/Sub
- Google Cloud Security Command Center
- IBM Cloud Security Advisor
- JIRA Alerts
- PagerDuty alerts
- ServiceNow alerts for Security Incident Response
- ServiceNow alerts for Vulnerability Response
- Slack Alerts
- Splunk Alerts
- Webhook alerts
- API
Kubernetes auditing
The Kubernetes auditing system records the activities of users, administrators, and other components, that have affected the cluster.
Prisma Cloud can ingest, analyze, and alert on security-relevant events.
Write custom rules or leverage Prisma Cloud Labs prewritten rules to assess the incoming audit stream and surface suspicious activity.
Audits types are limited to the ones been configured by the audit policy of the cloud provider.
Rule library
Custom rules are stored in a central library, where they can be reused.
Besides your own rules, Prisma Cloud Labs also distributes rules via the Intelligence Stream.
These rules are shipped in a disabled state by default.
You can review, and optionally apply them at any time.
Your Kubernetes audit policy is defined in
Defend > Access > Kubernetes
, and formulated from the rules in your library.
There are four types of rules, but the only one relevant to the audit policy is the kubernetes-audit type.
Custom rules are written and managed in Console under Defend > Custom rules > Runtime
with an online editor.
The compiler checks for syntax errors when you save a rule.Expression grammar
Expressions let you examine contents of a Kubernetes audit.
Expressions have the following grammar:
- term--integer | string | keyword | event | '(' expression ')' | unaryOp term
- in--'(' integer | string (',' integer | string)*)?
- op--and | or | > | < | >= | ⇐ | = | !=
- unaryOp--not
- keyword--startswith | contains
- string--Strings must be enclosed in double quotes
- integer--int
- event--process, file system, or network
Kubernetes audit events
When Prisma Cloud receives an audit, it is assessed against your policy.
Like all policies in Prisma Cloud, rule order is important.
Rules are processed top to bottom, and processing stops at the first match.
When a rule matches, an alert is raised.
Write rules to surface audits of interest.
Rules are written with the jpath function.
The jpath function extracts fields from JSON objects, which is the format of a Kubernetes audit.
The extracted string can then be compared against strings of interest.
The primary operators for jpath expressions are '=', 'in', and 'contains'.
For non-trivial examples, look at the Prisma Cloud Lab rules.
The argument to jpath is a single string.
The right side of the expression must also be a string.
A basic rule with a single jpath expression has the following form:
jpath("path.in.json.object") = "something"
Let’s look at some examples using the following JSON object as our example audit.
{ "user":{ "uid":"1234", "username":"some-user-name", "groups":[ "group1", "group2" ] }, "stage":"ResponseComplete" }
To examine a user’s UID, use the following syntax.
This expression evaluates to true.
jpath("user.uid") = "1234"
To examine the username, use the following syntax:
jpath("user.username") = "some-user-name"
To examine the stage field, use the following syntax:
jpath("stage") = "ResponseComplete"
To examine the groups list field, use the following syntax:
jpath("user.groups") contains "group1"
Or alternatively:
jpath("user.groups") in ("group1","group2")
Integrating with self-managed clusters
Prisma Cloud supports self-managed clusters. See here for supported Kubernetes versions.
You can deploy clusters with any number of tools, including kubeadm.
Prerequisites:
You’ve already deployed a Kubernetes cluster.Configure the API server
Configure the API server to forward audits to Prisma Cloud.
To configure the audit webhook backend:
- Create an audit policy file that specifies the events to record and the data events should contain.
- Create a configuration file that defines the backend details and configurations.
- Update the API server config file to point to your audit policy and configuration files.
If your API server runs as a pod, then the audit policy and configuration files must be placed in a directory mounted by the API server pod.
Either place the files in an already mounted directory, or create a new one.
If flags/objects related to AuditSink/dynamic auditing were previously added to your API server configuration, remove them.
Otherwise, this setup won’t work.
- Specify the audit policy.Create a file called audit-policy.yaml with the following recommended policy:apiVersion: audit.k8s.io/v1 # This is required. kind: Policy # Generate audit events only for ResponseComplete or panic stages of a request. omitStages: - "RequestReceived" - "ResponseStarted" rules: # Audit on pod exec/attach events - level: Request resources: - group: "" resources: ["pods/exec", "pods/attach"] # Audit on pod creation events - level: Request resources: - group: "" resources: ["pods"] verbs: ["create"] # Audit on changes to the twistlock namespace (defender daemonset) - level: Request verbs: ["create", "update", "patch", "delete"] namespaces: ["twistlock"] # Default catch all rule - level: NoneMore details can be found here.Create a configuration file.Create a configuration file named audit-webhook.yaml.For the server address, <console_url_webhook_suffix>, do the followingStep 1. Perform GET /api/v1/settings/kubernetes-audit and get the suffix. example response: { "webhookUrlSuffix": "Rov4TLMx1UiaJuP99OyulwQVUT0=", "lastPollingTime": null }Step 2. Append the suffix to your console URLapiVersion: v1 kind: Config preferences: {} clusters: - name: <cluster_name> cluster: server: <console_url_webhook_suffix> # compute console endpoint as stated above contexts: - name: webhook context: cluster: <cluster_name> user: kube-apiserver current-context: webhookMove the config files into place.Move both audit-policy.yaml and audit-webhook.yaml to a directory that holds your API server config files. If the API server runs as a pod, move the files to a directory that is accessible to the pod. Accessible directories can be found in the API server config file under mounts.Add flags.Configure the API server to use the policy and configuration files you just created. Add the following flags to the API server config file:spec: containers: - command: # Existing flags ... # New flags for Prisma Cloud: - --audit-policy-file=<PATH-TO-API-SERVER-CONFIG-FILES>/audit-policy.yaml - --audit-webhook-config-file=<PATH-TO-API-SERVER-CONFIG-FILES>/audit-webhook.yamlWhen changing the kube-apiserver config file, the API server automatically restarts. It can take a few minutes for the API server to resume operations.
Integrating with Google Kubernetes Engine (GKE)
On GKE, Prisma Cloud retrieves audits from Stackdriver, polling it every 10 minutes for new data.
Note that there can be some delay between the time an event occurs in the cluster and when it appears in Stackdriver.
Due to Twistock’s polling mechanism, there’s another delay between the time an audit arrives in Stackdriver and when it appears in Prisma Cloud.
See here for GKE cluster versions supported by Prisma Cloud.
Prerequisites:
You’ve created a service account with one of the following authorization scopes:- https://www.googleapis.com/auth/logging.read
- https://www.googleapis.com/auth/logging.admin
- https://www.googleapis.com/auth/cloud-platform.read-only
- https://www.googleapis.com/auth/cloud-platform
- Open Console.
- Go toDefend > Access > Kubernetes.
- SetKubernetes auditingtoEnabled.
- ClickAdd settingsto configure how Prisma Cloud connects to your cloud provider’s managed Kubernetes service.
- SetProvidertoGKE.
- Select your GKE credential.If there are no accounts to select, add one to the xref:~/authentication/credentials-store/credentials-store.adoc[credentials store].
- (Optional) Specify clusters to collect audit data, allows to limit the collected data
- Specify project IDs. If unspecified, the project ID where the service account was created is used
- (Optional) Specify Advanced filter - specify a filter to reduce the amount of data transferredDo not use the resource.type or timestamp filters because Prisma Cloud uses them internally.
- ClickAdd.
- ClickSave.
CA bundle
If you’re sending audit data to Prisma Cloud’s webhook over HTTPS, you must specify a CA bundle in the AuditSink object.
If you’ve customized Console’s certificate, you can get a copy from
Manage > Authentication > System-certificates > TLS certificate for Console
.
Paste the certificate into a file named server-cert.pem, then run the following command:$ openssl base64 -in server-cert.pem -out base64-output -A
In the AuditSingle object, set the value of caBundle to the contents of the base64-output file.
Testing your setup
Write a new rule, or select a prewritten rule from the inventory, and add it your audit policy.
This setup installs a rule that fires when privileged pods are created in the cluster.
- Open Console, and go toDefend > Access > Kubernetes.
- Add a Prisma Cloud Labs prewritten rule.
- ClickSelect rules.
- If you’re integrated with a managed cluster, selectPrisma Cloud Labs - Privileged pod creation. If you’re integrated with GKE, selectPrisma Cloud Labs - GKE - privileged pod creation.There are separate rules for standard Kubernetes and GKE because the structure of the audits are different. Therefore, the logic for parsing the audit JSON is different.
- ClickSave.
- Create a pod deployment file named priv-pod.yaml, and enter the following contents.apiVersion: v1 kind: Pod metadata: name: nginx labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 securityContext: privileged: trueCreate the privileged pod.$ kubectl apply -f priv-pod.yamlVerify an audit was created.Go toMonitor > Events, and select theKubernetes Auditsfilter.
- Open Console.
- Go toDefend > Access > Kubernetes.
- SetKubernetes auditingtoEnabled.
- ClickAdd settingsto configure how Prisma Cloud connects to your cloud provider’s managed Kubernetes service.
- SetProvidertoAKS.
- Select your AKS credential.If there are no accounts to select, add one to the xref:~/authentication/credentials-store/credentials-store.adoc[credentials store].
- (Optional) specify clusters to collect audit data, allows to limit audit data.
- Specify the Workspace Name.We recommend that you use the free 7 day retention period workspace.
- Specify a list of resource groups.If unspecified, all resource groups will be used to retrieve the audits.
- (Optional) Specify Advanced filter to reduce the amount of data transferred.Use this reference for help with the query syntax.
- ClickAdd.
- ClickSave.
- Open Console.
- Go toDefend > Access > Kubernetes.
- SetKubernetes auditingtoEnabled.
- ClickAdd settingsto configure how Prisma Cloud connects to your cloud provider’s managed Kubernetes service.
- SetProvidertoEKS.
- Select your EKS credential.If there are no accounts to select, add one to the xref:~/authentication/credentials-store/credentials-store.adoc[credentials store].
- Specify the cluster region.
- (Optional) Specify Advanced filter to reduce the amount of data transferred.
- ClickAdd.
- ClickSave.
- Open Console, and go toDefend > Access > Kubernetes.
- ClickAdd rule.
- Enter a name for the rule.
- InMessage, enter an audit message to be emitted when an event matches the condition logic in this custom rule.
- Enter your expression logic.You can filter by cluster name (applies to all cloud providers), project ID (GCP), account ID (AWS), resource group (only capital letters, GCP), and subscription ID (Azure)
- ClickAdd.Your expression logic is validated before it’s saved to the Console’s database.
Integrating with Azure Kubernetes Service (AKS)
With AKS, Prisma Cloud retrieves audits from "Log Analytics workspace", polling it every 10-15 minutes for new data.
You will have to enable exporting AKS logs into Azure Workspace, and Prisma Cloud will extract the logs from there.
You only need to export AKS resource logs of the category kube-audit (see here).
Also, there can be some delay between the time an event occurs in the cluster and when it appears in Workspace.
Due to Prisma Cloud’s polling mechanism, there’s another delay between the time an audit arrives in the Workspace and when it appears in Prisma Cloud.
Prisma Cloud supports only AKS cluster versions that allow log exporting.

Integrating with Elastic Kubernetes Service (EKS)
On EKS, Prisma Cloud retrieves audits from AWS "Cloud watch", polling it every 10-15 minutes for new data.
You will have to enable exporting EKS logs into AWS Cloud Watch, and Prisma Cloud will extract the logs from there.
You only need to enable exporting Kubernetes audits (logs of type audit), see here.
Also, there can be some delay between the time an event occurs in the cluster and when it appears in CloudWatch.
Due to Prisma Cloud’s polling mechanism, there’s another delay between the time an audit arrives in the CloudWatch and it appears in Prisma Cloud.
Prisma Cloud supports only EKS cluster versions that allow log exporting.

Custom rules
A custom rule is made up of one or more conditions.
Configure custom rules policy in order to trigger audits and match them.
Prisma Cloud supports GKE, EKS, and AKS clusters.
Write a Kubernetes custom rule
Expression syntax is validated when you save a custom rule.