What are the security considerations to take into account when building a machine learning solution, especially if it's built on Azure Machine Learning Service (AML)? This article summerizes the key points that developers can act upon toward building a secure ML solution. For a complete guide, see this Microsoft documentation.
Azure ML is a Platform-as-a-Service (PAAS). As any PAAS, security is a shared responsibility between the customer and Microsoft.
When you deploy an AML Workspace, you not only provision resources required by AML in your own subscription, Microsoft also provisions resources for you in a Microsoft managed subscription. Depending on your security requirements, you can have different levels of control over these resources. The following diagrams from AML documentation depict the resources deployed with an AML Workspace.
Take the following measures to secure your network and endpoints. You don’t have to implement all of them. For example, you can add your Storage account to a virtual network with a Service Endpoint without having to enable Private Link on your AML workspace.
-
Create a Private Link-enabled Workspace to enable communication between your VNet and the AML Workspace.
-
Add Azure Key Vault to the virtual network with a Service Endpoint or a Private Endpoint. Set Key Vault to "Allow trusted Microsoft services to bypass this firewall".
-
Add your Azure storage account to the virtual network with a Service Endpoint or a Private Endpoint.
-
Enable Azure Container Registry with AML in a virtual network and enable subnet delegation in Azure Container Instances.
- AML Operations
- Assign user roles to perform specific AML operations
- Use MSI to pull docker images from ACR to compute clusters so no ACR admin passwords need to be stored (in preview)
- Data
- Use Azure AD authentication whenever possible
- Storage Account/Container/FileSystem level access (Blob Storage or ADLS Gen2)
- Assign least privileges (roles and scopes) for users to access data (data plane)
- Assign least privileges for users to manage data (control plane)
- Folder/File level access (ADLS Gen2 only)
- Always use Azure AD security groups rather than individual users in ACL
- Create different AML Workspaces for dev/test/staging/prod environments and assign privileges accordingly
- Azure DevOps
- Set appropriate project visibility – private, enterprise, or public
- Assign permissions to users or teams at organization, project, and repository levels
- Add users to a role for role based access such as Service Connection, Variable Groups, and Agent Pools
- Avoid having secrets as much as possible. Nothing is more secure than no secrets at all. If you must, store secret variables in Azure Key Vault instead of Azure DevOps. Not only it's more secure, ML pipelines can also be triggered outside Azure DevOps by users who have access to secrets, for example, from their dev machines.
- Run Microsoft Security Code Analysis in Azure DevOps.
- Enable Container Registry Vulnerability Scanning to ensure Docker images are clear of malicious components
- Encryption –
- For production grade encryption, use AML Compute cluster for training, and AKS for inferencing. AML Compute Instance is for dev/test
- Turn on hbi_workspace flag for workspace that contains sensitive data
- You can use CMK (Customer Managed Key) for encryption in the following AML services
- Azure Storage
- Azure Cosmos DB (create your own)
- Azure Container Registry (create your own)
- Azure Container Instance
- Azure Kubernetes Service
- Logging –
- Don’t store sensitive data in environment variables – environment variables are logged, encrypted and stored by Microsoft
- Don’t put sensitive data in run_id
- Don’t put sensitive data in application logs
- Auditing & Compliance
-
Manage data lifecycle with policies (ex. delete data after N days)
- To manage the data in AML owned storage containers, you can set lifecycle actions based on the age of data, ex. N days after modification or creation or access.
-
Enforce security policy on AML
-
Enable Azure Storage diagnostics to audit storage access. This is what a sample log entry looks like.
-
Production deployments of machine learning solutions in enterprises are still fairly new and few, awareness and understanding of ML security risks are low. Full discussion of ML security risks is out of the scope of this doc, however, here are some examples for raising awareness:
- An attacker could poison training and testing data, for example, a chatbot trained on publicly available data can be poisoned with offensive content.
- An attacker can temper the model algorithm, for example, a self-driving car can be tricked to determine a dangerous area is safe to drive when the weakness in its vision model is exploited.
Make sure to analyze the risks and impact in case your ML solution is compromised. Mitigate as much as you can, and have a response plan.
- Enterprise security and governance for Azure Machine Learning: https://docs.microsoft.com/en-us/azure/machine-learning/concept-enterprise-security.
- Security how-tos: https://docs.microsoft.com/en-us/azure/machine-learning/how-to-setup-authentication.
- You can check all the Azure roles a Service Principal has by running
az role assignment list --assignee <app_id_or_object_id> --all --include-inherited.



