Mitigation Strategy: Enable Username/Password Authentication in Mosquitto
-
Mitigation Strategy: Enable Username/Password Authentication in Mosquitto
-
Description:
- Modify Mosquitto Configuration File (
mosquitto.conf
): Open themosquitto.conf
file. - Disable Anonymous Access: Ensure the line
allow_anonymous false
is present and uncommented in themosquitto.conf
file. This setting is a core Mosquitto configuration that disables unauthenticated connections. - Configure Password File: Specify the path to the password file using the
password_file
directive inmosquitto.conf
. For example:password_file /etc/mosquitto/mosquitto_users.pwd
. This tells Mosquitto where to find user credentials. - Create User Credentials: Use the
mosquitto_passwd
utility (provided with Mosquitto) to create user entries in the specified password file. For each user, execute:mosquitto_passwd -b /etc/mosquitto/mosquitto_users.pwd <username> <password>
. This utility is specific to Mosquitto for managing user passwords. - Restart Mosquitto Service: Restart the Mosquitto service (e.g.,
sudo systemctl restart mosquitto
) for the configuration changes to be applied. Mosquitto will now enforce username/password authentication based on the configured settings. - Configure MQTT Clients: Ensure all MQTT clients connecting to Mosquitto are configured to provide valid usernames and passwords during connection establishment. This is the client-side counterpart to the Mosquitto authentication enforcement.
- Modify Mosquitto Configuration File (
-
List of Threats Mitigated:
- Unauthorized Access to Mosquitto Broker (High Severity): Prevents connections from clients that do not provide valid credentials, directly mitigating unauthorized access to the Mosquitto broker itself.
- Data Breaches via Unauthenticated Access (High Severity): Reduces the risk of data breaches by ensuring only authenticated clients can access messages routed through Mosquitto.
- Malicious Control of MQTT Topics (High Severity): Prevents unauthorized entities from publishing or subscribing to topics managed by Mosquitto, thus protecting against malicious control.
-
Impact:
- Unauthorized Access to Mosquitto Broker: High reduction. Directly and effectively blocks anonymous connections at the Mosquitto broker level.
- Data Breaches via Unauthenticated Access: High reduction. Significantly limits data exposure by enforcing authentication at the broker.
- Malicious Control of MQTT Topics: High reduction. Prevents unauthorized topic interaction by controlling access at the broker.
-
Currently Implemented: Yes, implemented in the production environment. Configuration is managed via Ansible in
/etc/mosquitto/mosquitto.conf
and/etc/mosquitto/mosquitto_users.pwd
. User management is currently manual. -
Missing Implementation: Not missing in production for basic authentication. However, integration with external authentication systems via Mosquitto plugins and password complexity policies are missing for enhanced security.
Mitigation Strategy: Implement Access Control Lists (ACLs) in Mosquitto
-
Mitigation Strategy: Implement Access Control Lists (ACLs) in Mosquitto
-
Description:
- Enable ACL File in Mosquitto Configuration: In
mosquitto.conf
, configure theacl_file
directive to specify the path to the ACL file. For example:acl_file /etc/mosquitto/mosquitto.acl
. This directive is specific to Mosquitto for enabling ACL functionality. - Create and Edit ACL File: Create the ACL file (e.g.,
mosquitto.acl
) at the specified path. - Define ACL Rules in ACL File: Within the ACL file, define rules using Mosquitto's ACL syntax to control publish and subscribe permissions for users and clients based on topics. Rules are specific to Mosquitto's ACL implementation. Examples:
user <username>
: Apply rules to a specific user.topic read <topic_pattern>
: Allow subscription to topics matching the pattern.topic write <topic_pattern>
: Allow publishing to topics matching the pattern.clientid <client_id_pattern>
: Apply rules to clients with IDs matching the pattern.
- Restart Mosquitto Service: Restart the Mosquitto service for the ACL configuration to be loaded and enforced by Mosquitto.
- Test ACL Enforcement: Thoroughly test the ACL rules by attempting to publish and subscribe to various topics with different users and clients to verify that Mosquitto is correctly enforcing the defined access controls.
- Enable ACL File in Mosquitto Configuration: In
-
List of Threats Mitigated:
- Unauthorized Topic Access via Mosquitto (Medium Severity): Prevents authenticated users from accessing topics beyond their authorized scope, controlled directly by Mosquitto's ACL mechanism.
- Privilege Escalation within MQTT Broker (Medium Severity): Limits the potential for users to gain unintended access to sensitive topics by enforcing granular permissions within Mosquitto.
- Data Tampering through Unauthorized Publishing (Medium Severity): Restricts publishing to specific topics based on ACLs enforced by Mosquitto, reducing the risk of unauthorized data modification.
-
Impact:
- Unauthorized Topic Access via Mosquitto: Medium reduction. Mosquitto ACLs effectively control topic-level access for authenticated users.
- Privilege Escalation within MQTT Broker: Medium reduction. Limits the scope of access based on defined roles within Mosquitto's ACL system.
- Data Tampering through Unauthorized Publishing: Medium reduction. Restricts publishing capabilities based on Mosquitto's ACL rules.
-
Currently Implemented: Partially implemented. Basic ACLs are configured in
/etc/mosquitto/mosquitto.acl
to separate device and administrative topics. -
Missing Implementation: Fine-grained, role-based ACLs and dynamic ACL management integrated with user roles are missing. Current ACL management is static and manual.
Mitigation Strategy: Enforce TLS/SSL Encryption in Mosquitto Listener
-
Mitigation Strategy: Enforce TLS/SSL Encryption in Mosquitto Listener
-
Description:
- Configure TLS Listener in
mosquitto.conf
: Define a listener block inmosquitto.conf
specifically for TLS/SSL, typically on port 8883. Use Mosquitto-specific directives within thelistener
block:These directives are Mosquitto configuration options for enabling TLS.listener 8883 protocol mqtt certfile /etc/mosquitto/certs/mosquitto.crt keyfile /etc/mosquitto/certs/mosquitto.key cafile /etc/mosquitto/certs/ca.crt (Optional, for client certificate authentication) require_certificate false (Set to true for client certificate authentication)
- Specify Certificate and Key Files: Provide the paths to the server certificate (
certfile
) and private key (keyfile
) files within thelistener
block. These files are used by Mosquitto to establish TLS connections. - Optionally Configure CA Certificate and Client Certificate Requirement: Use
cafile
to specify a CA certificate for client certificate authentication andrequire_certificate true
to enforce client certificate authentication. These are optional Mosquitto TLS features. - Disable or Restrict Unencrypted Listener (Port 1883): Comment out or remove the default listener on port 1883 in
mosquitto.conf
to disable unencrypted MQTT or restrict access to it using firewall rules. This forces clients to use the secure TLS listener. - Restart Mosquitto Service: Restart Mosquitto for the TLS listener configuration to become active.
- Configure MQTT Clients for TLS: Configure MQTT clients to connect to Mosquitto on port 8883 using TLS/SSL and to trust the server certificate. This client-side configuration is necessary to utilize the Mosquitto TLS listener.
- Configure TLS Listener in
-
List of Threats Mitigated:
- Eavesdropping on MQTT Traffic (High Severity): TLS encryption configured in Mosquitto directly prevents interception and reading of MQTT messages in transit between clients and the broker.
- Man-in-the-Middle (MitM) Attacks on MQTT Connections (High Severity): Mosquitto's TLS implementation protects against MitM attacks by establishing secure, authenticated channels.
- Data Tampering during MQTT Transmission (Medium Severity): TLS provides integrity checks, reducing the risk of data modification during transmission to and from the Mosquitto broker.
-
Impact:
- Eavesdropping on MQTT Traffic: High reduction. Mosquitto TLS encryption makes eavesdropping practically infeasible.
- Man-in-the-Middle (MitM) Attacks on MQTT Connections: High reduction. Mosquitto TLS effectively prevents MitM attacks when properly configured.
- Data Tampering during MQTT Transmission: Medium reduction. TLS provides integrity, mitigating but not eliminating all tampering risks.
-
Currently Implemented: Yes, TLS/SSL encryption is enabled for production MQTT traffic on port 8883 using Mosquitto's listener configuration. Certificates are managed by Let's Encrypt.
-
Missing Implementation: Enforcement of minimum TLS version and configuration of strong cipher suites within Mosquitto's TLS listener configuration are missing. Client certificate authentication, a Mosquitto TLS feature, is also not implemented.
Mitigation Strategy: Implement Connection Limits (max_connections
) in Mosquitto
-
Mitigation Strategy: Implement Connection Limits (
max_connections
) in Mosquitto -
Description:
- Edit
mosquitto.conf
: Open the Mosquitto configuration file. - Set
max_connections
Directive: Add or modify themax_connections
directive inmosquitto.conf
to limit the maximum number of concurrent client connections that Mosquitto will accept. For example:max_connections 1000
. This directive is a core Mosquitto setting for connection management. - Restart Mosquitto Service: Restart the Mosquitto service for the
max_connections
limit to be enforced by Mosquitto. - Monitor Mosquitto Connections: Monitor the number of active connections to Mosquitto to ensure the configured limit is appropriate and adjust if necessary based on observed usage and potential DoS attempts.
- Edit
-
List of Threats Mitigated:
- Connection Exhaustion Denial of Service (DoS) against Mosquitto (High Severity): Prevents attackers from overwhelming the Mosquitto broker with excessive connection attempts, a DoS attack directly targeting Mosquitto's connection handling.
- Resource Exhaustion on Mosquitto Broker (Medium Severity): Limits resource consumption (memory, file descriptors) on the Mosquitto server by preventing an uncontrolled number of connections, improving Mosquitto's stability under load.
-
Impact:
- Connection Exhaustion Denial of Service (DoS) against Mosquitto: High reduction. Mosquitto's
max_connections
effectively limits the impact of connection flooding attacks on the broker. - Resource Exhaustion on Mosquitto Broker: Medium reduction. Helps prevent resource depletion on the Mosquitto server due to excessive connections.
- Connection Exhaustion Denial of Service (DoS) against Mosquitto: High reduction. Mosquitto's
-
Currently Implemented: Yes,
max_connections
is set to 500 in the productionmosquitto.conf
. -
Missing Implementation: The current limit is static. Dynamic adjustment of
max_connections
based on real-time Mosquitto server load or anomaly detection would enhance DoS protection.
Mitigation Strategy: Implement Rate Limiting (max_inflight_messages
) in Mosquitto
-
Mitigation Strategy: Implement Rate Limiting (
max_inflight_messages
) in Mosquitto -
Description:
- Edit
mosquitto.conf
: Open the Mosquitto configuration file. - Set
max_inflight_messages
Directive: Add or modify themax_inflight_messages
directive inmosquitto.conf
. This directive limits the number of QoS 1 and QoS 2 messages that can be "in flight" (unacknowledged) per client in Mosquitto. For example:max_inflight_messages 20
. This is a Mosquitto-specific rate limiting mechanism. - Restart Mosquitto Service: Restart the Mosquitto service for the
max_inflight_messages
limit to be enforced by Mosquitto. - Monitor Mosquitto Message Queues: Monitor Mosquitto's message queues and client behavior to ensure the limit is appropriately balanced and effective in mitigating message flooding without impacting legitimate clients.
- Edit
-
List of Threats Mitigated:
- Message Flooding Denial of Service (DoS) against Mosquitto (Medium Severity): Prevents clients from overwhelming Mosquitto by sending a flood of QoS 1 or QoS 2 messages without waiting for acknowledgements, a DoS attack targeting Mosquitto's message processing.
- Resource Exhaustion on Mosquitto Broker due to Message Backlog (Medium Severity): Limits resource consumption (memory, queue size) on the Mosquitto server by controlling the number of unacknowledged messages, improving stability under message flooding conditions.
-
Impact:
- Message Flooding Denial of Service (DoS) against Mosquitto: Medium reduction. Mosquitto's
max_inflight_messages
reduces the impact of message flooding attacks on the broker. - Resource Exhaustion on Mosquitto Broker due to Message Backlog: Medium reduction. Helps prevent resource exhaustion on the Mosquitto server caused by excessive message queuing.
- Message Flooding Denial of Service (DoS) against Mosquitto: Medium reduction. Mosquitto's
-
Currently Implemented: Yes,
max_inflight_messages
is set to 50 in the productionmosquitto.conf
. -
Missing Implementation: More granular rate limiting options within Mosquitto, such as rate limiting based on message rate per topic or client type, are missing.
Mitigation Strategy: Keep Mosquitto Software Updated
-
Mitigation Strategy: Keep Mosquitto Software Updated
-
Description:
- Subscribe to Mosquitto Security Announcements: Subscribe to the official Mosquitto security mailing list or monitor official channels for security advisories and update announcements. This is specific to staying informed about Mosquitto security.
- Regularly Check for Mosquitto Updates: Periodically check the official Mosquitto website, package repositories, or update management systems for new Mosquitto versions and security patches.
- Establish Mosquitto Update Procedure: Define a process for testing and applying Mosquitto updates in a timely manner, including testing in a staging environment before production deployment.
- Automate Mosquitto Updates (Consider): Explore automating the Mosquitto update process using package managers or configuration management tools to ensure timely patching of Mosquitto vulnerabilities.
- Apply Mosquitto Security Updates Promptly: Prioritize applying security updates for Mosquitto to production systems as quickly as possible after testing to address known vulnerabilities in the Mosquitto software.
-
List of Threats Mitigated:
- Exploitation of Known Mosquitto Vulnerabilities (High Severity): Regularly updating Mosquitto patches known security vulnerabilities in the broker software itself, preventing attackers from exploiting these flaws to compromise Mosquitto.
-
Impact:
- Exploitation of Known Mosquitto Vulnerabilities: High reduction. Significantly reduces the risk of exploitation by patching vulnerabilities within the Mosquitto broker software.
-
Currently Implemented: Partially implemented. We are subscribed to security mailing lists and periodically check for updates.
-
Missing Implementation: Automated Mosquitto update process is missing. Updates are currently applied manually, potentially delaying patching of critical Mosquitto vulnerabilities.
Mitigation Strategy: Run Mosquitto with Least Privileges (User Configuration)
-
Mitigation Strategy: Run Mosquitto with Least Privileges (User Configuration)
-
Description:
- Create Dedicated Mosquitto User: Create a dedicated system user account specifically for running the Mosquitto service (e.g.,
mosquitto_user
). - Configure User in
mosquitto.conf
: In themosquitto.conf
file, use theuser
andgroup
directives to specify the dedicated user and group under which Mosquitto should run. For example:These directives are Mosquitto configuration settings for process user management.user mosquitto_user group mosquitto_group
- Set File Permissions for Mosquitto User: Ensure that Mosquitto configuration files, log files, and any other files required by Mosquitto are owned by the dedicated user and group and have restricted permissions.
- Restart Mosquitto Service: Restart the Mosquitto service for the user configuration to take effect. Mosquitto will now run under the specified user account.
- Verify Mosquitto User: Verify that the Mosquitto process is running under the dedicated user account (e.g., using
ps aux | grep mosquitto
) to confirm the configuration is applied.
- Create Dedicated Mosquitto User: Create a dedicated system user account specifically for running the Mosquitto service (e.g.,
-
List of Threats Mitigated:
- Privilege Escalation after Mosquitto Compromise (Medium Severity): Limits the impact of a potential compromise of the Mosquitto process. If compromised, the attacker's access is limited to the privileges of the dedicated Mosquitto user, preventing broader system compromise.
- Lateral Movement from Compromised Mosquitto (Medium Severity): Restricts an attacker's ability to move to other parts of the system if the Mosquitto process is compromised, as the Mosquitto user will have limited system-wide permissions.
-
Impact:
- Privilege Escalation after Mosquitto Compromise: Medium reduction. Limits the potential damage from a compromised Mosquitto instance.
- Lateral Movement from Compromised Mosquitto: Medium reduction. Restricts attacker movement within the system originating from a Mosquitto compromise.
-
Currently Implemented: Yes, Mosquitto service is configured to run under a dedicated user
mosquitto
and groupmosquitto
. -
Missing Implementation: Further hardening of the dedicated Mosquitto user account, such as disabling login shell and restricting access to system resources beyond what Mosquitto absolutely requires, could be considered for enhanced security.
Mitigation Strategy: Secure Mosquitto Bridge Connections with TLS and Authentication
-
Mitigation Strategy: Secure Mosquitto Bridge Connections with TLS and Authentication
-
Description:
- Configure TLS for Bridge Connection in
mosquitto.conf
: When configuring a bridge inmosquitto.conf
, use thebridge_protocol mqttv311
(or appropriate MQTT version) and specify TLS related options within theconnection <bridge_name>
block. Mosquitto bridge configuration directives include:bridge_protocol mqttv311
: Specify MQTT protocol for bridge.bridge_tls_version tlsv1.2
: Enforce TLS version.bridge_certfile
,bridge_keyfile
,bridge_cafile
: Specify certificate files for TLS.bridge_insecure false
: Enforce certificate verification.
- Configure Authentication for Bridge Connection: Within the
connection <bridge_name>
block inmosquitto.conf
, configure authentication using Mosquitto bridge directives:bridge_username <username>
: Username for bridge authentication.bridge_password <password>
: Password for bridge authentication.
- Configure Remote Broker for Bridge Authentication and TLS: Ensure the remote Mosquitto broker (or other MQTT broker) is configured to require TLS and authenticate bridge connections using the credentials configured in the bridging broker.
- Restart Bridging Mosquitto Broker: Restart the Mosquitto broker acting as the bridge for the bridge configuration to take effect.
- Verify Secure Bridge Connection: Monitor the bridge connection to ensure it is established using TLS and authenticated successfully.
- Configure TLS for Bridge Connection in
-
List of Threats Mitigated:
- Eavesdropping on Bridge Traffic (High Severity): TLS encryption for bridge connections prevents eavesdropping on data exchanged between bridged Mosquitto brokers.
- Unauthorized Bridge Connection (High Severity): Authentication for bridge connections prevents unauthorized brokers from connecting and exchanging data, protecting against rogue bridge connections.
- Man-in-the-Middle Attacks on Bridge Connections (High Severity): TLS protects against MitM attacks on the communication channel between bridged brokers.
-
Impact:
- Eavesdropping on Bridge Traffic: High reduction. TLS encryption effectively secures bridge communication.
- Unauthorized Bridge Connection: High reduction. Authentication prevents unauthorized bridge establishment.
- Man-in-the-Middle Attacks on Bridge Connections: High reduction. TLS provides strong protection against MitM attacks on bridge links.
-
Currently Implemented: Not currently implemented as bridges are not used in the current production setup.
-
Missing Implementation: If bridges are implemented in the future, TLS and authentication for bridge connections should be a mandatory security requirement.
Mitigation Strategy: Secure Mosquitto Configuration Files
-
Mitigation Strategy: Secure Mosquitto Configuration Files
-
Description:
- Restrict File System Permissions: Set restrictive file system permissions on
mosquitto.conf
, password files (e.g.,mosquitto_users.pwd
), ACL files (e.g.,mosquitto.acl
), and certificate/key files. Ensure only the Mosquitto user and root (for administration) have read and write access. Usechmod
andchown
commands on Linux-based systems to achieve this. This is a standard system security practice applied to Mosquitto files. - Regularly Review Configuration Files: Periodically review the contents of
mosquitto.conf
, ACL files, and other configuration files to ensure they adhere to security best practices and that no unintended or insecure configurations have been introduced. - Implement Version Control for Configuration Files (Recommended): Use version control systems (like Git) to track changes to Mosquitto configuration files. This allows for auditing changes, reverting to previous configurations, and managing configuration drift.
- Secure Backup of Configuration Files: Implement secure backups of Mosquitto configuration files to ensure they can be restored in case of accidental deletion or corruption. Store backups in a secure location with restricted access.
- Restrict File System Permissions: Set restrictive file system permissions on
-
List of Threats Mitigated:
- Unauthorized Modification of Mosquitto Configuration (Medium Severity): Restricting file permissions prevents unauthorized users from modifying Mosquitto settings, which could lead to security bypasses or misconfigurations.
- Exposure of Sensitive Information in Configuration Files (Medium Severity): Secure file permissions and access control minimize the risk of sensitive information (like passwords or certificate keys, if improperly stored) in configuration files being exposed to unauthorized users.
- Configuration Drift and Undocumented Changes (Low Severity): Version control helps mitigate risks associated with configuration drift and undocumented changes, improving configuration management and security auditing.
-
Impact:
- Unauthorized Modification of Mosquitto Configuration: Medium reduction. File permissions significantly reduce the risk of unauthorized configuration changes.
- Exposure of Sensitive Information in Configuration Files: Medium reduction. Access control minimizes the risk of information leakage from configuration files.
- Configuration Drift and Undocumented Changes: Low reduction (but improves manageability and auditability). Version control improves configuration management practices.
-
Currently Implemented: Partially implemented. File permissions are set to restrict access to configuration files.
-
Missing Implementation: Version control for configuration files and formalized regular configuration review processes are missing. Secure, automated backups of configuration files are also not fully implemented.