Rust advisories / nats
Vulnerability MediumRUSTSEC-2023-0029 · nats
RUSTSEC-2023-0029: TLS certificate common name validation bypass
Short answerA security vulnerability in the nats crate: TLS certificate common name validation bypass. GitHub rates it Medium. Fixed in 0.24.1: update to a fixed version.
| Crate | nats |
|---|---|
| Type | Vulnerability (crypto-failure) |
| Affected versions | From 0.9.0 before 0.24.1. |
| Fixed in | 0.24.1 |
| Severity | Medium (GitHub rating) |
| Published | 2023-03-24 |
| Last changed | 2023-11-08 |
| Also known as | GHSA-wvc4-j7g5-4f79 |
What to do
- See which version you have:
cargo tree -i nats(it also shows which of your dependencies pulls it in). - Update within your version requirement:
cargo update -p nats. If the fix is a newer major or minor than your requirement allows, raise it in Cargo.toml (for examplenats = "0.24.1") or update the dependency that pulls it in. - Check again with
cargo audit, or paste your Cargo.lock into our Cargo.toml checker.
Details from the advisory
The NATS official Rust clients are vulnerable to MitM when using TLS.
The common name of the server's TLS certificate is validated against the hostname provided by the server's plaintext INFO message during the initial connection setup phase. A MitM proxy can tamper with the host field's value by substituting it with the common name of a valid certificate it controls, fooling the client into accepting it.
Reproduction steps
1. The NATS Rust client tries to establish a new connection 2. The connection is intercepted by a MitM proxy 3. The proxy makes a separate connection to the NATS server 4. The NATS server replies with an INFO message 5. The proxy reads the INFO, alters the host JSON field and passes the tampered INFO back to the client 6. The proxy upgrades the client connection to TLS, presenting a certificate issued by a certificate authority present in the client's keychain. In the previous step the host was set to the common name of said certificate 7. rustls accepts the certificate, having verified that the common name matches the attacker-controlled value it was given 9. The client has been fooled by the MitM proxy into accepting the attacker-controlled certificate
References
- Package: crates.io/crates/nats
- Advisory: rustsec.org/advisories/RUSTSEC-2023-0029.html
From the RustSec Advisory Database (CC0-1.0) via the OSV export, downloaded Oct 24, 2026. Severity score computed from the published CVSS vector.
Up next
Are you affected?Check your whole dependency treePaste Cargo.lock: every advisory, for your exact versions.Read it next →Also worth your time
Did this answer your question?