豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

CocoaMQTT: Denial of Service via Reachable Assertion in `PUBLISH` Packet Parsing

Moderate severity GitHub Reviewed Published Apr 2, 2026 in emqx/CocoaMQTT • Updated Apr 3, 2026

Package

swift CocoaMQTT (Swift)

Affected versions

< 2.2.2

Patched versions

2.2.2

Description

A vulnerability exists in the packet parsing logic of CocoaMQTT that allows an attacker (or a compromised/malicious MQTT broker) to remotely crash the host iOS/macOS/tvOS application.

The vulnerability is located in Source/FramePublish.swift during the extraction of the Topic string from the incoming byte array.

When parsing the Variable Header of a PUBLISH frame, the library reads the first two bytes to determine the topicLength. It then adds this length to the current position (pos) and attempts to slice the byte array to extract the string:

if let data = NSString(bytes: [UInt8](bytes[2...(pos-1)]), length: Int(len), encoding: String.Encoding.utf8.rawValue) {
    topic = data as String
}

If a packet is received where the Topic Length evaluates to 0 (e.g., 0x00 0x00), the len variable becomes 0, and pos evaluates to 2.

The slicing logic dynamically calculates bytes[2...(2-1)], which becomes bytes[2...1]. Swift's ClosedRange operator (...) requires the lower bound to be less than or equal to the upper bound. Because 2 is not less than 1, Swift detects an out-of-bounds access attempt and immediately triggers a runtime trap (Fatal error: Range requires lowerBound <= upperBound), crashing the host application.

If an attacker publishes this 4-byte malformed payload to a shared topic with the RETAIN flag set to true, the MQTT broker will persist the payload. Any time a vulnerable client connects and subscribes to that topic, the broker will automatically push the malformed packet. The app will instantly crash in the background before the user can even interact with it. This effectively "bricks" the mobile application (a persistent DoS) until the retained message is manually wiped from the broker database.

References

@HJianBo HJianBo published to emqx/CocoaMQTT Apr 2, 2026
Published by the National Vulnerability Database Apr 2, 2026
Published to the GitHub Advisory Database Apr 3, 2026
Reviewed Apr 3, 2026
Last updated Apr 3, 2026

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
Required
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:N/A:H

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(14th percentile)

Weaknesses

Reachable Assertion

The product contains an assert() or similar statement that can be triggered by an attacker, which leads to an application exit or other behavior that is more severe than necessary. Learn more on MITRE.

CVE ID

CVE-2026-30867

GHSA ID

GHSA-r3fr-7m74-q7g2

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.