06 / 13Data
Azure Storage account security hardening
Harden Azure Storage accounts: no anonymous blob access, no shared keys, short SAS, private endpoints, TLS 1.2, customer-managed keys, soft delete and logging.
- Service
- Storage accounts
- Category
- Data
- Baseline
- 11 controls
- Updated
On this page
An Azure Storage account holds blobs, files, queues and tables behind one public endpoint per service, and it is where most Azure data leaks start. The pattern repeats: a container left open to anonymous reads, an account key or long-lived SAS token pasted into a repository or a ticket, or a public endpoint reachable from anywhere combined with one of the first two. The best-known case is the 2023 exposure reported by Wiz, where a SAS token shared in a public GitHub repository granted full control over an entire Microsoft research storage account instead of read access to one folder. MITRE ATT&CK tracks the technique as T1530 (Data from Cloud Storage). This page maps each setting to the Microsoft cloud security benchmark (MCSB) and to the storage section of the CIS Microsoft Azure Foundations Benchmark.
Baseline controls
Plain CIS numbers refer to the CIS Microsoft Azure Foundations Benchmark v7.0.0; numbers marked Storage refer to the CIS Microsoft Azure Storage Services Benchmark v2.0.0.
| Control | Why | How to check | ID |
|---|---|---|---|
| Anonymous blob access off | Public containers are readable by anyone with the URL | properties.allowBlobPublicAccess is false | MCSB NS-2 / CIS 9.2.5 |
| Shared key access off | Account keys never expire and grant full data control | properties.allowSharedKeyAccess is false | MCSB IM-1 / CIS Azure Storage 2.0.0 16.1.7 |
| User delegation SAS and SAS expiration policy | Limits the lifetime and blast radius of shared links | properties.sasPolicy is set | CIS Storage 16.1.4, 16.1.5 |
| Public network access off or restricted | Removes the internet as an attack path | publicNetworkAccess, networkAcls.defaultAction | MCSB NS-2 / CIS 9.2.1.1, 9.2.1.2, CIS Storage 16.2.1 |
| TLS 1.2 and secure transfer | Blocks plaintext HTTP and legacy TLS | minimumTlsVersion is TLS1_2, supportsHttpsTrafficOnly is true | MCSB DP-3 / CIS 9.2.3, 9.2.4 |
| Cross-tenant replication off | Stops object replication to a storage account in another tenant | allowCrossTenantReplication is false | MCSB PV-2 / CIS Storage 16.12 |
| Customer-managed keys where required | Puts the key lifecycle under your control | encryption.keySource is Microsoft.Keyvault | MCSB DP-5 / CIS Storage 16.1.8 |
| Infrastructure encryption on new sensitive accounts | Second encryption layer, only settable at creation | encryption.requireInfrastructureEncryption | MCSB DP-4 / CIS Storage 16.5 |
| Soft delete and versioning | Recovers from deletion and ransomware-style overwrites | az storage account blob-service-properties show | CIS 9.1.1, CIS Storage 10.5, 16.7 |
| Defender for Storage | Detects anomalous access and malware uploads | Defender for Cloud plan StorageAccounts is Standard | MCSB LT-1 / CIS 8.1.5.1 |
| Resource logs to Log Analytics | Evidence for investigations and shared key migration | Diagnostic setting on each service sub-resource | MCSB LT-3 / CIS Storage 16.8, 16.9, 16.10 |
Anonymous blob access
allowBlobPublicAccess=false at the account level overrides every container-level setting. Containers previously set to Blob or Container access become private immediately. Recent accounts are created with anonymous access disallowed, but older accounts, ARM templates and Terraform modules often still allow it.
Start with an inventory across every subscription you can read, using Azure Resource Graph:
resources
| where type =~ "microsoft.storage/storageaccounts"
| project name, resourceGroup, subscriptionId,
publicBlob = tostring(properties.allowBlobPublicAccess),
sharedKey = tostring(properties.allowSharedKeyAccess),
publicNetwork = tostring(properties.publicNetworkAccess),
defaultAction = tostring(properties.networkAcls.defaultAction),
tls = tostring(properties.minimumTlsVersion),
httpsOnly = tostring(properties.supportsHttpsTrafficOnly),
crossTenant = tostring(properties.allowCrossTenantReplication)
An empty value for allowSharedKeyAccess or allowBlobPublicAccess means the property was never set. Treat empty as non-compliant, because older API versions behave as true when the property is absent.
Before turning anonymous access off, find containers that actually rely on it:
az storage container list --account-name stappdataweu01 --auth-mode login \
--query "[?properties.publicAccess!=null].{name:name, access:properties.publicAccess}" -o table
az storage account update -g rg-app1 -n stappdataweu01 --allow-blob-public-access false
Portal: Storage account > Settings > Configuration > Allow Blob anonymous access.
If something must be publicly readable (a static website, public downloads), put it in a dedicated account fronted by Azure Front Door, and keep every other account private.
Enforce: assign the built-in policy Storage account public access should be disallowed with the Deny effect at a management group. The rollout method (audit first, then deny, with exemptions) is on the Azure Policy page.
Shared key access and SAS tokens
An account key is a password with full control over all data in the account. It never expires, and anyone with Microsoft.Storage/storageAccounts/listkeys/action (which Contributor includes) can read it. Account SAS and service SAS tokens are signed with that key, so they inherit the problem: you cannot list them, and the only way to revoke one is to rotate the key that signed it.
The target is Microsoft Entra authorization only.
Migrate clients to Entra ID
-
Grant data roles to the identities that need them, preferably managed identities (see Entra ID and Azure RBAC):
Storage Blob Data Reader,Storage Blob Data Contributor,Storage Queue Data Message Senderand so on, at container or account scope. -
Find clients still using shared key. With blob resource logs in Log Analytics:
KQLStorageBlobLogs | where TimeGenerated > ago(14d) | where AuthenticationType in ("AccountKey", "SAS") | summarize Requests = count() by AccountName, AuthenticationType, CallerIpAddress, UserAgentHeader | order by Requests desc -
Move those clients to Entra tokens, then disable shared key:
bashaz storage account update -g rg-app1 -n stappdataweu01 --allow-shared-key-access false -
Rotate both keys afterwards, so any copy that leaked earlier is useless even if someone re-enables shared key later:
bashaz storage account keys renew -g rg-app1 -n stappdataweu01 --key primary az storage account keys renew -g rg-app1 -n stappdataweu01 --key secondary
Some services still need shared key (certain Azure Files SMB scenarios, a few older integrations). Test in a non-production account first; the change breaks every client that authenticates with a key or with an account or service SAS.
User delegation SAS
When a third party genuinely needs a SAS, issue a user delegation SAS. It is signed with a key obtained through Entra authentication, it is valid for at most seven days, and it stops working when the user delegation key is revoked or the issuing identity loses its role.
az storage blob generate-sas \
--account-name stappdataweu01 --container-name exports --name report.csv \
--permissions r --expiry 2026-11-21T18:00Z \
--auth-mode login --as-user --https-only
Scope it to one blob or one container, read-only, with the shortest expiry that works.
SAS expiration policy and key reminders
If shared key must stay on for a while, set a SAS expiration policy and a key expiration reminder:
az storage account update -g rg-app1 -n stappdataweu01 \
--sas-expiration-period 1.00:00:00 \
--key-expiration-period-in-days 90
The SAS expiration policy logs SAS tokens issued with a longer validity than one day, and with the Block action it rejects them.
Enforce: Storage accounts should prevent shared key access with Deny. The policy has an excludedManagedByResourceProviders parameter for accounts created by Azure Databricks, Azure Red Hat OpenShift and Microsoft Purview, which you cannot change yourself.
az policy assignment create \
--name deny-storage-shared-key \
--display-name "Storage accounts should prevent shared key access" \
--policy 8c6a50c6-9ffd-4ae7-986f-5fa6111f9a54 \
--scope /providers/Microsoft.Management/managementGroups/mg-landing-zones \
--params '{"effect":{"value":"Deny"}}'
Network access
Choose one posture per account, from strongest to weakest:
- Private endpoint only:
publicNetworkAccess=Disabled, access through a private endpoint in your VNet. - Selected networks: public endpoint on,
defaultAction=Deny, with specific subnets (service endpoints), resource instance rules or IP ranges allowed. - All networks: only for accounts that are public by design.
A private endpoint for the blob service:
SA_ID=$(az storage account show -g rg-app1 -n stappdataweu01 --query id -o tsv)
az network private-endpoint create \
--name pe-stappdataweu01-blob --resource-group rg-app1 \
--vnet-name vnet-app1 --subnet snet-private-endpoints \
--private-connection-resource-id "$SA_ID" \
--group-id blob --connection-name stappdataweu01-blob
az network private-endpoint dns-zone-group create \
--resource-group rg-app1 --endpoint-name pe-stappdataweu01-blob \
--name default --zone-name blob \
--private-dns-zone "/subscriptions/<connectivity-sub>/resourceGroups/rg-connectivity/providers/Microsoft.Network/privateDnsZones/privatelink.blob.core.windows.net"
az storage account update -g rg-app1 -n stappdataweu01 --public-network-access Disabled
Each sub-resource (blob, file, queue, table, dfs, web) needs its own private endpoint and private DNS zone. In hub-and-spoke designs, keep the zones centrally in the connectivity subscription and link them to the hub, as described on the Virtual Network page.
With selected networks, keep --bypass AzureServices only if a trusted Microsoft service needs the account (Azure Backup, Azure Monitor, Defender for Storage malware scanning). Prefer resource instance rules that allow one specific resource, such as a single Synapse workspace, over every trusted service.
az storage account update -g rg-app1 -n stappdataweu01 \
--public-network-access Enabled --default-action Deny --bypass None
az storage account network-rule add -g rg-app1 --account-name stappdataweu01 \
--vnet-name vnet-app1 --subnet snet-app
Portal: Storage account > Security + networking > Networking.
Enforce: Storage accounts should disable public network access (Deny) for private-only landing zones, or Storage accounts should restrict network access (Audit/Deny) where selected networks are allowed. Storage accounts should use private link audits the private endpoint side.
Encryption in transit
Set the minimum TLS version to 1.2 and require secure transfer (HTTPS only). Older accounts often still carry TLS1_0 in the property even though the service side has moved on, and scanners flag it.
az storage account update -g rg-app1 -n stappdataweu01 \
--min-tls-version TLS1_2 --https-only true
Azure Files over SMB also needs SMB 3.x with encryption. In File shares > Security, choose the maximum security profile, or set it from the CLI:
az storage account file-service-properties update -g rg-app1 -n stappdataweu01 \
--versions "SMB3.1.1" --channel-encryption "AES-256-GCM" \
--require-smb-encryption-in-transit true
Enforce: Storage accounts should have the specified minimum TLS version (parameter minimumTlsVersion = TLS1_2, effect Deny) and Secure transfer to storage accounts should be enabled.
Cross-tenant replication and copy scope
Object replication can copy blobs to an account in another Entra tenant. An attacker with Contributor on your account can use it to exfiltrate data continuously without touching the data plane from a suspicious IP. Turn it off, and restrict copy operations to accounts in the same tenant or behind private links:
az storage account update -g rg-app1 -n stappdataweu01 \
--allow-cross-tenant-replication false \
--allowed-copy-scope AAD
Enforce: Storage accounts should prevent cross tenant object replication.
Encryption at rest and customer-managed keys
All data is encrypted at rest with Microsoft-managed keys by default (AES-256). Add the following where your policy requires it:
-
Customer-managed keys (CMK) in Key Vault, when you must control key lifecycle and be able to revoke access to the data. Use a user-assigned managed identity for the account, reference the key without a version so rotation is picked up automatically, and enable purge protection on the vault. Losing the key means losing the data; the Key Vault page covers purge protection and rotation.
bashaz storage account update -g rg-app1 -n stappdataweu01 \ --identity-type UserAssigned \ --user-identity-id "$UAMI_ID" \ --key-vault-user-identity-id "$UAMI_ID" \ --encryption-key-source Microsoft.Keyvault \ --encryption-key-vault https://kv-app1-prod-weu.vault.azure.net \ --encryption-key-name cmk-storage -
Infrastructure encryption (
--require-infrastructure-encryptiononaz storage account create) for a second encryption layer at the infrastructure level. It can only be set when the account is created, so put it in your templates for sensitive data.
Enforce: Storage accounts should use customer-managed key for encryption and Storage accounts should have infrastructure encryption, usually in Audit because not every account needs them.
Soft delete, versioning and immutability
Malicious deletion and overwrite hit storage too. Turn on recovery features before you need them:
az storage account blob-service-properties update \
-g rg-app1 --account-name stappdataweu01 \
--enable-delete-retention true --delete-retention-days 14 \
--enable-container-delete-retention true --container-delete-retention-days 14 \
--enable-versioning true \
--enable-change-feed true
Enable share soft delete for Azure Files as well (az storage account file-service-properties update --enable-delete-retention true --delete-retention-days 14).
Immutability and locks
For backups, audit evidence and log archives, add an immutability policy (time-based retention, locked once validated) on the container, or version-level immutability on the account, so that even an Owner cannot delete data before the period ends. Add a CanNotDelete resource lock on the account to protect against deletion of the account itself:
az lock create --name lock-stappdataweu01 --lock-type CanNotDelete \
--resource-group rg-app1 --resource stappdataweu01 \
--resource-type Microsoft.Storage/storageAccounts
Enforce: the built-in Configure soft delete for blobs and containers on Storage Accounts policy deploys soft delete on accounts that lack it.
Microsoft Defender for Storage
Defender for Storage detects unusual access patterns, access from Tor exit nodes and known malicious IPs, suspicious SAS usage and mass deletion, and can scan uploaded blobs for malware on upload. Enable it at subscription level and adjust per account:
az security pricing create -n StorageAccounts --tier Standard --subplan DefenderForStorageV2
Plan settings, malware scanning caps and alert routing are covered on the Defender for Cloud page.
Enforce: Configure Microsoft Defender for Storage to be enabled (DeployIfNotExists) at the management group, and Microsoft Defender for Storage should be enabled to audit.
Logging and detection
Diagnostic settings for storage are configured per service sub-resource (blobServices/default, fileServices/default, queueServices/default, tableServices/default), not on the account. Send the audit category group (or StorageRead, StorageWrite and StorageDelete) to Log Analytics; the data lands in StorageBlobLogs, StorageFileLogs, StorageQueueLogs and StorageTableLogs. Scale this with policy as described on the Azure Monitor page.
SA_ID=$(az storage account show -g rg-app1 -n stappdataweu01 --query id -o tsv)
az monitor diagnostic-settings create --name to-law \
--resource "$SA_ID/blobServices/default" \
--workspace "$LAW_ID" \
--logs '[{"categoryGroup":"audit","enabled":true}]'
Hunt for anonymous reads and bulk downloads:
StorageBlobLogs
| where TimeGenerated > ago(1d)
| where OperationName == "GetBlob"
| summarize Reads = count(), Bytes = sum(ResponseBodySize), Blobs = dcount(Uri)
by AccountName, AuthenticationType, CallerIpAddress, bin(TimeGenerated, 1h)
| where AuthenticationType == "Anonymous" or Blobs > 500
Control plane events come from the activity log. Alert on key listing and on configuration changes that weaken the baseline:
AzureActivity
| where OperationNameValue in~ (
"MICROSOFT.STORAGE/STORAGEACCOUNTS/LISTKEYS/ACTION",
"MICROSOFT.STORAGE/STORAGEACCOUNTS/REGENERATEKEY/ACTION",
"MICROSOFT.STORAGE/STORAGEACCOUNTS/WRITE")
| where ActivityStatusValue == "Success"
| project TimeGenerated, Caller, CallerIpAddress, OperationNameValue, _ResourceId
Defender for Storage alerts (for example access from a Tor exit node, unusual SAS usage, malware uploaded) land in Defender for Cloud and can be streamed to Microsoft Sentinel.
Common mistakes
- Disabling anonymous access on the account but leaving the IaC module default at
allowBlobPublicAccess: true, so the next deployment reopens it. - Storing account keys in app settings or pipelines "temporarily", then never rotating them after the migration to Entra ID, so an old leak stays valid.
- Issuing account SAS tokens with all permissions and a multi-year expiry for a partner integration. You cannot revoke one without rotating the key and breaking every other client.
- Creating a private endpoint but leaving
publicNetworkAccessatEnabledwithdefaultAction=Allow, so the public path still works. - Keeping
--bypass AzureServiceseverywhere "just in case", which lets any trusted Microsoft service instance in any tenant attempt access instead of one named resource. - Using customer-managed keys in a vault without purge protection: a deleted and purged key makes the account's data permanently unreadable.
- Configuring diagnostic settings on the account resource only, which collects metrics but no blob, file, queue or table logs.
References
- Security recommendations for Blob storage (Microsoft Learn)
- Azure security baseline for Storage (Microsoft cloud security benchmark)
- Prevent Shared Key authorization for an Azure Storage account (Microsoft Learn)
- Remediate anonymous read access to blob data (Microsoft Learn)
- Create a user delegation SAS (Azure Storage REST reference)
- Configure a SAS expiration policy (Microsoft Learn)
- Use private endpoints for Azure Storage (Microsoft Learn)
- Overview of immutable storage for blob data (Microsoft Learn)
- Introduction to Microsoft Defender for Storage (Microsoft Learn)
- 38TB of data accidentally exposed by Microsoft AI researchers (Wiz Research)
- Microsoft mitigated exposure of internal information in a storage account due to overly-permissive SAS token (MSRC)
- CIS Microsoft Azure Foundations Benchmark (CIS)
Filed under storage, data-protection, network, cis-benchmark
Written by
Florian Amette, Cloud Security Engineer & EditorSecurity engineer writing practical hardening pages for Microsoft Azure tenants and subscriptions, aligned with the CIS Microsoft Azure Foundations Benchmark.