1. Resources
  2. Identity Threats
  3. Azure

Azure Storage SAS Token and Account Key Abuse

Also known as: SAS token abuse, Shared access signature abuse, Storage account key theft, listKeys abuse, User delegation SAS abuse

An identity that can list a storage account's keys, or that finds a leaked SAS token, can read and change the account's data without any Microsoft Entra sign-in and sign new tokens offline.

Platform
Azure
Impact
High
Last updated
Attack difficulty
Low
Detection difficulty
High
Privileges required: Specific rights or roles
Microsoft.Storage/storageAccounts/listkeys/action on the account (Owner, Contributor, Storage Account Contributor), or possession of an account key or an unexpired SAS token.
What the attacker gains
Read, write and delete access to blobs, files, queues and tables in the account, in a form that works from anywhere and survives changes to the identity's roles.
Threat groups
APT28HAFNIUMShinyHuntersTeamPCPAPT29APT33APT38APT42APT5Fox KittenKe3changLAPSUS$NIMBUS MANTICOREScattered Spiderand 2 more in MITRE ATT&CKGroups that MITRE ATT&CK records using T1550.001, T1530, T1078.004.

How it works

Azure Storage accepts three kinds of proof on a data request. A Microsoft Entra token is tied to an identity and its roles. An account key (Shared Key) is one of two long random secrets per account that authorize everything in it. A shared access signature (SAS) is a query string that grants stated permissions on a stated scope until a stated expiry, signed with a key. Storage checks the signature and the fields; it does not ask who is presenting it.

Two properties make keys and SAS tokens useful to an attacker. They are bearer material: whoever holds the string has the access, from any network the account accepts. And they are detached from identity: disabling the user or removing the role that obtained the key does nothing to the key or to tokens signed with it.

There are three SAS types:

  • Account SAS. Signed with an account key. It can span several services at once. Its reach is read from three fields together: signed services (ss, for example b for blob), resource types (srt: service, container, object) and permissions (sp). Selecting the object level does not select one named blob; it covers object-level operations across the account.
  • Service SAS. Signed with an account key, limited to one service. For Blob Storage the signed resource (sr) is a container or a blob. It can reference a stored access policy by its identifier (si), in which case the policy supplies permissions and times and can be changed later.
  • User delegation SAS. Signed with a user delegation key that Storage issues to a Microsoft Entra principal. The key is valid for at most seven days. When the SAS is used, Storage also checks that the signing principal still has the data permissions involved.

The management operation Microsoft.Storage/storageAccounts/listkeys/action returns both account keys. Owner, Contributor and Storage Account Contributor include it. None of those roles is a data role, which is why this path is easy to overlook: a reviewer sees no Storage Blob Data role on the identity and concludes it can't read blobs. One listKeys call later it can read everything, and it can sign as many account or service SAS tokens as it wants on its own machine, with no further request to Azure. Stored account keys behave like any other long-lived secret.

The other entry point needs no Azure role at all: a SAS URL or connection string found in source code, a configuration file, a ticket, a log or a browser history.

Prerequisites

One of the following:

  • A role that includes Microsoft.Storage/storageAccounts/listkeys/action on the account, and an account that still allows Shared Key authorization.
  • A role that includes Microsoft.Storage/storageAccounts/blobServices/generateUserDelegationKey plus blob data permissions, for the user delegation variant.
  • An account key, a connection string or an unexpired SAS token obtained elsewhere.

In all cases the request has to come from a network the account's firewall accepts, and a SAS may carry its own IP and protocol restrictions.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

The steps below are for an authorized assessment or a lab.

1. Find accounts and check whether Shared Key is allowed

az storage account list --query "[].{name:name, rg:resourceGroup}" --output table

az storage account show --name stprodexample --resource-group rg-prod \
  --query "allowSharedKeyAccess"

A result of false means key-signed requests are rejected. An empty result or true means they are accepted.

2. List the account keys

az storage account keys list -g rg-prod -n stprodexample

The command returns key1 and key2. Either one authorizes every data operation.

3. Use the key directly

az storage container list --account-name stprodexample --account-key "<key>" --output table

az storage blob list -c backups --account-name stprodexample --account-key "<key>" --output table

az storage blob download -c backups -n db-2026-11-28.bak -f ./db.bak \
  --account-name stprodexample --account-key "<key>"

4. Sign an account SAS offline

# Read and list on all blob containers and objects, HTTPS only, valid until the expiry
az storage account generate-sas --account-name stprodexample --account-key "<key>" \
  --services b --resource-types sco --permissions rl \
  --expiry 2026-12-31T00:00Z --https-only -o tsv

The CLI computes the signature locally when the key is supplied. The output is the token, without the leading ?. It stays valid until its expiry or until the signing key is rotated, whichever comes first.

A service SAS for one container works the same way:

az storage container generate-sas --account-name stprodexample --account-key "<key>" \
  --name backups --permissions rl --expiry 2026-12-31T00:00Z --https-only -o tsv

5. Variant: user delegation SAS

An identity with a blob data role and no access to the keys can still mint a portable token:

az storage container generate-sas --account-name stprodexample --name backups \
  --permissions rl --expiry 2026-12-05T00:00Z --auth-mode login --as-user

The CLI requests a user delegation key and signs with it. The token can't outlive the key, so the useful lifetime is at most seven days.

6. Use a SAS token

az storage blob list -c backups --account-name stprodexample --sas-token "<sas>" --output table

az storage blob download -c backups -n db-2026-11-28.bak -f ./db.bak \
  --account-name stprodexample --sas-token "<sas>"

A found SAS URL can be read before use. The fields sp (permissions), se (expiry), sr or srt (scope), sip (allowed addresses) and spr (protocol) say what it allows, and si shows that a stored access policy governs it.

Impact

The attacker reads, and with write permission changes or deletes, the data in the account: backups, exports, logs, application files, infrastructure state files that contain more secrets. With an account key the reach is the whole account and every service in it.

The access is durable in a way role-based access is not. A key works until it is regenerated. A SAS signed with it works until expiry or key rotation, and an attacker who held the key for five minutes may have signed tokens that last for years. Removing the user, the role assignment or the session does not end it. The data taken is T1530 in ATT&CK terms: collection from cloud storage.

OPSEC and artifacts

  • Signing locally. After one listKeys call the operator signs every further SAS offline. Azure has no per-token issuance event: the Activity Log shows that keys were listed and can't show how many signatures were made afterwards. The single Microsoft.Storage/storageAccounts/listkeys/action record, with the caller and address, is the only control-plane trace.
  • Asking Azure to sign instead. The management operations listAccountSas and listServiceSas return a SAS without revealing the key. They are logged in the Activity Log like listKeys. Operators who hold the key have no reason to use them.
  • Blending with tools that list keys anyway. The Azure portal, the CLI in its legacy key mode and many deployment tools call listKeys in normal operation, so one more call from an administrator's account does not stand out. The caller, the address and whether that identity has ever touched this account are what distinguish it.
  • User delegation leaves a data-plane record. Requesting the key is a GetUserDelegationKey operation in the blob resource log. One key can sign many SAS tokens.
  • Requests that present a key or a SAS are logged, if resource logs are on. StorageBlobLogs records each request with AuthenticationType, the operation, the status, CallerIpAddress, the user agent and AuthenticationHash. For a key the hash field names key1 or key2 and a hash of the key; for a SAS it adds a hash of the SAS signature, so requests made with the same token can be grouped. The logs do not distinguish between the SAS types. Resource logs are not collected unless a diagnostic setting routes them.
  • No identity in the record. A SAS or key request carries no user. Attribution rests on the caller address, the user agent and the signature hash.
  • Keeping requests few and specific. A ListBlobs followed by a handful of GetBlob requests is quieter than a full download with AzCopy, which produces a burst of reads from one address. Note that GetBlobProperties shows only a metadata read; GetBlob with a success status is the evidence of content access.

Detection

// Blob reads authorized with an account key or a SAS, grouped by caller and signature
StorageBlobLogs
| where AuthenticationType in ("AccountKey", "SAS")
| where OperationName in ("GetBlob", "ListBlobs", "ListContainers")
| summarize Requests = count(), Blobs = dcount(ObjectKey),
            FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated)
    by AccountName, AuthenticationType, AuthenticationHash, CallerIpAddress, UserAgentHeader
| order by Requests desc

A 403 on a SAS request shows a refused attempt, not access. Report what a token could reach separately from what the logs show was read.

Mitigation

  • Disallow Shared Key authorization where clients can use Microsoft Entra ID. Setting allowSharedKeyAccess to false makes the account keys and every account SAS and service SAS useless:

    az storage account update --name stprodexample --resource-group rg-prod \
      --allow-shared-key-access false
    

    Inventory dependent clients first; requests signed with a key fail with 403 afterwards.

  • Treat listKeys as data access. Count the Owner, Contributor and Storage Account Contributor assignments over each account and reduce them. Give applications data roles such as Storage Blob Data Reader instead of keys.

  • Prefer user delegation SAS where a SAS is needed. It is bound to an identity, limited to seven days, and can be revoked for the whole account:

    az storage account revoke-delegation-keys --name stprodexample --resource-group rg-prod
    
  • Keep SAS tokens short and narrow. Short expiry, the fewest permissions, a container or blob instead of the account, HTTPS only, and an IP restriction where the client is known.

  • Use stored access policies for service SAS that must live long, so they can be revoked. When replacing a policy use a new identifier: recreating a deleted policy under the same identifier can bring unexpired tokens back to life.

  • Rotate keys, and rotate both. Rotation ends every SAS signed with that key, but regenerating one key leaves the other and its tokens valid.

    az storage account keys renew -g rg-prod -n stprodexample --key primary
    az storage account keys renew -g rg-prod -n stprodexample --key secondary
    
  • Restrict the network. A storage firewall or private endpoint limits where a stolen key or token can be used from.

  • Collect storage resource logs. Add a diagnostic setting for the blob, file, queue and table services to a central workspace. Without it there is no record of who read what.

  • Keep keys and SAS URLs out of code and tickets. See hardcoded credential risk.

Detection rules for this attack

Log events to collect

FAQ

Why is listing storage account keys a data access permission?

Because the keys authorize every data operation on the account. Contributor and Storage Account Contributor grant no data role through Microsoft Entra ID, but they include Microsoft.Storage/storageAccounts/listkeys/action, and Microsoft's documentation states that with this permission a user can use the account access keys to access all data in the storage account.

Does Azure log the creation of a SAS token?

Not when it is signed locally. A SAS is a signature computed by whoever holds the key, so creating one sends nothing to Azure. The log shows the key being listed, or a user delegation key being requested, and later the requests that present the SAS. It can't count how many tokens were signed in between.

How do you revoke a SAS token?

It depends on how it was signed. A SAS signed with an account key dies when that key is rotated. A service SAS tied to a stored access policy is revoked by changing or deleting the policy. A user delegation SAS is revoked by revoking the account's user delegation keys or removing the signer's role. An ad hoc SAS can't be revoked on its own.

Does disabling shared key access stop SAS tokens?

It stops the two kinds signed with an account key. With AllowSharedKeyAccess set to false, requests with a service SAS or an account SAS are denied. A user delegation SAS is authorized through Microsoft Entra ID and keeps working.

References

Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.