Repository navigation
Redact SAS tokens and lowercase account keys in AzureBlockBlobBackend.as_uri - #10620
Merged
Merged
Conversation
….as_uri as_uri() only masked a part that starts with the exact text "AccountKey=". Azure also accepts a SharedAccessSignature in the connection string and matches keys case-insensitively, so a SAS token or an "accountkey=" was printed in clear, for example in the results line of the worker banner.
auvipy
self-requested a review
September 13, 2026 04:25
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10620 +/- ##
=======================================
Coverage 89.07% 89.07%
=======================================
Files 153 153
Lines 20139 20143 +4
Branches 2371 2373 +2
=======================================
+ Hits 17938 17942 +4
Misses 1896 1896
Partials 305 305
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
auvipy
approved these changes
Sep 13, 2026
ac2-d2c-c47-4ad4608af
pushed a commit
to ac2-d2c-c47-4ad4608af/celery
that referenced
this pull request
Sep 21, 2026
….as_uri (celery#10620) as_uri() only masked a part that starts with the exact text "AccountKey=". Azure also accepts a SharedAccessSignature in the connection string and matches keys case-insensitively, so a SAS token or an "accountkey=" was printed in clear, for example in the results line of the worker banner. Co-authored-by: Asif Saif Uddin {"Auvi":"অভি"} <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: Before submitting this pull request, please review our contributing
guidelines.
Description
While reading
AzureBlockBlobBackend.as_uri()I noticed it only masks a connection string part that starts with the exact textAccountKey=. The Azure SDK accepts two other forms that carry a secret, and both came out in clear.The first is a SAS connection string (
BlobEndpoint=...;SharedAccessSignature=sv=...&sig=...), whichBlobServiceClient.from_connection_string()accepts as is. The second is the same key in a different case: the SDK upper-cases keys before reading them (parse_connection_strin azure-storage-blob 12.30.1), soaccountkey=...authenticates fine but is not matched bystartswith('AccountKey=').I checked this against azure-storage-blob 12.30.1 with a fake token. On main:
as_uri()is what the worker banner prints on itsresults:line (celery/apps/worker.py), so the token ends up in startup logs.The fix compares each key case-insensitively against
AccountKeyandSharedAccessSignatureand keeps the key as the user wrote it, so the existingAccountKey=**output is unchanged.include_password=Truestill returns the full string.I added two tests next to the existing
as_uriones. Both fail on main with an assertion error and pass with the change, and the wholet/unit/backends/test_azureblockblob.pypasses (22 tests). flake8 is clean on both files.AI tools used