Skip to content

[QUERY] BlobContainerClient is not restricted to a specific container #48284

Closed
@mhichb

Description

@mhichb

Library name and version

Azure.Storage.Blobs 12.23.0

Query/Question

For blob client / blob container client, there is no validation to not leave the original container, e.g. in the following example

var path = $"../{otherContainerName}/{pathInOtherContainer}";

var credential = new DefaultAzureCredential();
var blobServiceClient = new BlobServiceClient(new Uri($"https://{storageAccountName}.blob.core.windows.net/"), credential);
var blobContainerClient = blobServiceClient.GetBlobContainerClient(containerName);
var blobClient = blobContainerClient.GetBlobClient(path);
var result = await blobClient.DownloadContentAsync();

result will be filled with the actual content of the file, even though the blob is in another container.

Is it a deliberate choice in design to not validate whether the blob path is contained within the original container? From naming and the fact that a container name was provided in construction, one might think that the client cannot access anything outside the provided container.

In the current situation, it's pretty easy to forget to validate the path and thus become vulnerable to https://cwe.mitre.org/data/definitions/22.html

Providing such a validation library-side would be nice IMO.

Environment

No response

Metadata

Metadata

Assignees

Labels

ClientThis issue is related to a non-management packageService AttentionWorkflow: This issue is responsible by Azure service team.StorageStorage Service (Queues, Blobs, Files)customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions