Vulnerabilities in pkg:golang/github.com/nats-io/jwt/v2
PACKAGECVE-2021-3127 is a CRITICAL nats-io/jwt not enforcing checking of vulnerability (CWE-863: Incorrect Authorization) affecting Github.com/nats io/jwt libraries in the Go ecosystem. The issue involves nats-io/jwt not enforcing checking of import token permissions. Remediation is available by upgrading affected packages to version 2.0.1.
pkg:golang/github.com/nats-io/jwt/v2
Vulnerability advisories affecting package pkg:golang/github.com/nats-io/jwt/v2. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-62mh-w5cv-p88c | CVE-2021-3127 | CRITICAL | nats-io/jwt not enforcing checking of Import token permissions |
| GHSA-9r5x-fjv3-q6h4 | - | HIGH | Duplicate Advisory: Incorrect Access Control in github.com/nats-io/jwt and github.com/nats-io/nats-server/v2 |
CVE-2021-3127 at a Glance
How to Fix CVE-2021-3127
To remediate this vulnerability, upgrade all affected Github.com/nats io/jwt 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/jwt to Latest secure release
Upgrade github.com/nats-io/jwt/v2 to 2.0.1
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/jwt
How to Check if You Are Affected
To determine whether your application is affected by CVE-2021-3127, inspect your project dependencies for Github.com/nats io/jwt:
inspect dependencies for github.com/nats-io/jwt
Analyze the terminal output to locate any version of Github.com/nats io/jwt in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0.1), 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-863: Incorrect Authorization, where the product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. In Github.com/nats io/jwt, 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
CVE-2021-3127 Affected Github.com/nats io/jwt Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/nats-io/jwt
|
Go |
≤ 1.2.2
|
|
|
github.com/nats-io/jwt/v2
|
Go |
< 2.0.1
|
2.0.1
|
References
Frequently Asked Questions
What is CVE-2021-3127?
Which Github.com/nats io/jwt versions are affected?
What version fixes CVE-2021-3127?
Is github.com/nats-io/jwt affected?
Is github.com/nats-io/jwt/v2 affected?
What CWE is associated with CVE-2021-3127?
How can I check Go dependencies for CVE-2021-3127?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-62mh-w5cv-p88c",
"modified" : "2024-05-21T15:22:54Z",
"published" : "2022-02-15T00:42:28Z",
"aliases" : [ "CVE-2021-3127" ],
"summary" : "nats-io/jwt not enforcing checking of Import token permissions",
"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\nrelevant 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\nimporting 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" : [ ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/nats-io/jwt"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "1.2.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/nats-io/jwt/v2"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.0.1"
} ]
} ]
} ],
"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" : "WEB",
"url" : "https://github.com/nats-io/jwt/pull/149"
}, {
"type" : "WEB",
"url" : "https://github.com/nats-io/jwt/commit/6c72fdd73e82fa9ebb151d84773baf4e9164c4ab"
}, {
"type" : "WEB",
"url" : "https://advisories.nats.io/CVE/CVE-2021-3127.txt"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/nats-io/jwt"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-863" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2021-05-20T20:58:15Z",
"nvd_published_at" : null
}
}