MQTT Security Assistant

MQTT Security Assistant (MQTTSA) is a tool designed to increase the security awareness of IoT developers by automatically assessing misconfigurations in MQTT-based environments and by providing a report of potential vulnerabilities and mitigation measures at a different level of details - from natural language descriptions to code snippets that can be cut-and-paste in actual deployments.

More information about the tool can be found on: A.Palmieri, P.Prem, S.Ranise, U.Morelli, T.Ahmad, "MQTTSA: A Tool for Automatically Assisting the Secure Deployments of MQTT brokers". In proceedings of IEEE SERVICES Workshop on Cyber Security and Resilience in the Internet of Things (CSRIoT 2019).

Architecture

Modules

  • Connection
  • Data parsing and exfiltration
    • Credential sniffing
    • Broker fingerprinting
  • Authentication bruteforcing
  • Data tampering
  • Denial of Service (DoS)
  • Report Generator

The connection module attempts to connect to the specified MQTT broker as a regular client and records the return_code value. According to the return_code (e.g. "4" if an authentication mechanism is detected) and the parameters specified by the user when running MQTTSA (e.g. a username and a wordlist of passwords via the -u and -w parameters), other modules are invoked or disabled.

The data parsing and exfiltration is responsible for recording messages and topics in the network (with Pyshark) and on MQTT topics (with Paho). This enables MQTTSA to exploit client credentials (extracted from MQTT CONNECT packets) and detect the leakage of sensitive data (such as credit cards, phone numbers and emails) by using a pre-defined set of regular expressions.

To allow the interception of credentials (i.e., perform Credential Sniffing), the user is required to run the tool in the clients or broker network and set the network interface parameter -i to, e.g., wlan0 or eth0.

By subscribing to the # and $SYS/# topics, MQTTSA intercepts, respectively, messages from clients and the internal control messages of the broker. The second messages are particularly important to enable the Broker Fingerprinting module to identify the broker type and version.

If the user does not enable the option “ni” (that restricts the tool to execute non-intrusive attacks), the module will finally attempt to publish a default test message (that can be modified through the -m parameter) in each of the topics previously intercepted (eventually exloiting sniffed credentials); when successful, the topic is added to a “writable topics” list that is passed to the Data Tampering module.

The Authentication bruteforcing module implements a classic password bruteforce attack in case the value of return_code is "4" and the tool is launched with a username and a wordlist of passwords. To the best of our knowledge, no dictionary of credentials specific to MQTT are currently available; we have thus derived one from Metasploit.

The Data Tampering module attempts to crash the broker or discontinue the IoT service by triggering missing input validation. It is executed only when launching the tool with the parameter --md and if the Data Parsing and Exfiltration module was able to recod at least one writable topic (see above). It also attempt to exploit specific vulnerabilities, such as CVE-2017-76507.

The Denial of Service module mounts a DoS attack by publishing considerably large files (up to 10mb) and performing several concurrent requests from a single process with multiple threads (100 by default). The idea is to evaluate the delay in the target MQTT broker upon receiving a substantial number of client requests (rather than inducing a permanent failure).

Notice that clients will be disconnected if the delay exceeds the keep_alive value configured in the broker: this accounts for the maximum time a broker will wait before closing the connection with a non-reachable client. Interestingly, this strategy can be exploited not only to mount DoS attacks but also to spoof the credentials of an authenticated clients by forcing their disconnection and then listening for CONNECT packets.

The Report Generator module generates a report (in PDF format) collecting all the results of the executed attack patterns and adescription of the mitigation measures for the detected vulnerabilities. If the Broker fingerprinting module was able to identify the broker type and version, the report also include code snippets that can be readily used in the actual deployment; thereby facilitating patching: as of the current version, only for Mosquitto (that resulted as the most widely used MQTT broker in our analysis).

Download

MQTTSA is an open-source project released under Apache-2.0 license. You can download, use and contribute to the code by visiting the project's repository on GitHub.

Who we are

Andrea Palmieri

Student@EIT Digital Master School, Trento, Italy andrea.palmieri@strudenti.unitn.it

Paolo Prem

student@EIT Digital Master School, Trento, Italypaolo.prem@strudenti.unitn.it

Silvio Ranise

Head of Security&Trust @ Fondazione Bruno Kessler, Trento, Italy ranise@fbk.eu

Umberto Morelli

Collaborator@Security&Trust - Fondazione Bruno Kessler, Trento, Italy umorelli@fbk.eu

Tahir Ahmad

Phd@Security&Trust - Fondazione Bruno Kessler, Trento, Italy ahmad@fbk.eu