Skip to content

Fixed a few SAS bugs in blob and file. Incorrectly appending a duplicate ? and not treating versioned blobs correctly - #27592

Open
Gauri Lamunion (gapra-msft) wants to merge 1 commit into
mainfrom
gapra/sasFix
Open

Gauri Lamunion (gapra-msft) wants to merge 1 commit into
mainfrom
gapra/sasFix

Conversation

@gapra-msft

Copy link
Copy Markdown
Member

Fixes a Shared Access Signature (SAS) vulnerability/bug class affecting versioned blobs and snapshotted share/file resources in azblob and azfile:

  • blob.Client.GetSASURL() called on a client returned by WithVersionID produced a SAS that was byte-for-byte identical to an ordinary base-blob (sr=b) SAS, silently granting broader access than intended. After fixing the resource-type binding, a second bug was found: the version identifier was never included in the signed string-to-sign (sas/service.go), so the corrected sr=bv SAS would fail to authenticate. Both are now fixed in SignWithSharedKey and SignWithUserDelegation.

  • GetSASURL() on blob.Client, container.Client, share.Client, and file.Client appended a second ? to the URL when the client's URL already contained a query string (e.g. clients returned by WithSnapshot/WithVersionID, or a file client derived from a share snapshot), producing a malformed SAS URL.

  • The purpose of this PR is explained in this or a referenced issue.

  • The PR does not update generated files.

  • Tests are included and/or updated for code changes.

  • Updates to module CHANGELOG.md are included.

  • MIT license headers are included in each file.

…ate ? and not treating versioned blobs correctly
Copilot AI balanced review requested due to automatic review settings September 21, 2026 20:00
@github-actions github-actions Bot added the Storage Storage Service (Queues, Blobs, Files) label Sep 21, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
6 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The advertised container fix is missing, and user-delegation version signing lacks regression coverage.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Fixes SAS generation for versioned blobs and snapshot-scoped Azure Files resources.

Changes:

  • Correctly signs blob-version SAS tokens.
  • Merges SAS parameters into existing query strings.
  • Adds live regression tests and changelog entries.
File Description
sdk/​storage/​azfile/​share/​client.go Merges share SAS query parameters.
sdk/​storage/​azfile/​share/​client_test.go Tests snapshot share/file SAS URLs.
sdk/​storage/​azfile/​file/​client.go Merges file SAS query parameters.
sdk/​storage/​azfile/​CHANGELOG.md Documents Azure Files fixes.
sdk/​storage/​azblob/​sas/​service.go Includes version IDs in signatures.
sdk/​storage/​azblob/​CHANGELOG.md Documents blob SAS fixes.
sdk/​storage/​azblob/​blob/​client.go Generates version-scoped SAS URLs.
sdk/​storage/​azblob/​blob/​client_test.go Tests version isolation and authentication.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

}

endpoint := b.URL() + "?" + qps.Encode()
// b.URL() may already contain a query string (e.g. "versionid" or "snapshot" for

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

container URL does not need this fix. It does not have resources with query params

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm actually we should modify all the methods to have this fix in case there are customer custom query params in the URL

Comment on lines +251 to +255
if resource == "bv" {
// See the corresponding comment in SignWithSharedKey: the "signed snapshot time"
// slot is shared between blob snapshots and blob versions and must carry the
// version ID for a version SAS.
snapshotTime = v.BlobVersion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Storage Storage Service (Queues, Blobs, Files)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants