Control: 1.22 Ensure That No Custom Subscription Administrator Roles Exist
Description
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 Azure Portal
- From Azure Home select the Portal Menu.
- Select
Subscriptions
. - Select
Access control (IAM)
. - Select
Roles
. - Click
Type
and selectCustomRole
from the drop down menu. - Check the box next to each role which grants subscription administrator privileges.
- Select
Remove
. - Select
Yes
.
From Azure CLI
List custom roles:
az role definition list --custom-role-only True
Check for entries with assignableScope
of / or the subscription
, and an action of *
. To remove a violating role:
az role definition delete --name <role name>
Note that any role assignments must be removed before a custom role can be deleted. Ensure impact is assessed before deleting a custom role granting subscription administrator privileges.
Default Value
By default, no custom owner roles are created.
Usage
Run the control in your terminal:
powerpipe control run azure_compliance.control.cis_v210_1_22
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run azure_compliance.control.cis_v210_1_22 --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 subscriptionfrom owner_custom_roles cr, azure_subscription subwhere sub.subscription_id = cr.subscription_idgroup by cr.subscription_id, cr._ctx, sub.display_name;