turbot/steampipe-mod-azure-compliance

Control: 1.20 Ensure that no custom subscription owner roles are created

Description

Subscription ownership should not include permission to create custom owner roles. The principle of least privilege should be followed and only necessary privileges should be assigned instead of allowing full administrative access.

Classic subscription admin roles offer basic access management and include Account Administrator, Service Administrator, and Co-Administrators. It is recommended the least necessary permissions be given initially. Permissions can be added as needed by the account holder. This ensures the account holder cannot perform actions which were not intended.

Remediation

From Command Line

  1. Execute to get the list of role definitions to check for entries with assignableScope of / or a subscription, and an action of * Verify the usage and impact of removing the role identified
az role definition list
  1. Review output for each returned role's 'AssignableScopes' value for '/' or the current subscription, and 'Actions' containing the '*' wildcard character. Based on the findings delete the role.
az role definition delete --name "rolename"

Usage

Run the control in your terminal:

powerpipe control run azure_compliance.control.cis_v140_1_20

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run azure_compliance.control.cis_v140_1_20 --share

SQL

This control uses a named query:

with owner_custom_roles as (
select
role_name,
role_type,
title,
action,
_ctx,
subscription_id
from
azure_role_definition,
jsonb_array_elements(permissions) as s,
jsonb_array_elements_text(s -> 'actions') as action
where
role_type = 'CustomRole'
and action in ('*', '*:*')
)
select
cr.subscription_id as resource,
case
when count(*) > 0 then 'alarm'
else 'ok'
end as status,
case
when count(*) = 1 then 'There is one custom owner role.'
when count(*) > 1 then 'There are ' || count(*) || ' custom owner roles.'
else 'There are no custom owner roles.'
end as reason
, sub.display_name as subscription
from
owner_custom_roles cr,
azure_subscription sub
where
sub.subscription_id = cr.subscription_id
group by
cr.subscription_id,
cr._ctx,
sub.display_name;

Tags