Summary
In Eclipse Mosquitto 2.1.0 through 2.1.2, the mosquitto_ctrl utility can crash when a broker responds with an error value that is not a string. A malicious or compromised broker may therefore cause a denial of service when a user runs the utility against it.
Affected context
The issue occurs in mosquitto_ctrl when it processes a broker response containing an error field of an unexpected type. It is relevant when the utility interacts with a hostile or compromised broker; the reported affected versions are Eclipse Mosquitto 2.1.0 through 2.1.2.
Exploit preconditions
- Attack surface: Broker responses processed by
mosquitto_ctrl - Required access: The attacker must be able to operate or influence a broker that the utility connects to; the user must run the utility against that broker
- Trigger point: Processing a response where the
errorvalue is not a string - Why exploitation is possible: The response value is not handled safely when it differs from the expected type, which can cause the utility to crash
Why this happens
The utility does not safely handle an unexpected type in broker-provided data. This is an input validation weakness (CWE-20); depending on the code path, unsafe handling may also result in a null pointer dereference (CWE-476). The underlying pattern is relying on an external response to match an expected structure or type without robust checks and failure handling.
Potential impact
mosquitto_ctrlmay terminate unexpectedly- A user may be unable to complete the requested control operation
- Repeated interactions with a hostile broker could disrupt workflows that depend on the utility
General mitigation guidance
Defensive patterns include validating broker response structure and field types before use, and handling malformed responses with controlled errors rather than unsafe assumptions. Treat broker-provided data as untrusted, keep parsing and validation boundaries explicit, and ensure failure paths cannot crash the utility. Limit broker access to trusted endpoints and apply least privilege to processes that use the utility.
How teams detect issues like this
- Review response-parsing code for assumptions about field presence, type, and nullability
- Use static analysis to identify unchecked external data and unsafe dereferences
- Add tests for malformed responses, including fields with unexpected types
- Apply protocol and input-validation policies consistently to data received from brokers
Automated code review tools may help flag unchecked parsing and error-handling patterns.

