[CVE-2020-26521][CVE-2020-26892] NATS JWT vulnerabilities

Related Vulnerabilities: CVE-2020-26521   CVE-2020-26892  
                Folks,

The NATS project has a new advisories website:
  <https://advisories.nats.io/>

We also have two new CVEs; both relate to our JWT handling and both
affect the NATS server:

* CVE-2020-26521
  + Nil deref in JWT library, causing Go panic
  + NATS server upgrade required to avoid Denial-of-Service
  + 2020-11-02
* CVE-2020-26892
  + Incorrect credential expiration handling via JWT library
  + API fixes needed by library users
  + NATS server upgrade required for expiration to work
  + 2020-11-02

The text of our advisories should be attached.

We have just released NATS server 2.1.9 which includes the fixes for
both these issues.

Regards,
-Phil Pennock

Subject: Nil dereference in NATS JWT, DoS of nats-server

CVE: CVE-2020-26521

Background:

NATS.io is a high performance open source pub-sub distributed communication
technology, built for the cloud, on-premise, IoT, and edge computing.
The server is written in Go and there are client libraries in many languages
and frameworks.

The nats-io JWT library provides the handling for JWTs common to the NATS.io
projects.

Problem Description:

The NATS account system has an Operator trusted by the servers, which
signs Accounts, and each Account can then create and sign Users within
their account.  The Operator should be able to safely issue Accounts to
other entities which it does not fully trust.

A malicious Account could create and sign a User JWT with a state not
created by the normal tooling, such that decoding by the NATS JWT
library (written in Go) would attempt a nil dereference, aborting
execution.

The NATS Server is known to be impacted by this.

Affected versions:

JWT library:
 * all versions prior to 1.1.0

NATS Server:
 * Version 2 prior to 2.1.9

Impact:

JWT library:
 * Programs would nil dereference and panic, aborting execution by default.

NATS server:
 * Denial of Service caused by process termination

Workaround:

If your NATS servers do not trust any accounts which are managed by
untrusted entities, then malformed User credentials are unlikely to be
encountered.

Solution:

Upgrade the JWT dependency in any application using it.

Upgrade the NATS server if using NATS Accounts.

Subject: Incorrect handling of credential expiry by NATS Server

CVE: CVE-2020-26892

Background:

NATS.io is a high performance open source pub-sub distributed communication
technology, built for the cloud, on-premise, IoT, and edge computing.
The server is written in Go and there are client libraries in many languages
and frameworks.

The nats-io JWT library provides the handling for JWTs common to the NATS.io
projects.

Problem Description:

NATS nats-server through 2020-10-07 has Incorrect Access Control because of how
expired credentials are handled.

The NATS accounts system has expiration timestamps on credentials; the
<https://github.com/nats-io/jwt> library had an API which encouraged misuse and
an IsRevoked() method which misused its own API.

A new IsClaimRevoked() method has correct handling and the nats-server has been
updated to use this.  The old IsRevoked() method now always returns true and
other client code will have to be updated to avoid calling it.

The CVE identifier should cover any application using the old JWT API, where
the nats-server is one of those applications.

Affected versions:

JWT library:
 * all versions prior to 1.1.0
 * fixed after nats-io/jwt PR 103 landed (2020-10-06)

NATS Server:
 * Version 2 prior to 2.1.9
   + 2.0.0 through and including 2.1.8 are vulnerable.
 * fixed with nats-io/nats-server PRs 1632, 1635, 1645

Impact:

Time-based credential expiry did not work.

Workaround:

Have credentials which only expire after fixes can be deployed.

Solution:

Upgrade the JWT dependency in any application using it.

Upgrade the NATS server if using NATS Accounts.