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.

Add a Custom Policy

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.

Custom Rego Policies

Note: This feature is in early availability and is subject to change. Functionality and support may be limited. To request access or share feedback, contact your Tenable representative.

Custom Rego policies use Rego, the Open Policy Agent (OPA) policy language, to write attribute-level checks against a single resource. They sit between templates, which cover common checks through predefined parameters, and Explorer queries, which provide an easier way to visualize resources.

Use Rego when any of the following apply:

  • You already have Rego expertise and prefer it to templates or graph queries.
  • You need conditions that go beyond what templates and graph queries support.
  • You have an existing policy written in Rego and want to reuse it in Tenable One Cloud Exposure.

If cross-resource logic is required, use an Explorer query instead.

Speed up custom policy development by starting from an existing policy written in Rego, whether built-in or custom. You can also use this approach to tune a built-in policy to your needs: copy the built-in policy, adjust the logic in your copy, and disable the original.

Once created, a Rego-based policy behaves like any other custom policy. Its findings follow the same format, dashboards, reports, automation, ticketing, exclusions, and compliance frameworks, and it uses the same role-based access controls. See Cloud Findings for more information.

Policy Evaluation

Each Rego-based custom policy evaluates one resource at a time. The policy receives the resource as input in raw provider JSON format. A policy cannot retrieve, traverse, or reference other resources during evaluation. Every evaluation ends in exactly one state:

State Meaning
Skipped The resource matches the policy's type but falls outside its entry criteria.
Passed The resource passes the policy evaluation.
Failed The resource fails the policy evaluation, and a finding is produced.
Error The evaluation did not complete due to a runtime error (e.g., invalid resource JSON, logic returns both passed and failed). This state is assigned by the engine.

Helper Functions

A helper function is a small, pre-built piece of logic you call from a custom Rego policy instead of writing it yourself. Checking whether a value is null, empty, or differs from another only by capitalization normally takes several lines of Rego; a helper function wraps that check into a single call.

Cloud Exposure authors and audits every allowlisted helper function for side-effect-free behavior: no network, file, or host access. The allowlist is re-validated with each OPA update, so a new helper function becomes available only after that review.

To use a helper function, click Helper Functions above the Rego editor and copy the function into your policy.

The following table lists each allowlisted helper function and its behavior.

Helper Function Behavior
equals_ignore_case(value_1, value_2) Determines whether value_1 and value_2 are equal, ignoring the case. Returns true when they match regardless of capitalization, otherwise it is false.
get_days_ns(days) Returns the given number of days as a nanosecond duration.
is_false(value) Determines whether the value represented is false. Returns true when its string form equals "false" (case-insensitive), otherwise it is false.
is_true(value) Determines whether the value represented is true. Returns true when its string form equals "true" (case-insensitive), otherwise it is false.
is_null_or_empty(value) Determines whether the value is missing or empty. Returns true when it's null, an empty string, an empty array, or an empty object. Otherwise it is false.

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.