Skip to content

LearnCloud

Azure Storage SAS token and account review

Brief

A shared access signature is a bearer credential in a URL, and an account or service SAS stays valid until it expires or the key that signed it is rotated. The review finds where tokens are kept and how long they last without ever printing one, then reads the account settings that decide whether keys, anonymous access and deletion are dangerous at all.

Track
Cloud
Stage
Access
Reviewed
On this page
  1. Check first
  2. Azure
  3. The defender sees
  4. Done when
  5. Not covered
  6. Tools
  7. Related research
  8. Where this page fits
  9. Reviewed

All commands

Situation
Reader on the subscriptions in scope, Key Vault Reader on the vaults that hold storage secrets, and read access to the repositories and pipeline definitions the client names. Everything here is a read: we print token parameters and secret names, never a signature, key or secret value, and we never delete a blob to prove that deletion would stick. Only the storage accounts and repositories the scope letter names are reviewed.
Goal
A table per storage account: where its SAS tokens are kept and their expiry and permissions, shared key and SAS policy settings, key age, anonymous containers, and the recovery settings that decide whether deleted data comes back.
Outputs
Representative examples on placeholder hosts, trimmed to the lines that matter. Not captured from a public fixture yet.

Check first

  • The storage accounts in scope, by subscription and resource group.
  • Which repositories, pipeline definitions and app settings the client will let us read.
  • Whether the accounts send resource logs (StorageBlobLogs) to a workspace the client can query.
  • Which containers the client means to be public, so a deliberate one is not reported.
  • Which containers hold backups or records that must survive a deletion.

Steps

Azure

Where are SAS tokens kept, and when do they expire?

git grep -lE '[?&]sig=[A-Za-z0-9%+/=]+' -- . ':!*.lock'
git grep -hoE '[?&](sv|ss|srt|sp|se)=[^&[:space:]"]+' -- deploy/ | sort | uniq -c
az keyvault secret list --vault-name prod-kv \
  --query "[?contains(name,'sas')].{name:name,expires:attributes.expires}" -o table

Expected output

deploy/exports-job.yaml   # <- a signed URL committed to the repository
src/reports/config.json
      1 &se=2031-01-01T00%3A00%3A00Z   # <- valid for another four years
      1 &sp=racwdl
      1 &srt=sco
      1 &ss=bfqt
      1 ?sv=2022-11-02
Name             Expires
---------------  ---------
exports-sas-url

The first command prints file names only. The second prints only the parameters that describe a token, never sig, so the signature stays out of our terminal and notes. ss and srt mark an account SAS: here every service, every resource type, and read, add, create, write, delete and list. An account or service SAS cannot be revoked on its own; only rotating the key that signed it, or removing a stored access policy, ends it early. The Key Vault listing returns names and attributes, never values, and an empty expiry means nobody planned a rotation.

Negative result. No signed URLs in repositories, tokens issued at run time as user delegation SAS lasting hours, and an expiry on every stored token.

Fix. Have the application issue a user delegation SAS at the moment of use with the narrowest permissions and a short expiry. Rotate the key that signed any token found, which ends every SAS it signed, and remove the URL from history through the client's usual leaked-secret process.

Which account settings still allow shared keys and long SAS?

az storage account list --query "[].{name:name,sharedKey:allowSharedKeyAccess,sasMax:sasPolicy.sasExpirationPeriod,sasAction:sasPolicy.expirationAction,keyDays:keyPolicy.keyExpirationPeriodInDays}" -o table
az storage account show --name prodexports --query keyCreationTime

Expected output

Name          SharedKey    SasMax      SasAction    KeyDays
------------  -----------  ----------  -----------  ---------
prodexports                                                     # <- unset means shared key is allowed, with no SAS or key policy
prodlogs      False
appassets     True         1.00:00:00  Log          90
{
  "key1": "2023-02-14T09:21:07.000000+00:00",   # <- the key behind every account SAS has not changed in over three years
  "key2": "2023-02-14T09:21:07.000000+00:00"
}

An unset allowSharedKeyAccess means the account accepts its keys and every account or service SAS they sign. Setting it to false denies both kinds of SAS and keeps user delegation SAS and Entra ID working. A SAS expiration policy sets the longest token anyone should create; its default action, Log, only records tokens over the limit, while Block refuses them. keyCreationTime shows when each key last changed.

Negative result. False on every account that does not need keys, and where keys must stay, a SAS policy with Block, a key expiration policy, and keys rotated within it.

Fix. Check StorageBlobLogs for requests made with keys or SAS, move those callers to Entra ID, then disallow shared key access. Where that cannot happen yet, set both policies and rotate keys on a schedule, one key at a time.

Which containers allow anonymous read?

az storage account list --query "[].[name,allowBlobPublicAccess]" -o tsv
az storage container-rm list --storage-account prodexports --resource-group prod-rg \
  --query "[].{name:name,access:publicAccess}" -o table

Expected output

prodexports	True
prodlogs	False
Name      Access
--------  ---------
exports   Container   # <- anyone can list and read every blob in this container
images    Blob
backups   None

Anonymous read needs two settings: the account must allow it, and the container must set a level. Container lets anyone list and read, Blob lets anyone read a blob whose name they know. The default for a new account disallows anonymous access, so a True is usually an older account or a deliberate choice worth asking about. The container-rm commands read through the management plane, so they need no key.

Negative result. False on the account, or True only where every public container is on the client's intended list.

Fix. Set allowBlobPublicAccess to false on the account, which overrides every container, after checking the logs for anonymous reads. Serve public files from a separate account or a CDN meant for them.

Would deleted or overwritten data come back?

az storage account blob-service-properties show --account-name prodexports --resource-group prod-rg \
  --query "{softDelete:deleteRetentionPolicy.enabled,days:deleteRetentionPolicy.days,containerSoftDelete:containerDeleteRetentionPolicy.enabled,versioning:isVersioningEnabled}"
az storage container-rm show --name backups --storage-account prodexports --resource-group prod-rg \
  --query "{policy:hasImmutabilityPolicy,legalHold:hasLegalHold}"

Expected output

{
  "softDelete": false,   # <- a deleted blob is gone at once
  "days": null,
  "containerSoftDelete": false,
  "versioning": null
}
{
  "policy": false,   # <- nothing stops a key holder deleting the backups
  "legalHold": false
}

A token with d in its permissions, or an account key, can delete data, and that is the step before ransom. Soft delete and versioning give the client a window to restore; a locked time-based retention policy stops deletion even by an account owner.

Negative result. Blob and container soft delete on with the retention the recovery plan names, versioning on, and a locked retention policy on every backup container.

Fix. Turn on blob soft delete, container soft delete and versioning. Put backups in a container with a time-based retention policy, test it unlocked, then lock it, and add a CanNotDelete lock to the account.

The defender sees

The Azure activity log records writes, not reads, so the management reads above leave little there; the Key Vault listing appears as a SecretList operation in the vault's audit log where diagnostic settings are on, and the repository searches are local. The signal that matters is data plane: in StorageBlobLogs the AuthenticationType column tells key, SAS, Entra ID and anonymous requests apart, so a client can see who still uses the tokens we found before revoking them. If the accounts send no resource logs, the client cannot tell a leaked SAS being used from normal traffic, and that goes in the report beside the cloud first hour logging checks.

Done when

Every signed URL found is recorded by file and parameters without its signature, each account has its shared key, SAS policy, key age and anonymous access settings recorded, and soft delete, versioning and immutability are known for every container holding backups or records.

Not covered

Checking a container from outside with no credentials (see public bucket checks), Azure Files and queue specifics, private endpoints and firewall rules, and data inside the blobs; the outputs shown are representative examples on placeholder accounts, not captured runs.