[Storage] Strip sensitive auth info on cross-domain redirect#47541
Open
weirongw23-msft wants to merge 3 commits into
Open
[Storage] Strip sensitive auth info on cross-domain redirect#47541weirongw23-msft wants to merge 3 commits into
weirongw23-msft wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a Storage pipeline policy intended to prevent credential/SAS leakage by stripping sensitive authentication headers and query parameters when an HTTP redirect crosses domains, and wires that policy into the Blob, Queue, File Share, and Data Lake pipelines.
Changes:
- Added
StorageSensitiveHeaderCleanupPolicyto scrub sensitive headers and removesigfrom the URL query whenRedirectPolicyflags a cross-domain redirect. - Inserted the new policy into the sync/async pipeline construction for Blob, Queue, File Share, and Data Lake clients.
- Added a Blob unit test covering the redirect-cleanup behavior.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/storage/azure-storage-queue/azure/storage/queue/_shared/policies.py | Adds StorageSensitiveHeaderCleanupPolicy implementation for Queue. |
| sdk/storage/azure-storage-queue/azure/storage/queue/_shared/base_client.py | Wires the new cleanup policy into the Queue sync pipeline. |
| sdk/storage/azure-storage-queue/azure/storage/queue/_shared/base_client_async.py | Wires the new cleanup policy into the Queue async pipeline. |
| sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/policies.py | Adds StorageSensitiveHeaderCleanupPolicy implementation for File Share. |
| sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/base_client.py | Wires the new cleanup policy into the File Share sync pipeline. |
| sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/base_client_async.py | Wires the new cleanup policy into the File Share async pipeline. |
| sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/policies.py | Adds StorageSensitiveHeaderCleanupPolicy implementation for Data Lake. |
| sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/base_client.py | Wires the new cleanup policy into the Data Lake sync pipeline. |
| sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/base_client_async.py | Wires the new cleanup policy into the Data Lake async pipeline. |
| sdk/storage/azure-storage-blob/azure/storage/blob/_shared/policies.py | Adds StorageSensitiveHeaderCleanupPolicy implementation for Blob. |
| sdk/storage/azure-storage-blob/azure/storage/blob/_shared/base_client.py | Wires the new cleanup policy into the Blob sync pipeline. |
| sdk/storage/azure-storage-blob/azure/storage/blob/_shared/base_client_async.py | Wires the new cleanup policy into the Blob async pipeline. |
| sdk/storage/azure-storage-blob/tests/test_sensitive_redirect.py | Adds unit coverage for redirect-based sensitive header/query cleanup (Blob only). |
Comment on lines
+912
to
+919
| # Clean up request query parameters | ||
| parsed = urlparse(request.http_request.url) | ||
| kept = [ | ||
| pair | ||
| for pair in parsed.query.split("&") | ||
| if pair and pair.split("=", 1)[0] not in self._blocked_query_params | ||
| ] | ||
| request.http_request.url = urlunparse(parsed._replace(query="&".join(kept))) |
Comment on lines
+912
to
+919
| # Clean up request query parameters | ||
| parsed = urlparse(request.http_request.url) | ||
| kept = [ | ||
| pair | ||
| for pair in parsed.query.split("&") | ||
| if pair and pair.split("=", 1)[0] not in self._blocked_query_params | ||
| ] | ||
| request.http_request.url = urlunparse(parsed._replace(query="&".join(kept))) |
Comment on lines
+912
to
+919
| # Clean up request query parameters | ||
| parsed = urlparse(request.http_request.url) | ||
| kept = [ | ||
| pair | ||
| for pair in parsed.query.split("&") | ||
| if pair and pair.split("=", 1)[0] not in self._blocked_query_params | ||
| ] | ||
| request.http_request.url = urlunparse(parsed._replace(query="&".join(kept))) |
Comment on lines
+918
to
+925
| # Clean up request query parameters | ||
| parsed = urlparse(request.http_request.url) | ||
| kept = [ | ||
| pair | ||
| for pair in parsed.query.split("&") | ||
| if pair and pair.split("=", 1)[0] not in self._blocked_query_params | ||
| ] | ||
| request.http_request.url = urlunparse(parsed._replace(query="&".join(kept))) |
| ) | ||
|
|
||
| def __init__( | ||
| self, |
| ) | ||
|
|
||
| def __init__( | ||
| self, |
| ) | ||
|
|
||
| def __init__( | ||
| self, |
| StorageResponseHook(**kwargs), | ||
| DistributedTracingPolicy(**kwargs), | ||
| HttpLoggingPolicy(**kwargs), | ||
| StorageSensitiveHeaderCleanupPolicy(**kwargs), |
| StorageResponseHook(**kwargs), | ||
| DistributedTracingPolicy(**kwargs), | ||
| HttpLoggingPolicy(**kwargs), | ||
| StorageSensitiveHeaderCleanupPolicy(**kwargs), |
| StorageResponseHook(**kwargs), | ||
| DistributedTracingPolicy(**kwargs), | ||
| HttpLoggingPolicy(**kwargs), | ||
| StorageSensitiveHeaderCleanupPolicy(**kwargs), |
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.
No description provided.