Az - Service Bus Enum

Reading time: 7 minutes

tip

Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)

Support HackTricks

Service Bus

Azure Service Bus is a cloud-based messaging service designed to enable reliable communication between different parts of an application or separate applications. It acts as a secure middleman, ensuring messages are safely delivered, even if the sender and receiver arenā€™t operating simultaneously. By decoupling systems, it allows applications to work independently while still exchanging data or instructions. Itā€™s particularly useful for scenarios requiring load balancing across multiple workers, reliable message delivery, or complex coordination, such as processing tasks in order or securely managing access.

Key Concepts

  1. Namespaces: A namespace in messaging systems is a logical container that organizes and manages messaging components, queues and topics. It provides an isolated environment where applications can send, receive, and process messages. Queues and topics share the same infrastructure and configuration within a Service Bus namespace, but they operate independently without interacting with each other.
  2. Queues: its purpose is to store messages until the receiver is ready.
    • Messages are ordered, timestamped, and durably stored.
    • Delivered in pull mode (on-demand retrieval) to one consumer.
      • It can be configured so when the message is shared itā€™s automatically deleted or in ā€œPeek lockā€ mode where the consumer needs to acknowledge that it can be deleted. If not, the message will get back to the queue.
    • Supports point-to-point communication.
  3. Topics: Publish-subscribe messaging for broadcasting.
    • Multiple independent subscriptions receive copies of messages.
      • Each subscription is like a queue inside the topic.
    • Subscriptions can have rules/filters to control delivery or add metadata.

The service bus endpoint/connection string is:

bash
https://<namespace>.servicebus.windows.net:443/

Advance Features

Some advance features are:

  • Message Sessions: Ensures FIFO processing and supports request-response patterns.
  • Auto-Forwarding: Transfers messages between queues or topics in the same namespace.
  • Dead-Lettering: Captures undeliverable messages for review.
  • Scheduled Delivery: Delays message processing for future tasks.
  • Message Deferral: Postpones message retrieval until ready.
  • Transactions: Groups operations into atomic execution.
  • Filters & Actions: Applies rules to filter or annotate messages.
  • Auto-Delete on Idle: Deletes queues after inactivity (min: 5 minutes).
  • Duplicate Detection: Removes duplicate messages during resends.
  • Batch Deletion: Bulk deletes expired or unnecessary messages.

Local Authentication

The --disable-local-auth from az cli parameter is used to control whether local authentication (allowing the use of Shared Access Signature (SAS) keys) is enabled for your Service Bus namespace.

  • When disable is set to true: Local authentication using SAS keys is disabled and Entrad ID authentication is allowed.
  • When disable is set to false (default): Both SAS local authentication and Entra ID authentication are available and you can use connection strings with SAS keys to access your Service Bus resources.

Authorization-Rule / SAS Policy

SAS Policies define the access permissions for Azure Service Bus entities namespace (Most Important One), queues and topics. Each policy has the following components:

  • Permissions: Checkboxes to specify access levels:
    • Manage: Grants full control over the entity, including configuration and permissions management.
    • Send: Allows sending messages to the entity.
    • Listen: Allows receiving messages from the entity.
  • Primary and Secondary Keys: These are cryptographic keys used to generate secure tokens for authenticating access.
  • Primary and Secondary Connection Strings: Pre-configured connection strings that include the endpoint and key for easy use in applications.
  • SAS Policy ARM ID: The Azure Resource Manager (ARM) path to the policy for programmatic identification.

Itā€™s important to note that a namespace has a single SAS policy that affects every entity within it, while queues and topics can have their own individual SAS policies for more granular control.

Enumeration

bash
# Namespace Enumeration
az servicebus namespace list
az servicebus namespace network-rule-set list --resource-group <MyResourceGroup> --namespace-name <MyNamespace>
az servicebus namespace show --resource-group <MyResourceGroup> --name <MyNamespace>
az servicebus namespace network-rule-set show --resource-group <MyResourceGroup> --namespace-name <MyNamespace>
az servicebus namespace private-endpoint-connection list --resource-group <MyResourceGroup> --namespace-name <MyNamespace>
az servicebus namespace exists --name ProposedNamespace

# Authorization Rule Enumeration
az servicebus namespace authorization-rule list --resource-group <MyResourceGroup> --namespace-name <MyNamespace>
az servicebus queue authorization-rule list --resource-group <MyResourceGroup> --namespace-name <MyNamespace> --queue-name <MyQueue>
az servicebus topic authorization-rule list --resource-group <MyResourceGroup> --namespace-name <MyNamespace> --topic-name <MyTopic>
az servicebus namespace authorization-rule keys list --resource-group <MyResourceGroup> --namespace-name <MyNamespace> --name <MyAuthRule>

# Get keys
az servicebus namespace authorization-rule keys list --resource-group <res-group> --namespace-name <namespace-name> [--authorization-rule-name RootManageSharedAccessKey]
az servicebus topic authorization-rule keys list --resource-group <res-group> --namespace-name <namespace-name> --topic-name <topic-name> --name <auth-rule-name>
az servicebus queue authorization-rule keys list --resource-group <res-group> --namespace-name <namespace-name> --queue-name <topic-name> --name <auth-rule-name>

# Queue Enumeration
az servicebus queue list --resource-group <MyResourceGroup> --namespace-name <MyNamespace>
az servicebus queue show --resource-group <MyResourceGroup> --namespace-name <MyNamespace> --name <MyQueue>

# Topic Enumeration
az servicebus topic list --resource-group <MyResourceGroup> --namespace-name <MyNamespace>
az servicebus topic show --resource-group <MyResourceGroup> --namespace-name <MyNamespace> --name <MyTopic>

# Susbscription Enumeration
az servicebus topic subscription list --resource-group <MyResourceGroup> --namespace-name <MyNamespace> --topic-name <MyTopic>
az servicebus topic subscription show --resource-group <MyResourceGroup> --namespace-name <MyNamespace> --topic-name <MyTopic> --name <MySubscription>

Privilege Escalation

Az - Service Bus Privesc

Post Exploitation

Az - Service Bus Post Exploitation

References

tip

Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)

Support HackTricks