Skip to content

Lesson 9 of 14 · 16m

Azure Storage: The Account Key Is a Master Key and SAS Is a URL That Leaks

key1/key2 bypass the RBAC data-plane split entirely, and Microsoft's own 38TB SAS leak is the case study.

The two master keys

Every Azure storage account is created with two symmetric keys, key1 and key2. Each grants every data operation on every blob container, queue, table, and file share in the account — master keys, no per-container scoping, used via the Authorization: SharedKey account:signature scheme. Two keys exist for rotation overlap, nothing more.

Now the RBAC trap, weaponized: Microsoft.Storage/storageAccounts/listKeys/action is a control-plane action included in Contributor. Anyone with Contributor on the account pulls the master keys and owns the data plane completely — the dataActions split never applies to key-based auth. "They can't read blobs, they only have Contributor" is a true sentence that doesn't mean what you think it means.

SAS: a bearer token in a query string

Shared Access Signatures sign a URL with the account key — or Entra credentials, for user delegation SAS. The query parameters are the whole policy: sp= permissions (r, w, l, d, a, c, u, p), st=/se= start and end time, sv= signature version, ss=/srt= service and resource scope, sip= allowed IP range, spr= required protocol. Three tiers: account SAS covers the entire account across services; service SAS covers one container/blob/queue/table; user delegation SAS is signed by a delegation key minted from the caller's Entra identity (Microsoft.Storage/storageAccounts/blobServices/generateUserDelegationKey), auditable per user and revocable without rotating the account key — which makes it the right default. A stored access policy on the container is the other revocation handle: SAS minted under it die when you delete the policy.

The failure modes all live in scope and lifetime: account-scoped SAS, se set a decade out, sp=rwld when sp=r sufficed — and the physical fact that the SAS travels in a URL. URLs land in access logs, proxy logs, browser history, Referer headers, support tickets, and README files committed to public repos. The least-protected string in your stack carries the token.

The mint commands show where scope slips: az storage blob generate-sas --account-name x --container-name c --name b --permissions r --expiry <iso> --auth-mode login --as-user produces a user delegation SAS; drop --as-user/--auth-mode login and you get an account-key-signed service SAS instead. sip= and spr=https are worth typing — an IP-scoped, HTTPS-only SAS still leaks, but it leaks to fewer places.

The evidence is Microsoft's own repo

September 18, 2023: Wiz disclosed that Microsoft's AI research GitHub repos — robust-models-transfer among them — linked to a storage account behind an account-level SAS granting read, write, and list, effectively without expiry. The URL sat in public documentation. Result: 38 TB of internal Microsoft data exposed, including private keys and tens of thousands of Teams messages from 359 employees. Microsoft's own researchers shipped the mistake the SAS design invites. The fix was scoping the link and rotating the keys — the lesson is that account SAS is the footgun, not the edge case. And SAS never appears in RBAC assignment lists: auditing who can mint SAS means auditing listKeys and generateUserDelegationKey holders, not looking for the tokens themselves.

The switches that close it

  • allowBlobPublicAccess: false at the account — container anonymous access levels (Private / Blob anonymous reads / Container anonymous reads plus listing) stop being honored regardless of how they're set.
  • allowSharedKeyAccess: false — kills every Shared Key-authorized request: account-key auth plus account and service SAS signed with the account key. User delegation SAS survives — it's Entra-authorized, not key-authorized — which is exactly why it's the right default for sharing. The big hammer: enable it and you'll immediately discover which legacy callers still use keys, which is also the point.
  • Firewall: defaultAction: Deny plus selected VNets/IPs or private endpoints. Audit the AzureServices "trusted Azure services" bypass — it reopens a path through the firewall that auditors routinely miss.
  • For sharing: user delegation SAS, minimal sp, se measured in days, sip/spr where defensible — or a stored access policy so the issued SAS stays revocable.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.