microsoft / microsoft/rust-mqtt-client
Enhanced authentication does not enforce Authentication Method continuity
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3
- Forks
- 3
- Avg merge
- 7d 8h
- Merged PRs (30d)
- 4
Description
Description
The client supports MQTT 5 enhanced authentication but does not validate that the Authentication Method remains identical to the method sent in CONNECT.
During the initial exchange, connect_enhanced_auth retains the configured method for its own outgoing packets, but accepts incoming AUTH and successful CONNACK packets without comparing their Authentication Method to it:
During post-connect re-authentication, Session::incoming_auth instead copies the method supplied by the server into ReauthToken:
continue_reauth then sends that peer-supplied method back, allowing a server to switch the exchange to a different method:
Reproduction
Initial authentication:
- Call
connect_enhanced_authwith Authentication Methodmethod-a. - Have the server send AUTH with reason Continue Authentication and Authentication Method
method-b, or send a successful CONNACK with a missing/different method. - The client reports Continue/Success instead of a protocol failure.
Re-authentication:
- Establish a connection using
method-aand initiate re-authentication. - Have the server reply with Continue Authentication using
method-b. - Continue through the returned token; the client sends
method-bback.
Expected behavior
Retain the Authentication Method established by CONNECT for the lifetime of the network connection. Every incoming AUTH and every successful CONNACK in the initial exchange must contain that exact method. Missing or mismatched methods must be treated as a Protocol Error rather than accepted or echoed.
MQTT 5.0 requirements:
- [MQTT-4.12.0-5]: when CONNECT contains an Authentication Method, all AUTH packets and any successful CONNACK must contain the same value.
- [MQTT-4.12.0-6]: when CONNECT omits it, the server must not send AUTH or an Authentication Method in CONNACK.
- [MQTT-4.12.1-1]: re-authentication must use the method originally used for the network connection.
Specification: https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html
Audited revision
e2df553b4ee0bc7f2d7b45175ef9bfe600a8424d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with connect_enhanced_auth in src/client.rs, then inspect Session::incoming_auth in src/client/session.rs and continue_reauth in src/client/token/reauth.rs. Compare incoming AUTH and successful CONNACK methods with the CONNECT method, including missing values, and verify re-authentication retains the original method and treats violations as protocol errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- authentication, networking, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100