Vulnerabilities in pkg:golang/github.com/nats-io/nkeys

PACKAGE
Advisory Identifier: GHSA-mr45-rx8q-wcm9
Advisory Summary

CVE-2023-46129 is a HIGH (CVSS 7.5) xkeys seal encryption used fixed vulnerability (CWE-321: Use of Hard-coded Cryptographic Key) affecting Github.com/nats io/nkeys libraries in the Go ecosystem. The issue involves xkeys seal encryption used fixed key for all encryption. Remediation is available by upgrading affected packages to version 0.4.6, 2.10.4.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:golang/github.com/nats-io/nkeys

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:golang/github.com/nats-io/nkeys. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-mr45-rx8q-wcm9 CVE-2023-46129 HIGH xkeys seal encryption used fixed key for all encryption

CVE-2023-46129 at a Glance

CVE Identifier CVE-2023-46129
GHSA Identifier GHSA-mr45-rx8q-wcm9
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-321: Use of Hard-coded Cryptographic Key
Affected Product Github.com/nats io/nkeys
Package Ecosystem Go
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2023-46129

To remediate this vulnerability, upgrade all affected Github.com/nats io/nkeys dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/nats-io/nkeys fixed: 0.4.6
Upgrade github.com/nats-io/nkeys to 0.4.6
github.com/nats-io/nats-server/v2 fixed: 2.10.4
Upgrade github.com/nats-io/nats-server/v2 to 2.10.4
Verify Direct and Transitive Dependencies

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/nkeys

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-46129, inspect your project dependencies for Github.com/nats io/nkeys:

inspect dependencies for github.com/nats-io/nkeys

Analyze the terminal output to locate any version of Github.com/nats io/nkeys in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.4.6), 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-321: Use of Hard-coded Cryptographic Key, where the product uses a hard-coded, unchangeable cryptographic key. In Github.com/nats io/nkeys, 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

## 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 cryptographic key handling library, nkeys, recently gained support for encryption, not just for signing/authentication. This is used in nats-server 2.10 (Sep 2023) and newer for authentication callouts. ## Problem Description The nkeys library's "xkeys" encryption handling logic mistakenly passed an array by value into an internal function, where the function mutated that buffer to populate the encryption key to use. As a result, all encryption was actually to an all-zeros key. This affects encryption only, not signing. FIXME: FILL IN IMPACT ON NATS-SERVER AUTH CALLOUT SECURITY. ## Affected versions nkeys Go library: * 0.4.0 up to and including 0.4.5 * Fixed with nats-io/nkeys: 0.4.6 NATS Server: * 2.10.0 up to and including 2.10.3 * Fixed with nats-io/nats-server: 2.10.4 ## Solution Upgrade the nats-server. For any application handling auth callouts in Go, if using the nkeys library, update the dependency, recompile and deploy that in lockstep. ## Credits Problem reported by Quentin Matillat (GitHub @tinou98).

CVE-2023-46129 Affected Github.com/nats io/nkeys Versions

2 component(s)
Fixed Versions:
0.4.62.10.4
Product / Package Ecosystem Affected Versions Fixed Version
github.com/nats-io/nkeys
Go
≥ 0.4.0
< 0.4.6
0.4.6
github.com/nats-io/nats-server/v2
Go
≥ 2.10.0
< 2.10.4
2.10.4

References

Frequently Asked Questions

What is CVE-2023-46129?
CVE-2023-46129 is a security vulnerability in Github.com/nats io/nkeys involving xkeys seal encryption used fixed key for all encryption under CWE-321: Use of Hard-coded Cryptographic Key.
Which Github.com/nats io/nkeys versions are affected?
Affected versions include releases prior to 0.4.6, 2.10.4 across affected packages: github.com/nats-io/nkeys, github.com/nats-io/nats-server/v2.
What version fixes CVE-2023-46129?
Upgrading to 0.4.6, 2.10.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/nats-io/nkeys affected?
Yes, github.com/nats-io/nkeys is affected in releases prior to 0.4.6. Upgrade your dependency to 0.4.6 or later.
Is github.com/nats-io/nats-server/v2 affected?
Yes, github.com/nats-io/nats-server/v2 is affected in releases prior to 2.10.4. Upgrade your dependency to 2.10.4 or later.
What is the CVSS score of CVE-2023-46129?
CVE-2023-46129 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2023-46129?
CVE-2023-46129 is classified under CWE-321: Use of Hard-coded Cryptographic Key (The product uses a hard-coded, unchangeable cryptographic key.).
How can I check Go dependencies for CVE-2023-46129?
Run the dependency tree command: 'inspect dependencies for github.com/nats-io/nkeys'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-mr45-rx8q-wcm9",
  "modified" : "2023-10-31T21:19:02Z",
  "published" : "2023-10-31T21:19:02Z",
  "aliases" : [ "CVE-2023-46129" ],
  "summary" : "xkeys seal encryption used fixed key for all encryption",
  "details" : "## Background\n\nNATS.io is a high performance open source pub-sub distributed communication technology, built for the cloud, on-premise, IoT, and edge computing.\n\nThe cryptographic key handling library, nkeys, recently gained support for encryption, not just for signing/authentication.  This is used in nats-server 2.10 (Sep 2023) and newer for authentication callouts.\n\n## Problem Description\n\nThe nkeys library's \"xkeys\" encryption handling logic mistakenly passed an array by value into an internal function, where the function mutated that buffer to populate the encryption key to use.  As a result, all encryption was actually to an all-zeros key.\n\nThis affects encryption only, not signing.  \nFIXME: FILL IN IMPACT ON NATS-SERVER AUTH CALLOUT SECURITY.\n\n## Affected versions\n\nnkeys Go library:\n * 0.4.0 up to and including 0.4.5\n * Fixed with nats-io/nkeys: 0.4.6\n\nNATS Server:\n * 2.10.0 up to and including 2.10.3\n * Fixed with nats-io/nats-server: 2.10.4\n\n## Solution\n\nUpgrade the nats-server.  \nFor any application handling auth callouts in Go, if using the nkeys library, update the dependency, recompile and deploy that in lockstep.\n\n## Credits\n\nProblem reported by Quentin Matillat (GitHub @tinou98).",
  "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/nkeys"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.4.0"
      }, {
        "fixed" : "0.4.6"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.4.5"
    }
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/nats-io/nats-server/v2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.10.0"
      }, {
        "fixed" : "2.10.4"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.10.3"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nats-io/nkeys/security/advisories/GHSA-mr45-rx8q-wcm9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-46129"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nats-io/nkeys/commit/58fb9d69f42ea73fffad1d14e5914dc666f3daa1"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/nats-io/nkeys"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/R3UETKPUB3V5JS5TLZOF3SMTGT5K5APS"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ULQQONMSCQSH5Z5OWFFQHCGEZ3NL4DRJ"
  }, {
    "type" : "WEB",
    "url" : "http://www.openwall.com/lists/oss-security/2023/10/31/1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-321", "CWE-325" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-10-31T21:19:02Z",
    "nvd_published_at" : "2023-10-31T00:15:09Z"
  }
}