CVE-2021-3127: High severity NATS JWT library vulnerability

Published Mar 16, 2021
·
Updated

(This advisory is canonically <https://advisories.nats.io/CVE/CVE-2021-3127.txt>)

Problem Description

The NATS server provides for Subjects which are namespaced by Account; all Subjects are supposed to be private to an account, with an Export/Import system used to grant cross-account access to some Subjects. Some Exports are public, such that anyone can import the relevant subjects, and some Exports are private, such that the Import requires a token JWT to prove permission.

The JWT library's validation of the bindings in the Import Token incorrectly warned on mismatches, instead of outright rejecting the token.

As a result, any account can take an Import token used by any other account and re-use it for themselves because the binding to the importing account is not rejected, and use it to import any Subject from the Exporting account, not just the Subject referenced in the Import Token.

The NATS account-server system treats account JWTs as semi-public information, such that an attacker can easily enumerate all account JWTs and retrieve all Import Tokens from those account JWTs.

The CVE identifier should cover the JWT library repair and the nats-server containing the fixed JWT library, and any other application depending upon the fixed JWT library.

Affected versions

JWT library

all versions prior to 2.0.1 fixed after nats-io/jwt#149 landed (2021-03-14)

NATS Server

Version 2 prior to 2.2.0 + 2.0.0 through and including 2.1.9 are vulnerable fixed with nats-io/nats-server@423b79440c (2021-03-14)

Impact

In deployments with untrusted accounts able to update the Account Server with imports, a malicious account can access any Subject from an account which provides Exported Subjects.

Abuse of this facility requires the malicious actor to upload their tampered Account JWT to the Account Server, providing the service operator with a data-store which can be scanned for signs of abuse.

Workaround

Deny access to clients to update their account JWT in the account server.

Solution

Upgrade the JWT dependency in any application using it.

Upgrade the NATS server if using NATS Accounts (with private Exports; Account owners can create those at any time though).

Audit all accounts JWTs to scan for exploit attempts; a Python script to audit the accounts can be found at <https://gist.github.com/philpennock/09d49524ad98043ff11d8a40c2bb0d5a>.

Other sources

Duplicate Advisory This advisory has been withdrawn because it is a duplicate of GHSA-62mh-w5cv-p88c (for github.com/nats-io/jwt) and GHSA-j756-f273-xhp4 (for github.com/nats-io/nats-server). This link is maintained to preserve external references.

Original Description NATS Server (github.com/nats-io/nats-server/v2/server) 2.x before 2.2.0 and JWT library (github.com/nats-io/jwt/v2) before 2.0.1 have Incorrect Access Control because Import Token bindings are mishandled.

GitHub

NATS Server 2.x before 2.2.0 and JWT library before 2.0.1 have Incorrect Access Control because Import Token bindings are mishandled.

Affected Software

7 affected componentsFixes available
go/github.com/nats-io/jwt<1.2.3-0.20210314221642-a826c77dc9d2
1.2.3-0.20210314221642-a826c77dc9d2
go/github.com/nats-io/nats-server/v2<2.2.0
2.2.0
go/github.com/nats-io/jwt/v2<2.0.1
2.0.1
go/github.com/nats-io/jwt<=1.2.2
NATS JWT library<2.0.1
NATS NATS Server>=2.0.0<2.2.0
linuxfoundation Nats-server>=2.0.0<2.2.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade go/github.com/nats-io/jwt to a version that resolves this vulnerability.

    Fixed in 1.2.3-0.20210314221642-a826c77dc9d2
  2. Upgrade

    Upgrade go/github.com/nats-io/nats-server/v2 to a version that resolves this vulnerability.

    Fixed in 2.2.0
  3. Upgrade

    Upgrade go/github.com/nats-io/jwt/v2 to a version that resolves this vulnerability.

    Fixed in 2.0.1
  4. Upgrade

    Upgrade nats-io/jwt/v2 to a version that resolves this vulnerability.

    Fixed in 2.0.1
  5. Upgrade

    Upgrade nats-io/nats-server/v2/server to a version that resolves this vulnerability.

    Fixed in 2.2.0
  6. Configuration

    Deny access to clients to update their account JWT in the account server.

    NATS Account Server allow_update_account_jwt_from_client = deny
  7. Compensating control

    Audit all accounts JWTs to scan for exploit attempts (a Python script is referenced in the advisory text).

Event History

Mar 16, 2021
CVE Published
via MITRE·07:55 PM
Data Sourced
via MITRE·07:55 PM
Description
Data Sourced
via NVD·08:15 PM
DescriptionSeverityWeaknessAffected Software
Feb 15, 2022
Advisory Published
via GitHub·12:42 AM
May 21, 2024
Withdrawn
via GitHub·02:35 PM

Frequently Asked Questions

1

What is CVE-2021-3127?

CVE-2021-3127 is a vulnerability in NATS Server and JWT library that allows incorrect access control due to mishandling of Import Token bindings.

2

What is the severity of CVE-2021-3127?

CVE-2021-3127 has a severity rating of 7.5 (high).

3

Which software is affected by CVE-2021-3127?

CVE-2021-3127 affects NATS Server (github.com/nats-io/nats-server/v2/server) versions before 2.2.0 and JWT library (github.com/nats-io/jwt/v2) versions before 2.0.1.

4

How can I fix CVE-2021-3127?

To fix CVE-2021-3127, update NATS Server to version 2.2.0 and update the JWT library to version 2.0.1.

5

Where can I find more information about CVE-2021-3127?

You can find more information about CVE-2021-3127 in the references provided: [link1](https://nvd.nist.gov/vuln/detail/CVE-2021-3127), [link2](https://github.com/nats-io/jwt/pull/149/commits/a826c77dc9d2671c961b75ceefdb439c41029866), [link3](https://github.com/nats-io/nats-server/commit/423b79440c80c863de9f4e20548504e6c5d5e403).

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203