Vulnerabilities in pkg:npm/jose

PACKAGE
Advisory Identifier: GHSA-hhhv-q57g-882q
Advisory Summary

CVE-2024-28176 is a MODERATE (CVSS 5.3) remote code execution vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Jose libraries in the npm ecosystem. The issue involves jose vulnerable to resource exhaustion via specifically crafted jwe with compressed plaintext. Remediation is available by upgrading affected packages to version 4.15.5, 2.0.7.

3 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/jose

3 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/jose. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-hhhv-q57g-882q CVE-2024-28176 MODERATE jose vulnerable to resource exhaustion via specifically crafted JWE with compressed plaintext
GHSA-jv3g-j58f-9mq9 CVE-2022-36083 MODERATE JOSE vulnerable to resource exhaustion via specifically crafted JWE
GHSA-58f5-hfqc-jgch CVE-2021-29443 MODERATE Padding Oracle Attack due to Observable Timing Discrepancy in jose

CVE-2024-28176 at a Glance

CVE Identifier CVE-2024-28176
GHSA Identifier GHSA-hhhv-q57g-882q
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Jose
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

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

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 Low (A:L)

How to Fix CVE-2024-28176

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

jose fixed: 4.15.5
npm install jose@4.15.5
jose-node-cjs-runtime fixed: 4.15.5
npm install jose-node-cjs-runtime@4.15.5
jose-node-esm-runtime fixed: 4.15.5
npm install jose-node-esm-runtime@4.15.5
jose fixed: 2.0.7
npm install jose@2.0.7
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 jose

How to Check if You Are Affected

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

npm ls jose

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

Note: The npm ls jose 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-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Jose, 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

A vulnerability has been identified in the JSON Web Encryption (JWE) decryption interfaces, specifically related to the [support for decompressing plaintext after its decryption](https://www.rfc-editor.org/rfc/rfc7516.html#section-4.1.3). This allows an adversary to exploit specific scenarios where the compression ratio becomes exceptionally high. As a result, the length of the JWE token, which is determined by the compressed content's size, can land below application-defined limits. In such cases, other existing application level mechanisms for preventing resource exhaustion may be rendered ineffective. Note that as per [RFC 8725](https://www.rfc-editor.org/rfc/rfc8725.html#name-avoid-compression-of-encryp) compression of data SHOULD NOT be done before encryption, because such compressed data often reveals information about the plaintext. For this reason the v5.x major version of `jose` removed support for compressed payloads entirely and is therefore NOT affected by this advisory. ### Impact Under certain conditions it is possible to have the user's environment consume unreasonable amount of CPU time or memory during JWE Decryption operations. ### Affected users The impact is limited only to Node.js users utilizing the JWE decryption APIs to decrypt JWEs from untrusted sources. You are NOT affected if any of the following applies to you - Your code uses jose version v5.x where JWE Compression is not supported anymore - Your code runs in an environment other than Node.js (e.g. Deno, CF Workers), which is the only runtime where JWE Compression is implemented out of the box - Your code does not use the JWE decryption APIs - Your code only accepts JWEs produced by trusted sources ### Patches `v2.0.7` and `v4.15.5` releases limit the decompression routine to only allow decompressing up to 250 kB of plaintext. In v4.x it is possible to further adjust this limit via the `inflateRaw` decryption option implementation. In v2.x it is possible to further adjust this limit via the `inflateRawSyncLimit` decryption option. ### Workarounds If you cannot upgrade and do not want to support compressed JWEs you may detect and reject these tokens early by checking the token's protected header ```js const { zip } = jose.decodeProtectedHeader(token) if (zip !== undefined) { throw new Error('JWE Compression is not supported') } ``` If you wish to continue supporting JWEs with compressed payloads in these legacy release lines you must upgrade (v1.x and v2.x to version v2.0.7, v3.x and v4.x to version v4.15.5) and review the limits put forth by the patched releases. ### For more information If you have any questions or comments about this advisory please open a discussion in the project's [repository](https://github.com/panva/jose/discussions/new?category=q-a&title=GHSA-hhhv-q57g-882q%20advisory%20question)

CVE-2024-28176 Affected Jose Versions

4 component(s)
Fixed Versions:
4.15.52.0.7
Product / Package Ecosystem Affected Versions Fixed Version
jose
npm
≥ 3.0.0
< 4.15.5
4.15.5
jose-node-cjs-runtime
npm
< 4.15.5
4.15.5
jose-node-esm-runtime
npm
< 4.15.5
4.15.5
jose
npm
< 2.0.7
2.0.7

References

Frequently Asked Questions

What is CVE-2024-28176?
CVE-2024-28176 is a security vulnerability in Jose involving jose vulnerable to resource exhaustion via specifically crafted JWE with compressed plaintext under CWE-400: Uncontrolled Resource Consumption.
Which Jose versions are affected?
Affected versions include releases prior to 4.15.5, 2.0.7 across affected packages: jose, jose-node-cjs-runtime, jose-node-esm-runtime.
What version fixes CVE-2024-28176?
Upgrading to 4.15.5, 2.0.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is jose affected?
Yes, jose is affected in releases prior to 4.15.5, 2.0.7. Upgrade your dependency to 4.15.5, 2.0.7 or later.
Is jose-node-cjs-runtime affected?
Yes, jose-node-cjs-runtime is affected in releases prior to 4.15.5. Upgrade your dependency to 4.15.5 or later.
What is the CVSS score of CVE-2024-28176?
CVE-2024-28176 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2024-28176?
CVE-2024-28176 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check npm dependencies for CVE-2024-28176?
Run the dependency tree command: 'npm ls jose'. 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-hhhv-q57g-882q",
  "modified" : "2024-03-30T06:30:42Z",
  "published" : "2024-03-07T17:40:57Z",
  "aliases" : [ "CVE-2024-28176" ],
  "summary" : "jose vulnerable to resource exhaustion via specifically crafted JWE with compressed plaintext",
  "details" : "A vulnerability has been identified in the JSON Web Encryption (JWE) decryption interfaces, specifically related to the [support for decompressing plaintext after its decryption](https://www.rfc-editor.org/rfc/rfc7516.html#section-4.1.3). This allows an adversary to exploit specific scenarios where the compression ratio becomes exceptionally high. As a result, the length of the JWE token, which is determined by the compressed content's size, can land below application-defined limits. In such cases, other existing application level mechanisms for preventing resource exhaustion may be rendered ineffective.\n\nNote that as per [RFC 8725](https://www.rfc-editor.org/rfc/rfc8725.html#name-avoid-compression-of-encryp) compression of data SHOULD NOT be done before encryption, because such compressed data often reveals information about the plaintext. For this reason the v5.x major version of `jose` removed support for compressed payloads entirely and is therefore NOT affected by this advisory.\n\n### Impact\n\nUnder certain conditions it is possible to have the user's environment consume unreasonable amount of CPU time or memory during JWE Decryption operations.\n\n### Affected users\n\nThe impact is limited only to Node.js users utilizing the JWE decryption APIs to decrypt JWEs from untrusted sources.\n\nYou are NOT affected if any of the following applies to you\n\n- Your code uses jose version v5.x where JWE Compression is not supported anymore\n- Your code runs in an environment other than Node.js (e.g. Deno, CF Workers), which is the only runtime where JWE Compression is implemented out of the box\n- Your code does not use the JWE decryption APIs\n- Your code only accepts JWEs produced by trusted sources\n\n### Patches\n\n`v2.0.7` and `v4.15.5` releases limit the decompression routine to only allow decompressing up to 250 kB of plaintext. In v4.x it is possible to further adjust this limit via the `inflateRaw` decryption option implementation. In v2.x it is possible to further adjust this limit via the `inflateRawSyncLimit` decryption option.\n\n### Workarounds\n\nIf you cannot upgrade and do not want to support compressed JWEs you may detect and reject these tokens early by checking the token's protected header\n\n```js\nconst { zip } = jose.decodeProtectedHeader(token)\nif (zip !== undefined) {\n  throw new Error('JWE Compression is not supported')\n}\n```\n\nIf you wish to continue supporting JWEs with compressed payloads in these legacy release lines you must upgrade (v1.x and v2.x to version v2.0.7, v3.x and v4.x to version v4.15.5) and review the limits put forth by the patched releases.\n\n### For more information\nIf you have any questions or comments about this advisory please open a discussion in the project's [repository](https://github.com/panva/jose/discussions/new?category=q-a&title=GHSA-hhhv-q57g-882q%20advisory%20question)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "jose"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "4.15.5"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.15.4"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "jose-node-cjs-runtime"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.15.5"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.15.4"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "jose-node-esm-runtime"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.15.5"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.15.4"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "jose"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.0.7"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/panva/jose/security/advisories/GHSA-hhhv-q57g-882q"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-28176"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/panva/jose/commit/02a65794f7873cdaf12e81e80ad076fcdc4a9314"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/panva/jose/commit/1b91d88d2f8233f3477a5f4579aa5f8057b2ee8b"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/panva/jose"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/I6MMWFBOXJA6ZCXNVPDFJ4XMK5PVG5RG"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/KXKGNCRU7OTM5AHC7YIYBNOWI742PRMY"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/UG5FSEYJ3GP27FZXC5YAAMMEC5XWKJHG"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/UJO2U5ACZVACNQXJ5EBRFLFW6DP5BROY"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/XJDO5VSIAOGT2WP63AXAAWNRSVJCNCRH"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-03-07T17:40:57Z",
    "nvd_published_at" : "2024-03-09T01:15:07Z"
  }
}