More Info:
Identifies roles held by the managed identities of container workloads such as AKS clusters, container instances and container apps. Anyone who can schedule a container, or break out of one, inherits the identity and everything the role permits - and a cluster identity is usually shared by every workload on it. Give each workload its own identity and scope its role to the resources that workload owns.Risk Level
HighAddress
SecurityCompliance Standards
- Cloudanix Best Practice
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To remediate the misconfiguration of roles assumable by container services in Azure using the Azure console, follow these steps:
- Sign in to the Azure portal (https://portal.azure.com) using your Azure account credentials.
- In the Azure portal, navigate to the Azure Container Instances service by searching for “Container Instances” in the search bar at the top.
- Click on the “Container Instances” service from the search results to open the Azure Container Instances page.
- On the left-hand side menu, click on “Access control (IAM)” to manage the access control settings for the Azure Container Instances service.
- In the “Access control (IAM)” page, you will see a list of roles assigned to different users and groups. Look for any roles that are misconfigured or should not be assumable by container services.
- To remediate the misconfiguration, click on the role that you want to modify or remove from the container service.
- In the role details page, you will see a list of assigned users or groups. To remove a user or group from the role, select the checkbox next to their name and click on the “Remove” button at the top.
- If you want to modify the role permissions, click on the “Add role assignment” button at the top of the page.
- In the “Add role assignment” panel, select the appropriate role from the “Role” dropdown menu. You can choose from built-in roles like “Contributor” or “Reader”, or create a custom role with specific permissions.
- Specify the user or group that should be assigned the role by selecting them from the “Assign access to” dropdown menu.
- Click on the “Save” button to apply the changes and remediate the misconfiguration.
- Repeat steps 6 to 11 for any other misconfigured roles that need to be remediated.
Using CLI
Using CLI
To remediate the misconfiguration of roles assumable by container services in Azure, you can follow these step-by-step instructions using Azure CLI:
- Install Azure CLI: If you haven’t already, install the Azure CLI on your local machine by following the instructions provided by Microsoft.
-
Login to Azure: Open your command prompt or terminal and login to your Azure account using the command:
-
Select the Azure subscription: If you have multiple subscriptions, select the appropriate subscription using the command:
-
List container services: Run the following command to list all the container services in your Azure subscription:
-
Get the AKS cluster resource group: Identify the resource group associated with the AKS cluster you want to remediate. Run the following command, replacing
<resource_group_name>with the actual name: -
List role assignments: Now, list the current role assignments for the AKS cluster by running the following command, replacing
<resource_group_name>with the actual name: -
Remove unwanted role assignments: Identify the role assignments that are not required or should not be assumable by container services. Use the following command to remove each unwanted role assignment, replacing
<assignment_id>with the actual ID: - Verify the remediation: Run the command from Step 6 again to ensure that the unwanted role assignments have been successfully removed.
Using Python
Using Python
To remediate the misconfiguration of roles assumable by container services in Azure IAM, you can follow these steps using Python:
-
Install the required Python libraries:
-
Import the necessary modules:
-
Authenticate to Azure using the default credentials:
-
Create an instance of the ContainerInstanceManagementClient:
-
Get the list of container groups:
-
Iterate through the container groups and check their assigned roles:
-
Create an instance of the AuthorizationManagementClient:
-
Get the list of role definitions:
-
Iterate through the role definitions and assign the necessary roles:
subscription_id: Azure subscription IDresource_group_name: Resource group name where the container groups are locatedscope: The scope of the role assignment (e.g.,/subscriptions/{subscription_id}/resourceGroups/{resource_group_name})service_principal_id: The ID of the service principal associated with the container service
Using Terraform
Using Terraform
azure-securityandidentity-iam-role) in Terraform, you must either delete that azurerm_role_assignment resource or change its principal_id and scope to match the workload-specific identity and resource as in azurerm_role_assignment.WORKLOAD_ROLE; otherwise the misconfiguration will persist.This change does not force replacement of the underlying AKS/ACI/container app resources, but it will revoke the old permissions as soon as the broad azurerm_role_assignment is removed, so ensure the new, scoped assignment is applied first to avoid outages.Verification: terraform plan should show the existing broad azurerm_role_assignment scheduled for destruction (or its principal_id/scope arguments changing), and a new, narrower azurerm_role_assignment created that targets the workload-specific managed identity at the least-privilege scope.
