Open philipsd6 opened 2 years ago
@philipsd6 Can this problem be resolved if you change the storage account access permissions?
kindly ping!
@Fred-sun : while I cannot answer for @philipsd6, my expectation would be that that would fix the issue. However, it is a really really bad idea to use the keys returned by listkeys for performing any actions as it completely nukes all security boundaries that might be applied in Azure. Is it possible to use the provided credentials via Ansible directly in the get_blob_service_client function?
In example: I want to download a blob from Azure, so the storage account owner grants me read rights. Should be sufficient right? However, this does not work due to the current get_blob_service_client routine that is hardcoded to request the storage account keys (see https://github.com/ansible-collections/azure/blob/ef944d9f715b5231cabf4e4caa1d930f8dc939ee/plugins/module_utils/azure_rm_common.py#L715 ). However, with that requested key I am able to modify every aspect of the storage account, and as such modify containers and blobs as a desire. Not exactly the read-only rights that I should have.
Same holds for another use case. A storage account owner grants a service principal read-write rights to a specific container, as he has different containers for different use cases. Uploading data without the listkeys access for the service principal will fail due to the same reason as in the previous example. With the listkeys access I can upload data to the target container perfectly fine, but due to the fact that a storage account key is used for authentication I can upload data to every other container as well! And for that reason the owner of the storage account will not grant me the listkeys action as it will allow me access way outside the intended scope.
SUMMARY
When using the
azure_rm_storageblob
module to access content in a specified container I have access to, I receive an error because I do not have access to list all the containers of the storage account.ISSUE TYPE
COMPONENT NAME
azure_rm_storageblob
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
n/a
STEPS TO REPRODUCE
storageAccounts/listKeys
Called the module like this (fake data of course)
EXPECTED RESULTS
I expect the
testing.json
blob to be downloaded to/tmp/test.json
.I expect to be able to work with the blobs in a specified container when access is granted to that specific container, even if I do not have full access to all containers in a storage account.
ACTUAL RESULTS
Received error:
This implies that even though I've specified "the_container" as my target container, the module still needs access to all containers in the storage account, which is broader permissions that necessary.
In order to resolve the issue, the service principal was required to have access granted at the Storage Account level instead of the Container level.