# CVE-2025-66023: NanoMQ has Use-After-Free of malformed bridging message

> A malicious remote broker can trigger a use-after-free in NanoMQ's bridge client, causing a crash or potential code execution.

- **Severity:** Medium 6.9 (`CVSS:4.0/AV:N/AC:H/AT:P/PR:H/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:H`)
- **Exploited in the wild:** Not known
- **Login needed:** An administrator
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** No
- **Published:** 1 Jan 2026
- **Updated:** 5 Jan 2026
- **Also known as:** GHSA-24f7-q5hh-27hf

## What is CVE-2025-66023?

CVE-2025-66023 is a medium-severity use after free vulnerability in nanomq, published on 1 Jan 2026. An attacker needs administrator access to exploit it, with no action from the victim.

### Official description

NanoMQ MQTT Broker (NanoMQ) is an all-around Edge Messaging Platform. Versions prior to 0.24.5 have a Heap-Use-After-Free (UAF) vulnerability within the MQTT bridge client component (implemented via the underlying NanoNNG library). The vulnerability is triggered when NanoMQ acts as a bridge connecting to a remote MQTT broker. A malicious remote broker can trigger a crash (Denial of Service) or potential memory corruption by accepting the connection and immediately sending a malformed packet sequence. Version 0.34.5 contains a patch. The patch enforces stricter protocol adherence in the MQTT client SDK embedded in NanoMQ. Specifically, it ensures that CONNACK is always the first packet processed in the line. This prevents the state confusion that led to the Heap-Use-After-Free (UAF) when a malicious server sent a malformed packet sequence immediately after connection establishment. As a workaround, validate the remote broker before bridging.

Weakness: CWE-416 (Use After Free)

## Which versions are affected by CVE-2025-66023?

It affects 1 product.


Products: Emqx Nanomq.

## How do I fix CVE-2025-66023?

No fix has been published for CVE-2025-66023 yet. Limit exposure of the affected software until one is available.

## Is CVE-2025-66023 being exploited?

There is no known exploitation of CVE-2025-66023 in the wild and no public exploit code.

## Other vulnerabilities in nanomq

- [CVE-2024-42655](https://insights.sbomify.com/CVE-2024-42655/): Missing authorization in n/a (high 8.8)
- [CVE-2025-59947](https://insights.sbomify.com/CVE-2025-59947/): NanoMQ has Buffer Overflow (high 8.5)
- [CVE-2023-34488](https://insights.sbomify.com/CVE-2023-34488/): Memory corruption in n/a (high 8.0)
- [CVE-2026-32135](https://insights.sbomify.com/CVE-2026-32135/): NanoMQ has Heap Buffer Overflow in URI Parameter Parsing (high 7.7)
- [CVE-2026-36590](https://insights.sbomify.com/CVE-2026-36590/): Denial of service in n/a (high 7.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-66023 and fix it if it is affected.

What it is: CVE-2025-66023 is a medium-severity use after free vulnerability in nanomq, published on 1 Jan 2026. An attacker needs administrator access to exploit it, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2025-66023 in the wild and no public exploit code.

Affected product: nanomq. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2025-66023/ (Markdown: https://insights.sbomify.com/CVE-2025-66023/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2025-66023
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-66023
- OSV: https://osv.dev/vulnerability/CVE-2025-66023

---
From sbomify Insights: https://insights.sbomify.com/CVE-2025-66023/
Summaries are generated and may contain mistakes; the official description above is the record.
