Summary
Moquette contains an authorization bypass in the Last Will publication path. When anonymous access is enabled and topic ACLs restrict writes, a remote client may cause attacker-controlled messages to be published to a protected MQTT topic without write permission.
Affected context
The issue occurs in Moquette deployments that permit anonymous client access and use topic-level write ACLs. It affects Last Will handling during client connection and abnormal disconnection, where the broker's publication path may differ from the normal PUBLISH authorization flow.
Exploit preconditions
- Attack surface: Network-accessible MQTT broker
- Required access: Ability to connect as an anonymous or otherwise permitted MQTT client
- Trigger point: Setting a Last Will topic during CONNECT followed by an abnormal client disconnect
- Why exploitation is possible: The Last Will publication path can deliver client-controlled content without applying the authorization check used for ordinary publications
Why this happens
The vulnerability results from inconsistent authorization enforcement across MQTT message publication paths. The Last Will handler invokes subscriber delivery without performing the corresponding write-permission check, allowing a client to publish through a secondary broker workflow despite topic ACL restrictions. This maps to CWE-862: Missing Authorization, in which an operation is performed without verifying that the requester has the required permission.
Potential impact
- Unauthorized messages may be published to ACL-protected topics
- Applications consuming affected topics could receive forged or misleading data
- Monitoring, automation, or control workflows may be triggered unexpectedly
- Message integrity and tenant isolation could be weakened
General mitigation guidance
Mitigation generally focuses on applying authorization consistently to every message publication path, including Last Will processing.
Common defensive patterns include:
- Enforcing topic write authorization before publishing any Last Will message
- Centralizing publication checks so alternate delivery paths cannot bypass policy
- Disabling anonymous access unless it is explicitly required
- Using deny-by-default topic ACLs and narrowly scoped client permissions
- Separating broker identities and tenant namespaces to limit cross-client impact
- Treating client-provided Last Will topics as untrusted input
How teams detect issues like this
Organizations can assess this risk through:
- Static analysis for publication methods that bypass shared authorization routines
- Code review checks covering CONNECT, disconnect, retained-message, and Last Will paths
- Integration tests verifying that unauthorized clients cannot publish through alternate broker workflows
- Runtime policy monitoring for publishes to protected topics by clients lacking write permissions
- Automated security review tools that identify inconsistent access-control enforcement

