Description
In an Azure file share’s stored access policy, permissions controls what a service SAS referencing that policy can do. rwdl permits reading, writing, deleting and listing files.
Potential impact
A token issued for a simple download could also be used to change or remove files if it grants those permissions.
Remediation
Keep only the permissions the task needs. For downloads, use r and set UTC start and expiry times for the required period. Test that a SAS referencing the policy can read a file and cannot write it.
Examples
Both examples change the policy on sharename. Supply the actual storage account and source file, and set expiry later than start.
Before
hcl
resource "azurerm_storage_share_file" "example" {
name = "my-awesome-content.zip"
storage_share_id = azurerm_storage_share.example.id
source = "some-local-file.zip"
}
resource "azurerm_storage_share" "example" {
name = "sharename"
storage_account_id = azurerm_storage_account.example.id
quota = 50
acl {
id = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI"
access_policy {
permissions = "rwdl"
start = var.policy_start_utc
expiry = var.policy_expiry_utc
}
}
}
After
hcl
resource "azurerm_storage_share_file" "example" {
name = "my-awesome-content.zip"
storage_share_id = azurerm_storage_share.example.id
source = "some-local-file.zip"
}
resource "azurerm_storage_share" "example" {
name = "sharename"
storage_account_id = azurerm_storage_account.example.id
quota = 50
acl {
id = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI"
access_policy {
permissions = "r"
start = var.policy_start_utc
expiry = var.policy_expiry_utc
}
}
}