GHSA-j756-f273-xhp4: Github.com/nats io/nats server/v2 Remote Code Execution Vulnerability
HIGHGHSA-j756-f273-xhp4 is a HIGH (CVSS 7.5) remote code execution vulnerability (CWE-755: Improper Handling of Exceptional Conditions) affecting Github.com/nats io/nats server/v2 libraries in the Go ecosystem. The issue involves github.com/nats-io/nats-server import token permissions checking not enforced. Remediation is available by upgrading affected packages to version 2.2.0.
GHSA-j756-f273-xhp4 at a Glance
Security Impact
CVSS: 7.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N).
How to Fix GHSA-j756-f273-xhp4
To remediate this vulnerability, upgrade all affected Github.com/nats io/nats server/v2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade github.com/nats-io/nats-server/v2 to 2.2.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for github.com/nats-io/nats-server/v2
How to Check if You Are Affected
To determine whether your application is affected by GHSA-j756-f273-xhp4, inspect your project dependencies for Github.com/nats io/nats server/v2:
inspect dependencies for github.com/nats-io/nats-server/v2
Analyze the terminal output to locate any version of Github.com/nats io/nats server/v2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.2.0), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-755: Improper Handling of Exceptional Conditions, where the product does not handle or incorrectly handles an exceptional condition. In Github.com/nats io/nats server/v2, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
GHSA-j756-f273-xhp4 Affected Github.com/nats io/nats server/v2 Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/nats-io/nats-server/v2
|
Go |
< 2.2.0
|
2.2.0
|
References
Frequently Asked Questions
What is GHSA-j756-f273-xhp4?
Which Github.com/nats io/nats server/v2 versions are affected?
What version fixes GHSA-j756-f273-xhp4?
Is github.com/nats-io/nats-server/v2 affected?
What is the CVSS score of GHSA-j756-f273-xhp4?
What CWE is associated with GHSA-j756-f273-xhp4?
How can I check Go dependencies for GHSA-j756-f273-xhp4?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-j756-f273-xhp4",
"modified" : "2024-05-21T15:22:51Z",
"published" : "2021-05-21T16:22:20Z",
"aliases" : [ ],
"summary" : "github.com/nats-io/nats-server Import token permissions checking not enforced",
"details" : "(This advisory is canonically <https://advisories.nats.io/CVE/CVE-2021-3127.txt>)\n\n## Problem Description\n\nThe 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.\n\nThe JWT library's validation of the bindings in the Import Token incorrectly warned on mismatches, instead of outright rejecting the token.\n\nAs 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.\n\nThe 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.\n\nThe 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.\n\n\n## Affected versions\n\n#### JWT library\n\n * all versions prior to 2.0.1\n * fixed after nats-io/jwt#149 landed (2021-03-14)\n\n#### NATS Server\n\n * Version 2 prior to 2.2.0\n + 2.0.0 through and including 2.1.9 are vulnerable\n * fixed with nats-io/nats-server@423b79440c (2021-03-14)\n\n\n## Impact\n\nIn 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.\n\nAbuse 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.\n\n\n## Workaround\n\nDeny access to clients to update their account JWT in the account server.\n\n\n## Solution\n\nUpgrade the JWT dependency in any application using it.\n\nUpgrade the NATS server if using NATS Accounts (with private Exports; Account owners can create those at any time though).\n\nAudit 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>.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/nats-io/nats-server/v2"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.2.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/nats-io/jwt/security/advisories/GHSA-62mh-w5cv-p88c"
}, {
"type" : "WEB",
"url" : "https://github.com/nats-io/nats-server/security/advisories/GHSA-j756-f273-xhp4"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-3127"
}, {
"type" : "WEB",
"url" : "https://github.com/nats-io/nats-server/commit/423b79440c80c863de9f4e20548504e6c5d5e403"
}, {
"type" : "WEB",
"url" : "https://advisories.nats.io/CVE/CVE-2021-3127.txt"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/nats-io/nats-server"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-755", "CWE-863" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2021-05-20T21:01:49Z",
"nvd_published_at" : null
}
}