rules/findings/Azure/Subscription/CIS3.0/azure-subscription-missing-custom-lock-role.json

{
  "args": [
     
  ],
  "provider": "Azure",
  "serviceType": "Subscription Security",
  "serviceName": "Subscription",
  "displayName": "Ensure Custom Role is Assigned Permissions for Administering Resource Locks",
  "description": "Resource locking is a powerful protection mechanism that can prevent inadvertent modification/deletion of resources within Azure subscriptions/Resource Groups and is a recommended NIST configuration.",
  "rationale": "Given the resource lock functionality is outside of standard Role Based Access Control(RBAC), it would be prudent to create a resource lock administrator role to prevent inadvertent unlocking of resources.",
  "impact": "By adding this role is you can have specific permissions granted for managing just resource locks rather than needing to provide the wide owner or contributor role reducing the risk of the user being able to do unintentional damage.",
  "remediation": {
    "text": "###### From Azure Console\r\n\t\t\t\t\t1. In the Azure portal, open a subscription or resource group where you want the custom role to be assignable.\r\n\t\t\t\t\t2. Select `Access control (IAM)`\r\n\t\t\t\t\t3. Click `Add`\r\n\t\t\t\t\t4. Select `Add custom role`\r\n\t\t\t\t\t5. In the Custom Role Name field enter `Resource Lock Administrator`\r\n\t\t\t\t\t6. In the `Description` field enter appropiate description\r\n\t\t\t\t\t7. For `Baseline permissions` select `Start from scratch`\r\n\t\t\t\t\t8. Click `next`\r\n\t\t\t\t\t9. In the `Permissions` tab select `Add permissions`\r\n\t\t\t\t\t10. in the Search for a permission box, type in `Microsoft.Authorization/locks` to search for permissions.\r\n\t\t\t\t\t11. Select the check box next to the permission called Microsoft.Authorization/locks\r\n\t\t\t\t\t12. Click `add`\r\n\t\t\t\t\t13. Click `Review+create`\r\n\t\t\t\t\t14. Click `Create`\r\n\t\t\t\t\t\r\n\t\t\t\t\tAssign the newly created role to the appropriate user.\r\n\r\n\t\t\t\t\t###### Using PowerShell:\r\n\t\t\t\t\tBelow is a power shell definition for a resource lock administrator role created at an Azure Management group level:\r\n\t\t\t\t\t\r\n\t\t\t\t\t```\r\n\t\t\t\t\tImport-Module Az.Accounts\r\n\t\t\t\t\tConnect-AzAccount\r\n\t\t\t\t\t$role = Get-AzRoleDefinition \"User Access Administrator\"\r\n\t\t\t\t\t$role.Id = $null\r\n\t\t\t\t\t$role.Name = \"Resource Lock Administrator\"\r\n\t\t\t\t\t$role.Description = \"Can Administer Resource Locks\"\r\n\t\t\t\t\t$role.Actions.Clear()\r\n\t\t\t\t\t$role.Actions.Add(\"Microsoft.Authorization/locks/*\")\r\n\t\t\t\t\t$role.AssignableScopes.Clear()\r\n\t\t\t\t\t#Scope at the Management group level Management group\r\n\t\t\t\t\t$role.AssignableScopes.Add(\"/providers/Microsoft.Management/managementGroups/MG-Name\")\r\n\t\t\t\t\tNew-AzRoleDefinition -Role $role\r\n\t\t\t\t\tGet-AzureRmRoleDefinition \"Resource Lock Administrator\"\r\n\t\t\t\t\t```",
    "code": {
      "powerShell": null,
      "iac": null,
      "terraform": null,
      "other": null
    }
  },
  "recommendation": null,
  "references": [
    "https://docs.microsoft.com/en-us/azure/role-based-access-control/custom-roles",
    "https://docs.microsoft.com/en-us/azure/role-based-access-control/check-access",
    "https://docs.microsoft.com/en-us/azure/security/benchmarks/security-controls-v2-privileged-access#pa-1-protect-and-limit-highly-privileged-users",
    "https://docs.microsoft.com/en-us/azure/security/benchmarks/security-controls-v2-privileged-access#pa-2-restrict-administrative-access-to-business-critical-systems",
    "https://docs.microsoft.com/en-us/azure/security/benchmarks/security-controls-v2-privileged-access#pa-7-follow-just-enough-administration-least-privilege-principle",
    "https://docs.microsoft.com/en-us/azure/security/benchmarks/security-controls-v2-privileged-access#pa-5-automate-entitlement-management",
    "https://docs.microsoft.com/en-us/azure/security/benchmarks/security-controls-v2-governance-strategy#gs-2-define-enterprise-segmentation-strategy",
    "https://docs.microsoft.com/en-us/azure/security/benchmarks/security-controls-v2-governance-strategy#gs-6-define-identity-and-privileged-access-strategy"
  ],
  "compliance": [
    {
      "name": "CIS Microsoft Azure Foundations",
      "version": "3.0.0",
      "reference": "2.24",
      "profile":"Level 2"
    }
  ],
  "level": "medium",
  "tags": [
    "CIS Microsoft Azure Foundations"
  ],
  "rule": {
    "path": "az_role_definitions",
    "subPath": null,
    "selectCondition": {
       
    },
    "query": [
      {
        "filter": [
          {
            "conditions": [
              [
                "properties.type",
                "eq",
                "CustomRole"
              ],
              [
                "properties.permissions.actions",
                "match",
                "Microsoft.Authorization/locks/*"
              ]
            ],
            "operator": "and"
          }
        ]
      }
    ],
    "shouldExist": "true",
    "returnObject": {
      "Missing Role": "Custom Resource Lock Administrator",
      "Status": "DoesNotExists"
    },
    "removeIfNotExists": null
  },
  "output": {
    "html": {
      "data": {
        "properties": {
           
        },
        "expandObject": null
      },
      "table": null,
      "decorate": [
         
      ],
      "emphasis": [
         
      ],
      "actions": {
        "objectData": {
          "properties": [
            "*"
          ],
          "expandObject": null,
          "limit": null
        },
        "showGoToButton": false,
        "showModalButton": false,
        "directLink": null
      }
    },
    "text": {
      "data": {
        "properties": {
           
        },
        "expandObject": null
      },
      "status": {
        "keyName": [
           
        ],
        "message": "",
        "defaultMessage": null
      },
      "properties": {
        "resourceName": null,
        "resourceId": null,
        "resourceType": null
      },
      "onlyStatus": false
    }
  },
  "idSuffix": "azure_subscription_missing_custom_lock_role",
  "notes": [
     
  ],
  "categories": [
     
  ]
}