metadata:
  id: 05676b4e-3274-5984-9981-6aa1623c24ec
  name: Ensure That No Custom Subscription Administrator Roles Exist
  profile_applicability: '* Level 1'
  description: |-
    The principle of least privilege should be followed and only necessary privileges should be assigned instead of allowing full administrative access.
  rationale: |-
    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.
  audit: |-
    **From Azure Portal**

    1. From Azure Home select the Portal Menu.
    2. Select `Subscriptions`.
    3. Select `Access control (IAM)`.
    4. Select `Roles`.
    5. Click `Type` and select `CustomRole` from the drop down menu.
    6. Select `View` next to a role.
    7. Select `JSON`.
    8. Check for `assignableScopes` set to `/` or the subscription, and `actions` set to `*`.
    9. Repeat steps 6-8 for each custom role.

    **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 `*`

    **From PowerShell**

    ```
    Connect-AzAccount
    Get-AzRoleDefinition |Where-Object {($_.IsCustom -eq $true) -and ($_.Actions.contains('*'))}
    ```

    Check the output for `AssignableScopes` value set to '/' or the subscription.
  remediation: |-
    **From Azure Portal**

    1. From Azure Home select the Portal Menu.
    2. Select `Subscriptions`.
    3. Select `Access control (IAM)`.
    4. Select `Roles`.
    5. Click `Type` and select `CustomRole` from the drop down menu.
    6. Check the box next to each role which grants subscription administrator privileges.
    7. Select `Remove`.
    8. 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.
  impact: Subscriptions will need to be handled by Administrators with permissions.
  default_value: ''
  references: |-
    1. https://docs.microsoft.com/en-us/azure/billing/billing-add-change-azure-subscription-administrator
    2. https://docs.microsoft.com/en-us/security/benchmark/azure/security-controls-v3-governance-strategy#gs-2-define-enterprise-segmentation-strategy
    3. https://docs.microsoft.com/en-us/security/benchmark/azure/security-controls-v3-governance-strategy#gs-6-define-identity-and-privileged-access-strategy
    4. https://docs.microsoft.com/en-us/security/benchmark/azure/security-controls-v3-privileged-access#pa-1-protect-and-limit-highly-privileged-users
    5. https://docs.microsoft.com/en-us/security/benchmark/azure/security-controls-v3-privileged-access#pa-5-automate-entitlement-management
    6. https://docs.microsoft.com/en-us/security/benchmark/azure/security-controls-v3-privileged-access#pa-2-restrict-administrative-access-to-business-critical-systems
    7. https://docs.microsoft.com/en-us/security/benchmark/azure/security-controls-v3-governance-strategy#gs-2-define-enterprise-segmentation-strategy
    8. https://docs.microsoft.com/en-us/security/benchmark/azure/security-controls-v3-governance-strategy#gs-6-define-identity-and-privileged-access-strategy
    9. https://docs.microsoft.com/en-us/security/benchmark/azure/security-controls-v3-privileged-access#pa-7-follow-just-enough-administration-least-privilege-principle
  section: Identity and Access Management
  version: '1.0'
  tags:
  - CIS
  - AZURE
  - CIS 1.23
  - Identity and Access Management
  benchmark:
    name: CIS Microsoft Azure Foundations
    version: v2.0.0
    id: cis_azure
    rule_number: '1.23'
    posture_type: cspm
