Join our Newsletter — 33% off our NHI Course
Home› Guides› Azure SAS Tokens Security Guide: User Delegation SAS,…
Guide Non-Human Identity (NHI)

Azure SAS Tokens Security Guide: User Delegation SAS, Expiry and Policies

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 26 October 2026 13 min read
On this page

An Azure Storage shared access signature (SAS) is a bearer credential inside a URL: anyone who holds the link gets its permissions until it expires, and Azure keeps no record that it was ever created. SAS tokens are generated client-side, signed with either a storage account key or a Microsoft Entra user delegation key, and pasted into scripts, pipelines, partner emails and public repositories. This guide explains the three SAS types, who can mint them, how to cap their lifetime with SAS expiration policies, how to revoke them, how to detect their use in Azure Monitor logs, and how to move to user delegation SAS or no SAS at all. It is for cloud platform, storage and security teams responsible for Azure Blob Storage, Data Lake Storage, Azure Files, Queue and Table Storage.

Key takeaways

  • Prefer user delegation SAS. Microsoft recommends it whenever a SAS is needed: it is signed with an Entra-issued key, lasts at most seven days, and its creator's role assignments are checked on every request.
  • Account and service SAS inherit the account key. They are signed with Shared Key, cannot be listed or audited at creation, and an account SAS can only be revoked by rotating the key that signed it.
  • Set a SAS expiration policy and move it to Block. The policy caps the validity interval; the default Log action only records violations in the SasExpiryStatus log field.
  • Remove the key, not just the tokens. Setting AllowSharedKeyAccess to false makes every service and account SAS stop working, which is the only control that prevents new key-signed SAS outright.
  • Usage is visible, issuance is not. StorageBlobLogs records AuthenticationType "SAS" and a SHA-256 hash of the signature, so you can only find tokens that are used, and only on accounts with diagnostic logging enabled.

How identity and access work in Azure SAS tokens

A SAS token is a set of query parameters appended to a storage resource URI. The service rebuilds a string from those parameters, checks the HMAC-SHA256 signature in sig against the key that signed it, and authorises the request if it matches, otherwise returning 403. Microsoft's documentation is explicit that the SAS token "is not tracked by Azure Storage in any way" and that you can create an unlimited number of them. There is no API that lists how many exist.

SAS typeSigned withScopeMaximum lifetimeRevocation
User delegation SASUser delegation key obtained with Microsoft Entra credentialsOne service: Blob (including Data Lake Storage), Queue, Table or Azure FilesSeven days (bounded by the delegation key)Revoke user delegation keys, or remove the creator's role assignments
Service SASStorage account key (Shared Key)Resources in one serviceNo platform limit unless a SAS expiration policy or stored access policy appliesStored access policy (if used), otherwise rotate the account key
Account SASStorage account key (Shared Key)One or more services, including service-level operationsNo platform limit unless a SAS expiration policy appliesRotate the account key only

The parameters that matter for security

  • sp (permissions): letters such as r read, w write, d delete, l list. A user delegation SAS grants only the intersection of sp and the creator's RBAC or POSIX ACL permissions.
  • st and se (start and expiry): the validity window. Microsoft advises a start time at least 15 minutes in the past, or none, to avoid clock skew failures.
  • sip and spr: an allowed client IP address or range, and the protocol. Set spr=https; HTTP-only is not allowed, but the default permits both.
  • skoid, sktid, skt, ske: on a user delegation SAS, the object ID and tenant of the principal that requested the key, and the key's own start and expiry.
  • scid (correlation ID): optional on a Blob user delegation SAS from service version 2020-02-10; a GUID that links Azure Storage logs to the issuing service's own log of who received the token.
  • sduoid (user-bound SAS): in service versions from 2025-07-05, a user delegation SAS can name the Entra object ID of the intended end user, who must then present a bearer token with a matching oid claim. Storage account properties can log or block user delegation SAS that are not user-bound. Check regional availability and SDK support before relying on it.

A SAS can be ad hoc, with constraints in the URI, or a service SAS tied to a stored access policy on a container, file share, queue or table. Stored access policies are not supported for account SAS or user delegation SAS. Each resource holds at most five, and creating or changing one can take up to 30 seconds to take effect.

Admin roles and privileged access

Microsoft warns that SAS generation cannot be audited: anyone with the account key, or a role that allows them to sign a SAS, can mint one without the account owner knowing. Controlling who can sign is therefore the main preventive control.

CapabilityAzure RBAC actionBuilt-in roles that include it (examples)Risk
Read account keys (mint any service or account SAS)Microsoft.Storage/storageAccounts/listkeys/actionOwner, Contributor, Storage Account Key Operator Service RoleFull data-plane control of the account, offline and untraceable
Regenerate account keysMicrosoft.Storage/storageAccounts/regeneratekey/actionOwner, Contributor, Storage Account Key Operator Service RoleRevokes all key-signed SAS; outage if applications use the key
Request a user delegation keyMicrosoft.Storage/storageAccounts/blobServices/generateUserDelegationKeyStorage Blob Data Contributor, Storage Blob DelegatorBounded: the SAS cannot exceed the creator's own data permissions or seven days
Change SAS and key policies, AllowSharedKeyAccessMicrosoft.Storage/storageAccounts/writeOwner, Contributor, Storage Account ContributorCan re-enable Shared Key or remove the expiration policy
  • Treat key readers as privileged: the generic Contributor role at subscription or resource group scope includes listkeys. Engineers who only need data access should hold Storage Blob Data roles, not Contributor. See the Azure RBAC and Service Principals Guide.
  • Use just-in-time elevation: put Owner, Contributor and Storage Account Key Operator assignments on storage accounts behind Privileged Identity Management or an equivalent approval process.
  • Separate delegation from data: a SAS-issuing service can hold a role scoped to one container, so every SAS it signs is limited to that container whatever sp says.

Integrations, API tokens and service accounts

Most SAS tokens exist because an application, pipeline or partner needed storage access without an Entra identity. Choose the narrowest pattern that works.

ScenarioRecommended patternAvoid
Azure-hosted workload reading or writing storageManaged identity with a Storage Blob Data role; no SAS at allConnection strings with account keys in app settings
Browser or mobile client uploading its own filesBack-end service issues a user delegation SAS for one blob, write only, minutes of validity, HTTPS onlyLong-lived container SAS embedded in the client
Partner or customer downloadUser delegation SAS for the specific blobs, read only, from a dedicated sharing accountAccount SAS on the production account
Recurring partner integration that cannot use EntraService SAS bound to a stored access policy, so it can be revoked without rotating keysAd hoc service SAS with a far-future expiry
Cross-account copy or blob-to-file copyShort-lived user delegation or service SAS on the source, created for the jobReusing a standing SAS across jobs
Azure File SyncLeave the platform-managed SAS in place; keep the expiration upper limit at three days or moreExpiry limits below three days, which break sync

Where account keys must still exist, Microsoft recommends storing them in Azure Key Vault and rotating them, using one key in all applications so the second can be rotated in. Rotating a key revokes every service and account SAS signed with it, which is both the emergency response and the reason rotation breaks undocumented integrations. See the Azure Managed Identities Security Guide and the Secrets Rotation Runbook Template.

Revocation options

  1. User delegation SAS: call Revoke User Delegation Keys (az storage account revoke-delegation-keys). All user delegation SAS on the account become invalid; issuers then request new keys. Alternatively remove the creator's role assignment. Both are cached, so allow some minutes.
  2. Service SAS with a stored access policy: delete the policy, rename its signed identifier, or set its expiry in the past with Set Container ACL (or the queue, table or share equivalent).
  3. Ad hoc service SAS or account SAS: regenerate the account key that signed it. Rotate key2 first if applications use key1, then key1, so you know which key you are cutting.
  4. Any SAS, as a stop-gap: set AllowSharedKeyAccess to false (stops all key-signed SAS), or restrict the account's network access while you rotate.

Logging and detection

Enable a diagnostic setting for each storage service (blob, file, queue, table) that sends resource logs to a Log Analytics workspace. Without it, SAS usage leaves no queryable record. SAS tokens never appear in logs; the AuthenticationHash field holds the SHA-256 hash of the decoded signature, so you can match a known token by hashing its sig value.

SignalWhere and howWhat it indicates
Requests authorised by key or SASStorageBlobLogs | where AuthenticationType in ("AccountKey", "SAS"), summarised by CallerIpAddress, UserAgentHeader, AccountNameWhich clients still depend on Shared Key or SAS before you disable it
Out-of-policy SAS in useSasExpiryStatus property in storage resource logsA SAS with no start time or an interval above the policy limit
Writes through SASOperationName == "PutBlob" with AuthenticationType == "SAS", projecting AuthenticationHash and UriUploads by token holders; unexpected volume suggests leaked write SAS
Unknown SAS from new locationsNew AuthenticationHash values or new caller IPs on sensitive accountsA token you did not issue, or one being reused outside its purpose (ATT&CK T1530 Data from Cloud Storage)
Key listingAzure Activity Log operation listKeys on storage accountsSomeone obtained the ability to mint SAS offline
Policy changesActivity Log writes changing sasPolicy, keyPolicy or allowSharedKeyAccessControls weakened

Issuing services should log every SAS they create with recipient, resource, permissions, expiry, the scid correlation ID where supported, and the signature hash, because Azure cannot tell you who a SAS was given to. Relevant ATT&CK techniques: T1552.001 Credentials In Files (SAS URLs in code and configs), T1528 Steal Application Access Token and T1530 Data from Cloud Storage.

Metrics that show it is working

  • Shared Key disabled: percentage of storage accounts with AllowSharedKeyAccess set to false.
  • Policy coverage: percentage of accounts with a SAS expiration policy in Block mode, and the configured upper limit.
  • Key-signed traffic: share of requests with AuthenticationType AccountKey or SAS, trending down month on month.
  • Logging coverage: percentage of accounts with diagnostic settings for every enabled service.
  • Leak response: SAS URLs found by secret scanning per month and median time from detection to revocation.

Hardening baseline

SettingTarget valueEnforce withFramework mapping
AllowSharedKeyAccessfalse wherever no client needs keysAzure Policy "Storage accounts should prevent shared key access" (Audit, then Deny)NIST SP 800-53 IA-5, AC-3; CSF 2.0 PR.AA-01
SAS expiration policyEnabled, upper limit sized to real need (hours for most uses), action Block"Storage accounts should have shared access signature (SAS) policies configured"; "Storage SAS tokens should adhere to 7 day maximum validity"SP 800-53 IA-5, AC-6; CSF 2.0 PR.AA-05
Key expiration policySet, with keys rotated within it"Storage account keys should not be expired"SP 800-53 IA-5, SC-12
Anonymous and public network accessAnonymous blob access disallowed; public network access disabled where possible"Storage account public access should be disallowed"; "Storage accounts should disable public network access"SP 800-53 AC-3; CIS Control 3
Diagnostic loggingResource logs for all services to a central workspace, with alert rulesAzure Policy diagnostic settings assignments, or landing zone automationSP 800-53 AU-2, AU-6; CSF 2.0 DE.CM-09; CIS Control 8
Who can list keysOnly break-glass and key rotation identities, through just-in-time elevationRBAC review, PIMSP 800-53 AC-6; CIS Control 6

Rollout without breaking applications

  1. Inventory: list accounts and their allowSharedKeyAccess value with Azure Resource Graph, and enable diagnostic logging on all of them.
  2. Observe for two to four weeks: run the AccountKey and SAS query to identify every client, and the owners behind each caller IP and user agent.
  3. Set SAS expiration policies in Log mode and review SasExpiryStatus entries. If the portal greys the setting out, rotate both account keys once so keyCreationTime is populated.
  4. Migrate clients: managed identities for Azure workloads, user delegation SAS for external sharing, stored access policies for the remainder.
  5. Enforce: switch expiration policies to Block, set AllowSharedKeyAccess to false account by account, and change the Azure Policy assignments from Audit to Deny.
  6. Roll back a single account by setting AllowSharedKeyAccess to true or the expiration action back to Log, and record the exception with an owner and end date.

Note that the Azure portal uses Shared Key by default to browse Azure Files, so assign data roles before disabling keys on accounts with file shares. Disabling Shared Key is also a prerequisite for protecting an account with Entra Conditional Access.

Common misconfigurations

  • Full-control account SAS shared publicly. In the Microsoft SAS Token Exposure 2023, an account SAS with full control over a whole storage account sat in a public GitHub repository, its expiry extended to 2051, exposing 38TB including workstation backups and Teams messages. Scope, permissions and expiry all failed at once.
  • Scanner findings dismissed. The same case was flagged by secret scanning and marked a false positive. SAS URLs are credentials; triage them as such. See the Git Secret Scanning Guide.
  • Sharing from production accounts. A SAS for one file on an account that holds everything turns any scoping mistake into a full exposure. Use dedicated accounts for external sharing.
  • Expiration policy left in Log mode. It warns creators and writes log entries, but out-of-policy tokens keep working.
  • Using both keys across applications. When key1 and key2 are both in use, no key can be rotated without an outage, so leaked SAS are never revoked.
  • Write permission without validation. Microsoft notes a write SAS lets the holder upload whatever they like and bill it to you; validate written data before use and keep write SAS short-lived.

Practitioner checklist

  • Enable diagnostic logging on every storage account and baseline which clients use AccountKey or SAS authorisation.
  • Remove listkeys rights from everyone who does not rotate keys; use Storage Blob Data roles for data access.
  • Replace account and ad hoc service SAS with managed identities or user delegation SAS scoped to single resources.
  • Configure a SAS expiration policy on every account, validate in Log mode, then switch to Block.
  • Set AllowSharedKeyAccess to false wherever possible and enforce it with the built-in Azure Policy in Deny mode.
  • Bind any remaining long-lived service SAS to stored access policies so they can be revoked without key rotation.
  • Require issuing services to log recipient, scope, expiry, correlation ID and signature hash for every SAS.
  • Scan repositories, wikis and tickets for SAS URLs and write a revocation runbook for each SAS type.

Standards and references

Related NHI Mgmt Group resources: Microsoft Azure Security Guide · Azure Managed Identities Security Guide · OWASP NHI Top 10 NHI7 Long-Lived Secrets Guide · Cloud Storage Exposure Playbook · Kubernetes Secrets Security Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 26 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.