Create a Custom Policy on Prisma Cloud
Create a custom policy to meet your specific needs for compliance or monitoring of cloud resources.
You can create a custom policy with remediation rules that are tailored to meet the requirements of your organization. When creating a new policy, you can either build the query using RQL or you use a saved search to automatically populate the query you need to match on your cloud resources. For Cloud Application Security, you can also create configuration policies to scan your Infrastructure as Code (IaC) templates that are used to deploy cloud resources. The policies used for scanning IaC templates use a JSON query instead of RQL.
If you want to enable auto-remediation, Prisma Cloud requires write access to your cloud platform to successfully execute the remediation commands.
You can create the following types of custom policies:
Attack Path—Attack path policies monitor the high risk attack paths for possible breaches. See Attack Path Policies.
Audit Event—Event policies monitor audit events in your environment for potential policy violations. You create audit policies to flag sensitive events such as root activities or configuration changes that may potentially put your cloud environment at risk. See Create a Network or Audit Event Policy.
Config—Configuration policies monitor your resource configurations for potential policy violations. Configuration policies on Prisma Cloud can be of two sub-types—Build and Run—to enable a layered approach. Build policies enable you to check for security misconfigurations in the IaC templates and ensure that these issues do not make their way into production. The Run policies monitor resources and check for potential issues once these cloud resources are deployed. See Create a Configuration Policy.
Data—Data policies protect against malware and enable data classification. To identify sensitive data in cloud storage buckets, it uses machine learning and pattern matching. See Data Policies.
IAM—IAM policies monitor the identities in your cloud environment for excess-or-unused permissions. See Create an IAM Policy.
Network—Network policies monitor network activities in your environment. See Create a Network or Audit Event Policy.
Create a Configuration Policy
Use these instructions to add a custom configuration policy, for checking resources in the build or run phase of your application lifecycle. Because building the rules takes practice, before you start, take a look at a few Prisma Cloud default policies directly on the administrative console, and review the query format within the rules.
You must enable a Configuration policy with the subtype Run, Build and attach it to an alert rule on Prisma Cloud if you want to view the build-time details in an alert.

Select Governance.
Select Add Policy > Config.
Enter a Policy Name.
You can optionally add a Description and Labels.
NOTE: When creating a custom policy or modifying a default policy, do not use or delete system assigned labels.
Select the policy subtype and select Next.
You can choose one or both the policy subtypes options:
Run subtype enables you to scan cloud resources that are already deployed on a supported cloud platform.
Build subtype enables you to scan code repositories and IaC templates that are used to deploy cloud resources.

Select the Severity for the policy and select Next.
For a Run policy, an alert will be generated on a policy violation.
Build the query to define the match criteria for your policy.
Add a rule for the Run phase.
The Configuration—Run policies use RQL. If you are using a Saved Search, you can select from predefined options to auto-populate the query. For building a New Search,
config from cloud.resource whereand use the auto-suggestion to select the available attributes and complete the query.
Config queries require some mandatory attributes. It should begin with
config where cloud.resource whereand at a minimum haveapi.namein conjunction withjson.ruleor it can have an attribute from completion suggestions, or it can have twoapi.nameattributes with afilterattribute.NOTE: When creating a custom policy, as a best practice do not include
cloud.account,cloud.accountgroup,cloud.region,resource.status, ortagattributes in the RQL query. If you have a saved search that includes these attributes, make sure to edit the RQL before you create a custom policy. While these attributes are useful to filter the results you see on Investigate, they are ignored by the policy engine (scanner) when used in a custom policy.Add a rule for the Build phase.
If your policy will include both Run and Build checks, and you have added the RQL query, your cloud type for the build rule is automatically selected. It is based on the cloud type referenced in the RQL query.
NOTE: If you have activated the Application Security module, see Create a custom build policy to continue with creating a build policy rule.
Add the compliance standards to your policy.
Choose the compliance Standard, Requirement, and Section.
Click + to add more standards as required and click Next.
Enter details in the remediation section, if you want to automatically remediate alerts on a policy violation.
Select Run or Build
Build phase policies do not support remediation via CLI or UI.
(tt:[Configuration—Run policies only]) Enter Command Line remediation commands in CLI Remediation.
CLI remediation is available for
config fromqueries only. You can add up to 5 CLI commands, and use a semi-colon to separate the commands in the sequence. The sequence is executed in the order defined in policy, and if a CLI command fails, the execution stops at that command. The parameters that you can use to create remediation commands are displayed on the interface as CLI variables, and a syntax example is:gcloud -q compute --project=${account} firewall-rules delete ${resourceName}; gsutil versioning set off gs://${resourceName};:$account — Account is the Account ID of your account in Prisma Cloud.
$azurescope — tt:[(Azure only)] Allows you to specify the node in the Azure resource hierarchy where the resource is deployed.
$gcpzoneid — tt:[(GCP only)] Allows you to specify the zone in the GCP project, folder, or organization where the resource is deployed.
$region — Region is the name of the cloud region to which the resource belongs.
resourcegroup — tt:[(Azure only)] Allows you to specify the name of the Azure Resource Group that triggered the alert.
$resourceid — Resource ID is the identification of the resource that triggered the alert.
$resourcename — Resource name is the name of the resource that triggered the alert.
Click Validate syntax to validate the syntax of your code.
If you would like to see an example of the CLI syntax in the default remediable policies on Prisma Cloud, Manage Prisma Cloud Policies any existing policy and edit it.
NOTE: The default policies include additional variables that are restricted for use in default policies only, and are not supported in custom policies. Syntax validation displays an error if you use the restricted variables.
Select Submit.
All your System Admin, Account and Cloud Provisioning Admin and Account Group Admin are notified when there is a change to the CLI commands.
Serverless auto-remediation is an option (for AWS only for now). For more complex or customizable remediation solutions, check out serverless-autoremediation: https://github.com/PaloAltoNetworks/Prisma-Enhanced-Remediation
Create a Network or Audit Event Policy
Use the following instructions to add a custom Network or Audit Event policy on Prisma Cloud.
For Network policies, the RQL query used in a saved search is different for detecting risk of network exposure versus network protection.
Select Governance.
Select Add Policy > Network.
Enter a Policy Name and Severity.
Add an optional Description and Labels before you click Next.

NOTE: When creating a custom policy or modifying a default policy, do not use or delete system assigned labels.
Build the query to define the match criteria for your policy by using a New Search or a Saved Search and click Next.
If you are using a Saved Search, you can select from the list of predefined options to auto-populate the query. The Select Saved Search drop-down displays the RQL for saved searches that match the policy type you selected in Step 2 above.
For a building a New Search, the RQL query must begin with
event fromfor an Audit Event policy; for Network policyconfig from network where, ornetwork from, ornetwork from vpc.flow_record where. You can then use the auto-suggestion to select the available attributes and complete the query.
(tt:[Optional]) Select the compliance standards for your policy.
Compliance standards can be only associated with custom policies for Audit Events, and for Network policies that do not use the RQL
config from network where.Choose the compliance Standard, Requirement, and Section.
Click + to add more standards as required and click Next.
(tt:[Optional]) Provide a Recommendation for Remediation.
CLI commands to enable automatic remediation are not supported on Audit Event or Network policy.
Save the policy.
Create an Attack Path Policy
Use the following instructions to add an Attack Path policy on Prisma Cloud.
Select Governance.
Select Add Policy > Attack Path.
Enter a Policy Name and select the Severity.
(tt:[Optional]) Add a Description and Labels.

NOTE: When creating a custom policy or modifying a default policy, do not use or delete system assigned labels.
Click Next.
Click Select saved search dropdown to select from one of the existing Asset Search queries.
NOTE: You cannot run a New Search in this workflow. However, you can run a new search from the Investigate page and save the query as a custom Attack Path policy.

Click Next.
(tt:[Optional]) Provide a Recommendation for Remediation.
Click Submit to save the policy.
Last updated
Was this helpful?

