# GHSA-prmc-5v5w-c465: Client TLS credentials sent raw to server in npm package nats

> NATS Node.js client leaks TLS private keys to the server during connection, exposing credentials if mutual TLS is used with untrusted servers.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 6 Apr 2021

## What is GHSA-prmc-5v5w-c465?

GHSA-prmc-5v5w-c465 is a vulnerability in nats, published on 6 Apr 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Nats is a Node.js client for the NATS messaging system.

## Problem Description

_Preview versions_ of two NPM packages and one Deno package from the NATS project contain an information disclosure flaw, leaking options to the NATS server; for one package, this includes TLS private credentials.

The _connection_ configuration options in these JavaScript-based implementations were fully serialized and sent to the server in the client's `CONNECT` message, immediately after TLS establishment.

The nats.js client supports Mutual TLS and the credentials for the TLS client key are included in the connection configuration options; disclosure of the client's TLS private key to the server has been observed.

Most authentication mechanisms are handled after connection, instead of as part of connection, so other authentication mechanisms are unaffected.
For clarity: NATS account NKey authentication **is NOT affected**.

Neither the nats.ws nor the nats.deno clients support Mutual TLS: the affected versions listed below are those where the logic flaw is
present.  We are including the nats.ws and nats.deno versions out of an abundance of caution, as library maintainers, but rate as minimal the likelihood of applications leaking sensitive data.

## Affected versions

### Security impact

* NPM package nats.js:
  + **mainline is unaffected**
  + beta branch is vulnerable from 2.0.0-201, fixed in 2.0.0-209

### Logic flaw

* NPM package nats.ws:
  + status: preview
  + flawed from 1.0.0-85, fixed in 1.0.0-111

* Deno repository https://github.com/nats-io/nats.deno
  + status: preview
  + flawed in all git tags prior to fix
  + fixed with git tag v1.0.0-9

## Impact

For deployments using TLS client certificates (for mutual TLS), private key material for TLS is leaked from the client application to the
server.  If the server is untrusted (run by a third party), or if the client application also disables TLS verification (and so the true identity of the server is unverifiable) then authentication credentials are leaked.

## Workaround

*None*

## Solution

Upgrade your package dependencies to fixed versions, and then reissue any TLS client credentials (with new keys, not just new certificates) and revoke the old ones.

## Which versions are affected by GHSA-prmc-5v5w-c465?

2 open source packages ship an affected version, including nats.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `nats` | npm | From 2.0.0-201 | 2.0.0-209 |
| `nats` | npm | From 2.0.0-201 | 2.0.0-209 |

## How do I fix GHSA-prmc-5v5w-c465?

Upgrade nats to 2.0.0-209 or later.

## Is GHSA-prmc-5v5w-c465 being exploited?

There is no known exploitation of GHSA-prmc-5v5w-c465 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-prmc-5v5w-c465 and fix it if it is affected.

What it is: GHSA-prmc-5v5w-c465 is a vulnerability in nats, published on 6 Apr 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-prmc-5v5w-c465 in the wild and no public exploit code.

Affected packages and fixed versions:
- nats (npm): affected from 2.0.0-201; fixed in 2.0.0-209
- nats (npm): affected from 2.0.0-201; fixed in 2.0.0-209

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/GHSA-prmc-5v5w-c465/ (Markdown: https://insights.sbomify.com/GHSA-prmc-5v5w-c465/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-prmc-5v5w-c465

---
From sbomify Insights: https://insights.sbomify.com/GHSA-prmc-5v5w-c465/
Summaries are generated and may contain mistakes; the official description above is the record.
