CVE-2022-21676: Engine.io Uncaught Exception Vulnerability

HIGH
Advisory Identifier: GHSA-273r-mgr4-v34f
CVSS 7.5
CWE-755 CWE-754
Published
Advisory Summary

CVE-2022-21676 is a HIGH (CVSS 7.5) uncaught exception vulnerability (CWE-755: Improper Handling of Exceptional Conditions) affecting Engine.io libraries in the npm ecosystem. The issue involves uncaught exception in engine.io. Remediation is available by upgrading affected packages to version 4.1.2, 5.2.1, 6.1.1.

CVE-2022-21676 at a Glance

CVE Identifier CVE-2022-21676
GHSA Identifier GHSA-273r-mgr4-v34f
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-755: Improper Handling of Exceptional Conditions
Affected Product Engine.io
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-21676

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

engine.io fixed: 4.1.2
npm install engine.io@4.1.2
engine.io fixed: 5.2.1
npm install engine.io@5.2.1
engine.io fixed: 6.1.1
npm install engine.io@6.1.1
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 engine.io

How to Check if You Are Affected

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

npm ls engine.io

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

Note: The npm ls engine.io 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-755: Improper Handling of Exceptional Conditions, where the product does not handle or incorrectly handles an exceptional condition. In Engine.io, 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

### Impact A specially crafted HTTP request can trigger an uncaught exception on the Engine.IO server, thus killing the Node.js process. > RangeError: Invalid WebSocket frame: RSV2 and RSV3 must be clear > at Receiver.getInfo (/.../node_modules/ws/lib/receiver.js:176:14) > at Receiver.startLoop (/.../node_modules/ws/lib/receiver.js:136:22) > at Receiver._write (/.../node_modules/ws/lib/receiver.js:83:10) > at writeOrBuffer (internal/streams/writable.js:358:12) This impacts all the users of the [`engine.io`](https://www.npmjs.com/package/engine.io) package starting from version `4.0.0`, including those who uses depending packages like [`socket.io`](https://www.npmjs.com/package/socket.io). ### Patches A fix has been released for each major branch: | Version range | Fixed version | | --- | --- | | `engine.io@4.x.x` | `4.1.2` | | `engine.io@5.x.x` | `5.2.1` | | `engine.io@6.x.x` | `6.1.1` | Previous versions (`< 4.0.0`) are not impacted. For `socket.io` users: | Version range | `engine.io` version | Needs minor update? | | --- | --- | --- | | `socket.io@4.4.x` | `~6.1.0` | - | `socket.io@4.3.x` | `~6.0.0` | Please upgrade to `socket.io@4.4.x` | `socket.io@4.2.x` | `~5.2.0` | - | `socket.io@4.1.x` | `~5.1.1` | Please upgrade to `socket.io@4.4.x` | `socket.io@4.0.x` | `~5.0.0` | Please upgrade to `socket.io@4.4.x` | `socket.io@3.1.x` | `~4.1.0` | - | `socket.io@3.0.x` | `~4.0.0` | Please upgrade to `socket.io@3.1.x` or `socket.io@4.4.x` (see [here](https://socket.io/docs/v4/migrating-from-3-x-to-4-0/)) In most cases, running `npm audit fix` should be sufficient. You can also use `npm update engine.io --depth=9999`. ### Workarounds There is no known workaround except upgrading to a safe version. ### For more information If you have any questions or comments about this advisory: * Open an issue in [`engine.io`](https://github.com/socketio/engine.io) Thanks to Marcus Wejderot from Mevisio for the responsible disclosure.

CVE-2022-21676 Affected Engine.io Versions

3 component(s)
Fixed Versions:
4.1.25.2.16.1.1
Product / Package Ecosystem Affected Versions Fixed Version
engine.io
npm
≥ 4.0.0
< 4.1.2
4.1.2
engine.io
npm
≥ 5.0.0
< 5.2.1
5.2.1
engine.io
npm
≥ 6.0.0
< 6.1.1
6.1.1

References

Frequently Asked Questions

What is CVE-2022-21676?
CVE-2022-21676 is a security vulnerability in Engine.io involving Uncaught Exception in engine.io under CWE-755: Improper Handling of Exceptional Conditions.
Which Engine.io versions are affected?
Affected versions include releases prior to 4.1.2, 5.2.1, 6.1.1 across affected packages: engine.io.
What version fixes CVE-2022-21676?
Upgrading to 4.1.2, 5.2.1, 6.1.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is engine.io affected?
Yes, engine.io is affected in releases prior to 4.1.2, 5.2.1, 6.1.1. Upgrade your dependency to 4.1.2, 5.2.1, 6.1.1 or later.
What is the CVSS score of CVE-2022-21676?
CVE-2022-21676 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-21676?
CVE-2022-21676 is classified under CWE-755: Improper Handling of Exceptional Conditions (The product does not handle or incorrectly handles an exceptional condition.).
How can I check npm dependencies for CVE-2022-21676?
Run the dependency tree command: 'npm ls engine.io'. 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-273r-mgr4-v34f",
  "modified" : "2022-01-21T13:25:59Z",
  "published" : "2022-01-13T16:14:17Z",
  "aliases" : [ "CVE-2022-21676" ],
  "summary" : "Uncaught Exception in engine.io",
  "details" : "### Impact\n\nA specially crafted HTTP request can trigger an uncaught exception on the Engine.IO server, thus killing the Node.js process.\n\n> RangeError: Invalid WebSocket frame: RSV2 and RSV3 must be clear\n>   at Receiver.getInfo (/.../node_modules/ws/lib/receiver.js:176:14)\n>   at Receiver.startLoop (/.../node_modules/ws/lib/receiver.js:136:22)\n>   at Receiver._write (/.../node_modules/ws/lib/receiver.js:83:10)\n>   at writeOrBuffer (internal/streams/writable.js:358:12)\n\nThis impacts all the users of the [`engine.io`](https://www.npmjs.com/package/engine.io) package starting from version `4.0.0`, including those who uses depending packages like [`socket.io`](https://www.npmjs.com/package/socket.io).\n\n### Patches\n\nA fix has been released for each major branch:\n\n| Version range | Fixed version |\n| --- | --- |\n| `engine.io@4.x.x` | `4.1.2` |\n| `engine.io@5.x.x` | `5.2.1` |\n| `engine.io@6.x.x` | `6.1.1` |\n\nPrevious versions (`< 4.0.0`) are not impacted.\n\nFor `socket.io` users:\n\n| Version range | `engine.io` version | Needs minor update? |\n| --- | --- | --- |\n| `socket.io@4.4.x` | `~6.1.0` | -\n| `socket.io@4.3.x` | `~6.0.0` | Please upgrade to `socket.io@4.4.x`\n| `socket.io@4.2.x` | `~5.2.0` | -\n| `socket.io@4.1.x` | `~5.1.1` | Please upgrade to `socket.io@4.4.x`\n| `socket.io@4.0.x` | `~5.0.0` | Please upgrade to `socket.io@4.4.x`\n| `socket.io@3.1.x` | `~4.1.0` | -\n| `socket.io@3.0.x` | `~4.0.0` | Please upgrade to `socket.io@3.1.x` or `socket.io@4.4.x` (see [here](https://socket.io/docs/v4/migrating-from-3-x-to-4-0/))\n\nIn most cases, running `npm audit fix` should be sufficient. You can also use  `npm update engine.io --depth=9999`.\n\n### Workarounds\n\nThere is no known workaround except upgrading to a safe version.\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n* Open an issue in [`engine.io`](https://github.com/socketio/engine.io)\n\nThanks to Marcus Wejderot from Mevisio for the responsible disclosure.\n",
  "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" : "engine.io"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.1.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "engine.io"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.0.0"
      }, {
        "fixed" : "5.2.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "engine.io"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.0.0"
      }, {
        "fixed" : "6.1.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/socketio/engine.io/security/advisories/GHSA-273r-mgr4-v34f"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-21676"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/socketio/engine.io/commit/66f889fc1d966bf5bfa0de1939069153643874ab"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/socketio/engine.io/commit/a70800d7e96da32f6e6622804ef659ebc58659db"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/socketio/engine.io/commit/c0e194d44933bd83bf9a4b126fca68ba7bf5098c"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/socketio/engine.io"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/socketio/engine.io/releases/tag/4.1.2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/socketio/engine.io/releases/tag/5.2.1"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/socketio/engine.io/releases/tag/6.1.1"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20220209-0002"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-754", "CWE-755" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-01-12T19:26:23Z",
    "nvd_published_at" : "2022-01-12T19:15:00Z"
  }
}