Cloud Policies: Custom

This is a how-to guide for creating custom cloud policies.

Create custom policies to address specific issues relevant to your organization. Custom policies can be based on:

Custom policies created on the organization level or within a group of accounts (folder) are inherited to all children accounts, including to any children accounts created at a later time. You can only enable or disable a custom policy from the original folder/account that you created it from. For example, if you created a custom policy from the top-level AWS folder, you won’t be able to enable/disable it from any children folders/accounts within the AWS folder. In this case, the status you define in the top-level AWS folder is propagated to all children folders/accounts. See Account Hierarchy and Folders for more information about folders.

If you created an automation rule and chose to apply it to All policies, any automation targets (actions) that you selected will also apply to custom policies that you create.

Choose a Policy Type

Policy Type Use It When
Template A template already covers the check, such as which principals have which permissions on a resource. No code required.
Explorer query The condition spans several resources, such as a public virtual machine that can reach a sensitive bucket, or an identity with access to sensitive data.
Rego You need fine-grained control over one resource's own configuration, you want to adapt a built-in Rego policy to your environment, your team already has OPA skills to reuse, or you want policy-as-code control.

Add a Custom Policy

Required Cloud Exposure User Role: To create, edit, and delete a custom policy, you need the Collaborator or Administrator role, or a custom role with the Manage permission for Policies, on the scope where you create the policy. See Users and Groups.

To add a custom policy:

  1. (Optional) Select an account scope in the Organization dropdown to limit the scope of the custom policy to a specific subset of cloud accounts. By default, the entire organization (all accounts) is selected.
  2. In the left navigation pane, click Policies > Cloud Policies.
  3. Select the Custom tab.
  4. Click + Create Custom Policy. The Create Custom Policy wizard opens.
  5. Select the policy type.

     

  6. Enter a meaningful name and an optional description.
  7. Assign the policy a severity, which determines the severity level of any findings triggered by the policy.
  8. (Optional) Enter custom remediation steps to provide clear guidance for security teams.
  9. When finished, click Create.

Write a Policy with Hexa AI

If Hexa AI is available in your organization, you can describe a policy in plain language and let Hexa AI write it. This works for both query-based and Rego-based custom policies.

Hexa AI prefers Explorer queries. When a check can be expressed as a query, Hexa AI creates a query-based policy, which is easier to read and maintain if you don't know Rego. Hexa AI writes Rego only when the check can't be expressed as a query, or when you ask for Rego explicitly.

To write a policy with Hexa AI:

  1. Open Hexa AI and describe the check, for example Write a Rego policy that fails any S3 bucket without an owner tag ending in @acme.com.
  2. Hexa AI identifies the resource type, reads a sample resource from your environment, and writes a policy that validates. The card shows the proposed name, description, resource type, severity, remediation, and the query or Rego code.
  3. Click Create Policy. The editor opens prefilled with what Hexa AI wrote. The policy isn't saved yet.
  4. Test the policy, adjust it if needed, and then create it. For a Rego policy, test it with Single and Batch. See Test a Policy.

Always test a policy that Hexa AI wrote before you create it, the same as one you wrote yourself.

Custom Policy Templates

Cloud Exposure provides a number of templates that you can use to create custom policies. These templates provide a flexible way of defining exactly which resources you want to monitor, and how. For example, you can use the Monitor any activity of these identities template to create a custom policy that monitors activity in a break glass account (used for emergency purposes) to ensure that it’s not being used by unauthorized identities. Or, for example, you can use templates that monitor changes in buckets/keys/secrets to monitor critical, “crown jewel” assets in your environment.

Note: If you're interested in configuring custom policies that aren’t supported by any of the available templates, please contact your Cloud Exposure representative.

The following templates, divided by category, can be used to create custom policies that address specific use cases:

Category Cloud Template Potential Use Case
Monitor Permissions AWS Only these principals should have these permissions Protecting crown jewel data. Prevent specific identities from accessing sensitive resources.
AWS For these resources, only these principals should have these permissions Segregation of duties. Only specific identities should have access to this resource(s).
Azure Only these principals should have these permissions on these resources Segregation of duties. Only specific identities should have access to this resource(s).
AWS/Azure/GCP These principals should not have these permissions on these resources Protecting crown jewel data. Prevent specific identities from accessing sensitive resources.
Azure/GCP These principals should not have these roles on these resources Impersonation. Monitor changes in access to sensitive roles.
AWS These roles should have policies that match this reference role

Note: If you use organizational roles, and want per-account instances of the roles to conform to a pre-defined template, you can use this template to alert when the set of attached policies deviates from the chosen reference role.
AWS Monitor policy, ACL, and Block Public Access setting changes in these buckets Protecting crown jewel data. Get alerts on changes to sensitive bucket configuration.
AWS Monitor permission changes in these keys Protecting crown jewel data. Get alerts on changes to key policies.
AWS Monitor policy changes in these secrets Protecting crown jewel data. Get alerts on changes to specific secret policies.
AWS Monitor changes on identity-based policies attached to these principals IMonitor policy changes on high-impact principals to prevent privilege escalation.
AWS Monitor trust policy changes in these roles Impersonation. Monitor changes in access to sensitive roles.
Monitor Activity AWS/Azure/GCP

Monitor any activity of these identities

Important Notes:

  • GCP:To use this policy, which requires access to GCP activity log data, you must configure the audit log forwarding steps as part of GCP integration to Cloud Exposure.
  • Azure — Activity monitoring relies exclusively on management write logs from Azure.
Monitor break glass accounts. Monitor identity activity for use of break glass accounts.
Monitor Sensitive Data AWS/Azure This sensitive data should not reside in these resources Detects sensitive data that is stored within restricted boundaries where it should not reside. Use to monitor data sprawl and enforce data boundary compliance. Learn more.
Monitor Resources AWS Monitor rule changes in these security groups Network security. Monitor changes to sensitive security groups.
AWS Monitor policy, ACL, and Block Public Access setting changes in these buckets Protecting crown jewel data. Get alerts on changes to sensitive bucket configuration.
AWS Monitor permission changes in these keys Protecting crown jewel data. Get alerts on changes to key policies.
AWS Monitor policy changes in these secrets Protecting crown jewel data. Get alerts on changes to specific secret policies.
AWS Monitor these IAM principals of these types that are created Monitoring access. Monitor newly created identities.
AWS Monitor trust policy changes in these roles Impersonation. Monitor changes in access to sensitive roles.
AWS Monitor when these permission sets are assigned to users or groups Monitoring access. Monitor AWS Identity Center permission set changes.
AWS Monitor when these permission sets are created or updated Monitoring access. Monitor AWS Identity Center permission set changes.
AWS Monitor rule changes in these security groups Network security. Monitor changes to sensitive security groups.
AWS/Azure/GCP

Resources should not allow inbound internet connection from these IPv4 address ranges to these ports

Note: This policy applies to the following resources:

  • GCP — Instance Groups and VM Instances
  • Azure — Virtual Machines, Virtual Machine Scale Sets, Load Balancers, and Application Gateways
  • AWS — EC2 Instances, EC2 Services, Load Balancers, RDS Instances and Redshift Clusters
Network security. Limit access from external networks.
AWS These security groups should not allow inbound internet access from these IP address ranges to these ports. Network security. Limit access from internal or external networks.
AWS These security groups should allow inbound internet access from these IP address ranges to these ports. Network security. Limit access from internal or external networks.

For a worked example of building a custom data type and a custom sensitive data policy, see Governing Proprietary Sensitive Data.