# Az - Queue Storage Privesc

{{#include ../../../banners/hacktricks-training.md}}

## Queue

For more information check:

{{#ref}}
../az-services/az-queue.md
{{#endref}}

### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/read`

An attacker with this permission can peek messages from an Azure Storage Queue. This allows the attacker to view the content of messages without marking them as processed or altering their state. This could lead to unauthorized access to sensitive information, enabling data exfiltration or gathering intelligence for further attacks.

```bash
az storage message peek --queue-name <queue_name> --account-name <storage_account>
```

**Potential Impact**: Unauthorized access to the queue, message exposure, or queue manipulation by unauthorized users or services.

### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/process/action`

With this permission, an attacker can retrieve and process messages from an Azure Storage Queue. This means they can read the message content and mark it as processed, effectively hiding it from legitimate systems. This could lead to sensitive data being exposed, disruptions in how messages are handled, or even stopping important workflows by making messages unavailable to their intended users.

```bash
az storage message get --queue-name <queue_name> --account-name <storage_account>
```

### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/add/action`

With this permission, an attacker can add new messages to an Azure Storage Queue. This allows them to inject malicious or unauthorized data into the queue, potentially triggering unintended actions or disrupting downstream services that process the messages.

```bash
az storage message put --queue-name <queue-name> --content "Injected malicious message" --account-name <storage-account>
```

### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/write`

This permission allows an attacker to add new messages or update existing ones in an Azure Storage Queue. By using this, they could insert harmful content or alter existing messages, potentially misleading applications or causing undesired behaviors in systems that rely on the queue.

```bash
az storage message put --queue-name <queue-name> --content "Injected malicious message" --account-name <storage-account>

#Update the message
az storage message update --queue-name <queue-name> \
    --id <message-id> \
    --pop-receipt <pop-receipt> \
    --content "Updated message content" \
    --visibility-timeout <timeout-in-seconds> \
    --account-name <storage-account>
```

### Action: `Microsoft.Storage/storageAccounts/queueServices/queues/write`

This permission allows an attacker to create or modify queues and their properties within the storage account. It can be used to create unauthorized queues, modify metadata, or change access control lists (ACLs) to grant or restrict access. This capability could disrupt workflows, inject malicious data, exfiltrate sensitive information, or manipulate queue settings to enable further attacks.

```bash
az storage queue create --name <new-queue-name> --account-name <storage-account>

az storage queue metadata update --name <queue-name> --metadata key1=value1 key2=value2 --account-name <storage-account>

az storage queue policy set --name <queue-name> --permissions rwd --expiry 2024-12-31T23:59:59Z --account-name <storage-account>
```

## References

- [https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues](https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues)
- [https://learn.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api](https://learn.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api)
- [https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes](https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes)

{{#include ../../../banners/hacktricks-training.md}}



