CVE-2022-25345: @discordjs/opus Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-rvgf-69j7-xh78
CVSS 7.5
CWE-908
Published
Advisory Summary

CVE-2022-25345 is a HIGH (CVSS 7.5) remote code execution vulnerability (CWE-908: Use of Uninitialized Resource) affecting @discordjs/opus libraries in the npm ecosystem. The issue involves uncontrolled resource consumption in @discordjs/opus. Remediation is available by upgrading affected packages to version 0.8.0.

CVE-2022-25345 at a Glance

CVE Identifier CVE-2022-25345
GHSA Identifier GHSA-rvgf-69j7-xh78
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-908: Use of Uninitialized Resource
Affected Product @discordjs/opus
Package Ecosystem npm
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:N/I:N/A:H).

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 None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2022-25345

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

@discordjs/opus fixed: 0.8.0
npm install @discordjs/opus@0.8.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @discordjs/opus

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2022-25345, inspect your project dependencies using npm:

npm ls @discordjs/opus

Analyze the terminal output to locate any version of @discordjs/opus in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.8.0), your application is affected.

Note: The npm ls @discordjs/opus command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-908: Use of Uninitialized Resource, where the product uses or accesses a resource that has not been initialized. In @discordjs/opus, 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

Improperly handled errors in @discordjs/opus cause hard crashes instead of returning the error to user land. All versions of package @discordjs/opus (<= 0.7.0) are vulnerable to Denial of Service (DoS) when trying to encode using an encoder with zero channels, or a non-initialized buffer. This leads to a hard crash due to improperly returning the errors from the invalid inputs. As of version 0.8.0, the errors are correctly returned to the user and are no longer throwing hard crashes that cannot be recovered.

CVE-2022-25345 Affected @discordjs/opus Versions

1 component(s)
Fixed Versions:
0.8.0
Product / Package Ecosystem Affected Versions Fixed Version
@discordjs/opus
npm
< 0.8.0
0.8.0

References

Frequently Asked Questions

What is CVE-2022-25345?
CVE-2022-25345 is a security vulnerability in @discordjs/opus involving Uncontrolled Resource Consumption in @discordjs/opus under CWE-908: Use of Uninitialized Resource.
Which @discordjs/opus versions are affected?
Affected versions include releases prior to 0.8.0 across affected packages: @discordjs/opus.
What version fixes CVE-2022-25345?
Upgrading to 0.8.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @discordjs/opus affected?
Yes, @discordjs/opus is affected in releases prior to 0.8.0. Upgrade your dependency to 0.8.0 or later.
What is the CVSS score of CVE-2022-25345?
CVE-2022-25345 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:N/I:N/A:H.
What CWE is associated with CVE-2022-25345?
CVE-2022-25345 is classified under CWE-908: Use of Uninitialized Resource (The product uses or accesses a resource that has not been initialized.).
How can I check npm dependencies for CVE-2022-25345?
Run the dependency tree command: 'npm ls @discordjs/opus'. 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-rvgf-69j7-xh78",
  "modified" : "2023-09-07T18:48:21Z",
  "published" : "2022-06-18T00:00:20Z",
  "aliases" : [ "CVE-2022-25345" ],
  "summary" : "Uncontrolled Resource Consumption in @discordjs/opus",
  "details" : "Improperly handled errors in @discordjs/opus cause hard crashes instead of returning the error to user land. All versions of package @discordjs/opus (<= 0.7.0) are vulnerable to Denial of Service (DoS) when trying to encode using an encoder with zero channels, or a non-initialized buffer. This leads to a hard crash due to improperly returning the errors from the invalid inputs.\n\nAs of version 0.8.0, the errors are correctly returned to the user and are no longer throwing hard crashes that cannot be recovered.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@discordjs/opus"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.8.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-25345"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/discordjs/opus/commit/406249f3fca484a2af97a34ceb989019efa09bc7"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/discordjs/opus"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/discordjs/opus/blob/3ca4341ffdd81cf83cec57045e59e228e6017590/src/node-opus.cc#L28"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/discordjs/opus/releases/tag/v0.8.0"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JS-DISCORDJSOPUS-2403100"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-908" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-06-20T22:30:01Z",
    "nvd_published_at" : "2022-06-17T20:15:00Z"
  }
}