Skip to content
Heist/ feed
Back to feed
Medium

jsonwebtoken's insecure implementation of key retrieval function could lead to Forgeable Public/Private Tokens from RSA to HMAC

Type: advisorySources: OSV

jsonwebtoken is an implementation of JSON Web Tokens. Versions `<= 8.5.1` of `jsonwebtoken` library can be misconfigured so that passing a poorly implemented key retrieval function referring to the `secretOrPublicKey` argument from the readme link will result in incorrect verification of tokens. There is a possibility of using a different algorithm and key combination in verification, other than the one that was used to sign the tokens. Specifically, tokens signed with an asymmetric public key could be verified with a symmetric HS256 algorithm. This can lead to successful validation of forged tokens. If your application is supporting usage of both symmetric key and asymmetric key in jwt.verify() implementation with the same key retrieval function. This issue has been patched, please update to version 9.0.0.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2022-23541
Confirmed fixed CVEs
Not specified
Updated in this feed
4 Nov 2026, 20:12 UTC · Revision 1

Source evidence

jsonwebtoken's insecure implementation of key retrieval function could lead to Forgeable Public/Private Tokens from RSA to HMAC

core-osv · Original source

Published 22 Dec 2022, 17:52 UTC

jsonwebtoken is an implementation of JSON Web Tokens. Versions `<= 8.5.1` of `jsonwebtoken` library can be misconfigured so that passing a poorly implemented key retrieval function referring to the `secretOrPublicKey` argument from the readme link will result in incorrect verification of tokens. There is a possibility of using a different algorithm and key combination in verification, other than the one that was used to sign the tokens. Specifically, tokens signed with an asymmetric public key could be verified with a symmetric HS256 algorithm. This can lead to successful validation of forged tokens. If your application is supporting usage of both symmetric key and asymmetric key in jwt.verify() implementation with the same key retrieval function. This issue has been patched, please update to version 9.0.0.

osv:CVE-2022-23541
Complete source record
{
  "id": "72053ebb662a633f17bb131adb4860729b7b6cdf3d2d08007635dd10a4af1af8",
  "url": "https://osv.dev/vulnerability/CVE-2022-23541",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "jsonwebtoken's insecure implementation of key retrieval function could lead to Forgeable Public/Private Tokens from RSA to HMAC",
    "summary": "jsonwebtoken is an implementation of JSON Web Tokens. Versions `<= 8.5.1` of `jsonwebtoken` library can be misconfigured so that passing a poorly implemented key retrieval function referring to the `secretOrPublicKey` argument from the readme link will result in incorrect verification of tokens. There is a possibility of using a different algorithm and key combination in verification, other than the one that was used to sign the tokens. Specifically, tokens signed with an asymmetric public key could be verified with a symmetric HS256 algorithm. This can lead to successful validation of forged tokens. If your application is supporting usage of both symmetric key and asymmetric key in jwt.verify() implementation with the same key retrieval function. This issue has been patched, please update to version 9.0.0.",
    "evidence": "osv:CVE-2022-23541",
    "products": [],
    "severity": "medium",
    "structured": {
      "id": "CVE-2022-23541",
      "aliases": [
        "CVE-2022-23541",
        "GHSA-hjrf-2m68-5959"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/auth0/node-jsonwebtoken",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "e1fa9dcc12054a8681db4e6373da1b30cf7016e3"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:auth0:jsonwebtoken:*:*:*:*:*:node.js:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "last_affected": "8.5.1"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "range": [
                      {
                        "fixed": "e1fa9dcc12054a8681db4e6373da1b30cf7016e3"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  },
                  {
                    "range": [
                      {
                        "fixed": "e1fa9dcc12054a8681db4e6373da1b30cf7016e3"
                      }
                    ],
                    "source": "REFERENCES_TAG",
                    "original_tag": "v9.0.0"
                  }
                ]
              }
            }
          ],
          "versions": [
            "v8.5.1",
            "v8.5.0",
            "v8.3.0",
            "v8.2.2",
            "v8.2.1",
            "v8.2.0",
            "v8.1.1",
            "v8.1.0",
            "v8.0.1",
            "v8.0.0",
            "v7.4.3",
            "v7.4.2",
            "v7.4.1",
            "v7.4.0",
            "v7.3.0",
            "v7.2.1",
            "v7.2.0",
            "v7.1.10",
            "v7.1.9",
            "v7.1.8",
            "v7.1.7",
            "v7.1.6",
            "v7.1.5",
            "v7.1.4",
            "v7.1.3",
            "v7.1.2",
            "v7.1.1",
            "v7.1.0",
            "v7.0.1",
            "v7.0.0",
            "v6.2.0",
            "v6.1.2",
            "v6.1.1",
            "v6.1.0",
            "v6.0.1",
            "v6.0.0",
            "v5.7.0",
            "v5.6.2",
            "v5.6.1",
            "v5.6.0",
            "v5.5.4",
            "v5.5.3",
            "v5.5.2",
            "v5.5.1",
            "v5.5.0",
            "v5.4.0",
            "v5.3.1",
            "v5.3.0",
            "v5.1.0",
            "v5.0.5",
            "v5.0.4",
            "v5.0.3",
            "v5.0.2",
            "v5.0.1",
            "v5.0.0",
            "v4.2.2",
            "v4.2.1",
            "v4.2.0",
            "v4.1.0",
            "v4.0.0",
            "v3.2.2",
            "v3.2.1",
            "v3.2.0",
            "v3.1.1",
            "v3.1.0",
            "v3.0.0",
            "v2.0.0",
            "v1.1.2",
            "v1.1.1",
            "v0.2.0"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2022-23541.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:39.053722749Z",
      "provider": "osv",
      "references": [
        "https://github.com/auth0/node-jsonwebtoken/releases/tag/v9.0.0",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/23xxx/CVE-2022-23541.json",
        "https://github.com/auth0/node-jsonwebtoken/security/advisories/GHSA-hjrf-2m68-5959",
        "https://nvd.nist.gov/vuln/detail/CVE-2022-23541",
        "https://security.netapp.com/advisory/ntap-20240621-0007/",
        "https://github.com/auth0/node-jsonwebtoken/commit/e1fa9dcc12054a8681db4e6373da1b30cf7016e3"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-1259",
          "CWE-287"
        ],
        "cna_assigner": "GitHub_M",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/23xxx/CVE-2022-23541.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2022-23541",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 506546,
  "published_at": "2022-12-22T17:52:22.173+00:00"
}