Skip to content
Back to skills

Mqtt Knowledge Patch

ASecurity

MQTT

  • 25 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 5, 2026
developmentgodebugging

Works with

  • cli

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill mqtt-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mqtt Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mqtt Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-mqtt-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-mqtt-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: mqtt-knowledge-patch
description: MQTT
version: "MQTT-SN 2.0 CSD01"
license: MIT
metadata:
  author: Nevaberry
---


# MQTT compatibility guidance

Load this skill when implementing, reviewing, or debugging MQTT and MQTT-SN
Clients, Servers, and Gateways. Use the references for packet fields, Session
behavior, publication delivery, subscriptions, authentication, and transport.

> [!CAUTION]
> MQTT-SN 2.0 CSD01 is a prerelease. Prerelease guidance may change before stable release.
> The MQTT-SN references preserve the draft's stated inconsistencies and qualifications.

## Reference index

| Reference | Topics |
| --- | --- |
| [MQTT-SN packet contracts](references/mqtt-sn-packets.md) | Migration, framing, identifiers, packet fields, encapsulation, Reason Code scopes |
| [MQTT-SN Sessions and topics](references/mqtt-sn-sessions-topics.md) | Virtual Connections, aliases, request limits, retries, delivery, Unicode, discovery |
| [MQTT-SN authentication, sleep, and protection](references/mqtt-sn-auth-sleep-protection.md) | Authentication methods, identity, DTLS, sleep and wake cycles, protection schemes |
| [MQTT 5 connections and publishing](references/mqtt5-connections-publishing.md) | Session State, Wills, disconnects, publication properties, expiry, QoS, send quota |
| [MQTT 5 subscriptions and operations](references/mqtt5-subscriptions-operations.md) | Subscription options and identifiers, shared delivery, request/reply, redirection, authentication, errors |
| [MQTT 5 wire format and transport](references/mqtt5-wire-format.md) | Variable Byte Integers, property encoding, compact acknowledgements, Reason Code scopes, SOCKSv5, WebSocket, conformance |

## MQTT-SN migration changes

### Will, sleep, and disconnect packets

> **Prerelease (`2.0-csd01`):** This guidance may change before stable release.

Carry the Will in `CONNECT` and drop the MQTT-SN 1.2 Will-message exchange.
Request sleep with `SLEEPREQ` and handle `SLEEPRESP`. `DISCONNECT` is now a
one-way notification.

### Native Topic Names and aliases

> **Prerelease (`2.0-csd01`):** This guidance may change before stable release.
> **Prerelease (`mqtt-sn-2.0-csd01-foundations`):** This guidance may change before stable release.

Native publish packets use a full Topic Name or a two-byte Topic Alias;
the native format removes the Short Topic Name. Topic Type `0b00` selects a
Session alias, `0b01` a Predefined alias, and `0b11` a Topic Name or Filter.
`0b10` is reserved. Session and Predefined aliases have separate pools.

### Packet Type assignments

> **Prerelease (`2.0-csd01`):** This guidance may change before stable release.

Read one Packet Type byte after Length. The assignments change from MQTT-SN
1.2, with `0x00` and `0x19`–`0xFC` reserved. Use the complete registry in
[packet contracts](references/mqtt-sn-packets.md#packet-type-values).

## MQTT 5 connection and publication pitfalls

### Session Present and Will takeover

A Client with no local Session State that receives Session Present `1` MUST
close the Network Connection. If it receives Session Present `0` and
continues, it MUST discard old local Session State.

Resuming the same Session before Will Delay expires suppresses the old
connection's Will. A stored Will is published when the old connection closes
with zero delay or the old Session ends, including takeover with Clean Start
`1` or an old Session Expiry Interval of zero.

### Invalid Session Expiry changes

If `CONNECT` used a zero Session Expiry Interval, a Client `DISCONNECT`
setting a nonzero interval is a Protocol Error (`0x82`). Any stored Will
remains subject to publication even if that packet carried Reason Code `0x00`.

### Topic Alias errors and oversized publications

Alias zero or above Topic Alias Maximum uses `DISCONNECT` `0x94`.
An in-range alias without a mapping and with an empty Topic Name uses `0x82`.
If an outgoing publication exceeds the Client's Maximum Packet Size, the
Server MUST discard it and treat sending that Application Message as complete.

### Expiry and retransmission

The Server MUST drop a subscriber's copy if Message Expiry elapses before
onward delivery starts, and MUST subtract time spent waiting in the Server
when forwarding with a Message Expiry Interval.
Once the sender has sent QoS 2 `PUBLISH`, it MUST NOT apply Message Expiry to
the in-flight exchange; a receiver applying expiry MUST still complete its
QoS 2 acknowledgement sequence.

Both peers MUST resend unacknowledged QoS 1 and 2 `PUBLISH` and outstanding
`PUBREL` with their original identifiers only on reconnect with Clean Start
`0` and a present Session. A `PUBACK` or `PUBREC` of `0x80` or greater completes
the publication for retry purposes; sending `PUBREL` ends its `PUBLISH` retries.

### Subscription validation and replay

Setting No Local on a Shared Subscription is a Protocol Error. Nonzero
reserved bits 6 or 7 in Subscription Options are a Malformed Packet.
A Server advertising Maximum QoS `0` or `1` MUST still accept Requested QoS
`0`, `1`, and `2` in `SUBSCRIBE`.

Retained messages replayed on subscription establishment carry `RETAIN=1`
even with Retain As Published `0`; Retain Handling controls only that replay.
Joining a shared subscription skips retained replay even for its first member.

## MQTT-SN connections, aliases, and requests

### Packet Length and identifiers

> **Prerelease (`2.0-csd01`):** This guidance may change before stable release.

Clients and Servers MUST accept both Length encodings. An initial `0x01`
introduces a two-byte big-endian total length; any other first byte is the
total length. Native `PUBLISH` carries a Packet Identifier at QoS 1 or 2 and
MUST omit it at QoS 0. See the packet reference for encapsulation Length rules.

### Alias use and lifetime

> **Prerelease (`mqtt-sn-2.0-csd01-guidance`):** This guidance may change before stable release.

Either sender MUST use the mapped alias in `PUBLISH` when one exists.
Session alias mappings survive Virtual Connection replacement while the same
Session continues, subject to the `SLEEPREQ` alias retention flag.
Predefined mappings are shared by all Clients of a Server and stay fixed
for a Session's duration.

### Outstanding requests and retries

> **Prerelease (`mqtt-sn-2.0-csd01-guidance`):** This guidance may change before stable release.

Each endpoint MUST wait for acknowledgement before starting another listed
request: QoS 1 or 2 `PUBLISH`, `PUBREC`, `PUBREL`, `REGISTER`, `SUBSCRIBE`,
`UNSUBSCRIBE`, `PINGREQ`, `SLEEPREQ`, or `AUTH`. If another listed request
arrives from that peer with a different Packet Identifier while one is
outstanding, send `DISCONNECT` `0x93` and delete the Virtual Connection.

`CONNECT` and `AUTH` MUST NOT be retried. Other permitted retries, their
timers, the protection requirement, and the draft's identical-inner-packet
versus `DUP=1` requirements are in the Sessions and topics reference.

### Sessionless publication

> **Prerelease (`2.0-csd01`):** This guidance may change before stable release.
> **Prerelease (`mqtt-sn-2.0-csd01-guidance`):** This guidance may change before stable release.

Use `PUBWOS` (`0x12`) without a Session at the receiver and omit the Packet
Identifier. A receiver MAY accept ownership and MUST treat an accepted
message as QoS 0. It sends no response, and the sender performs no retry.

## Authentication, sleep, and protection

### MQTT 5 enhanced authentication

With Authentication Method in `CONNECT`, the Client MUST restrict subsequent
packets to `AUTH` or `DISCONNECT` until `CONNACK`. Both peers MUST repeat the
same method in every `AUTH` and any successful `CONNACK`.
Without enhanced authentication, a Client can pipeline control packets after
`CONNECT` before receiving `CONNACK`.

After successful `CONNACK`, the Client can start re-authentication with `AUTH`
`0x19` using the original method and continue ordinary traffic under the
previous authentication until Server `AUTH` `0x00` or failure. On failure the
endpoint MUST close the Network Connection and SHOULD first send `DISCONNECT`
with an appropriate Reason Code.

### MQTT-SN authentication establishment

> **Prerelease (`mqtt-sn-2.0-csd01`):** This guidance may change before stable release.

Wait for `CONNACK` `0x00` before sending traffic needing a Virtual Connection.
During establishment the Server MUST process only Client `AUTH` after
`CONNECT`. Server `AUTH` or `CONNACK` echoes the Packet Identifier of the
specific `CONNECT` or Client `AUTH` it answers.

### MQTT-SN re-authentication and credential methods

> **Prerelease (`mqtt-sn-2.0-csd01-guidance`):** This guidance may change before stable release.

After successful `CONNACK`, a Client that supplied an Authentication Method
can start re-authentication with `AUTH` `0x19` and MUST reuse that method.
Pause other packet flow. Exchange `AUTH` `0x18` while more data is needed;
finish on Server `AUTH` `0x00`. On failure the endpoint MUST send `DISCONNECT`
with an appropriate Reason Code and delete the Virtual Connection.
The authentication reference gives `MQTT-BASIC` and `MQTT-ENHANCED` field layouts.

### MQTT-SN sleep and wake cycles

> **Prerelease (`mqtt-sn-2.0-csd01`):** This guidance may change before stable release.
> **Prerelease (`mqtt-sn-2.0-csd01-guidance`):** This guidance may change before stable release.

`SLEEPREQ` bit 0 retains Session aliases; clearing it releases them.
A granted request suspends Keep Alive while retaining the Virtual Connection.
The Client can sleep without waiting for `SLEEPRESP` and uses `PINGREQ` to wake.
The Server MUST buffer QoS 1 and 2 messages while the Client sleeps; QoS 0
buffering is optional. Sending `PINGRESP` returns the Client to Asleep at the
Server and restarts the Sleep Duration timer.

### MQTT-SN packet protection

> **Prerelease (`mqtt-sn-2.0-csd01`):** This guidance may change before stable release.

An endpoint supporting Protection Encapsulation with the peer's shared key
MUST protect every MQTT-SN packet exchanged with that peer. The originator
applies protection. A Forwarder can wrap a protected packet; Forwarder
Encapsulation is prohibited inside Protection Encapsulation.
Use the protection reference for flags, scheme codes, counters, tags, and nonces.

## MQTT 5 framing and transport checks

Variable Byte Integers MUST use their shortest encoding, including Remaining
Length, Property Length, Property Identifiers, and Subscription Identifier
values. Invalid fixed-header flags or property placement/wire types make a
packet malformed (`0x81`). Use the wire-format reference for exact packet scopes.

For WebSocket, the Client MUST offer `mqtt` and the Server MUST select and
return it. Use binary data frames and close the Network Connection on other
data frame types. Parse binary data as a byte stream: a frame can contain
part of a Control Packet or several Control Packets. The URI is deployment-specific.

Files in this skill

  • SKILL.md8.9 KB
  • coverage.json1.1 KB
  • references/mqtt-sn-auth-sleep-protection.md6.5 KB
  • references/mqtt-sn-packets.md12.5 KB
  • references/mqtt-sn-sessions-topics.md9.1 KB
  • references/mqtt5-connections-publishing.md4.7 KB
  • references/mqtt5-subscriptions-operations.md5 KB
  • references/mqtt5-wire-format.md4.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.