T1071.005

Publish/Subscribe Protocols

Adversaries may communicate using publish/subscribe (pub/sub) application layer protocols to avoid detection/network filtering by blending in with existing traffic. Commands to the remote system, and often the results of those commands, will be embedded within the protocol traffic between the client and server. Protocols such as MQTT, XMPP, AMQP, and STOMP use a publish/subscribe design, with message distribution managed by a centralized broker. Publishers categorize their messages by topics, while subscribers receive messages according to their subscribed topics. An adversary may abuse publish/subscribe protocols to communicate with systems under their control from behind a message broker while also mimicking normal, expected traffic.

Microsoft Sentinel / Defender
kusto
let TimeWindow = 24h;
let PubSubPorts = dynamic([1883, 8883, 5222, 5223, 5269, 5672, 5671, 61613, 61614]);
// Detect connections to pub/sub protocol ports
DeviceNetworkEvents
| where Timestamp > ago(TimeWindow)
| where RemotePort in (PubSubPorts)
| where ActionType == "ConnectionSuccess"
| extend Protocol = case(
    RemotePort in (1883, 8883), "MQTT",
    RemotePort in (5222, 5223, 5269), "XMPP",
    RemotePort in (5672, 5671), "AMQP",
    RemotePort in (61613, 61614), "STOMP",
    "Unknown")
| extend IsExternal = RemoteIPType == "Public"
| summarize
    ConnectionCount = count(),
    BytesSent = sum(SentBytes),
    BytesReceived = sum(ReceivedBytes),
    FirstSeen = min(Timestamp),
    LastSeen = max(Timestamp)
    by DeviceName, InitiatingProcessFileName, RemoteIP, RemotePort, Protocol, IsExternal, AccountName
| where ConnectionCount > 1
| extend Suspicion = case(
    IsExternal and Protocol in ("XMPP", "STOMP"), "high",
    IsExternal and Protocol == "MQTT" and InitiatingProcessFileName !in~ ("mosquitto_pub", "mosquitto_sub", "mosquitto"), "high",
    IsExternal and Protocol == "AMQP", "medium",
    not(IsExternal) and Protocol in ("XMPP", "STOMP"), "medium",
    "low")
| where Suspicion in ("high", "medium")
| project LastSeen, DeviceName, AccountName, InitiatingProcessFileName, RemoteIP, Protocol, RemotePort, IsExternal, ConnectionCount, BytesSent, BytesReceived, Suspicion
| sort by Suspicion asc, ConnectionCount desc
high severity medium confidence

Data Sources

Network Traffic: Network Connection Creation Network Traffic: Network Traffic Flow Microsoft Defender for Endpoint

Required Tables

DeviceNetworkEvents

False Positives

  • IoT platforms and home automation systems that legitimately use MQTT for device communication (Home Assistant, AWS IoT Core)
  • Chat and messaging applications using XMPP (Pidgin, Conversations, Cisco Jabber)
  • Message queue infrastructure (RabbitMQ, ActiveMQ, Apache Kafka) used for application integration
  • Development and testing environments with MQTT brokers for IoT prototyping

Unlock Pro Content

Get the full detection package for T1071.005 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections