CVE-2021-30246: Jsrsasign RSA Signature Validation Vulnerability On Vulnerability

CRITICAL
Advisory Identifier: GHSA-27fj-mc8w-j9wg
CVSS 9.1
CWE-347
Published
Advisory Summary

CVE-2021-30246 is a CRITICAL (CVSS 9.1) rsa signature validation vulnerability on vulnerability (CWE-347: Improper Verification of Cryptographic Signature) affecting Jsrsasign libraries in the npm ecosystem. The issue involves rsa signature validation vulnerability on maleable encoded message in jsrsasign. Remediation is available by upgrading affected packages to version 10.2.0.

CVE-2021-30246 at a Glance

CVE Identifier CVE-2021-30246
GHSA Identifier GHSA-27fj-mc8w-j9wg
Severity CRITICAL
CVSS v3.1 Base Score 9.1
CWE Classification CWE-347: Improper Verification of Cryptographic Signature
Affected Product Jsrsasign
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.1

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

How to Fix CVE-2021-30246

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

jsrsasign fixed: 10.2.0
npm install jsrsasign@10.2.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 jsrsasign

How to Check if You Are Affected

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

npm ls jsrsasign

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

Note: The npm ls jsrsasign 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-347: Improper Verification of Cryptographic Signature, where the product does not verify, or incorrectly verifies, the cryptographic signature for data. In Jsrsasign, 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 Vulnerable jsrsasign will accept RSA signature with improper PKCS#1.5 padding. Decoded RSA signature value consists following form: `01(ff...(8 or more ffs)...ff)00[ASN.1 OF DigestInfo]` Its byte length must be the same as RSA key length, however such checking was not sufficient. To make crafted message for practical attack is very hard. ### Patches Users validating RSA signature should upgrade to 10.2.0 or later. ### Workarounds There is no workaround. Not to use RSA signature validation in jsrsasign. ### ACKNOWLEDGEMENT Thanks to Daniel Yahyazadeh @yahyazadeh for reporting and analyzing this vulnerability.

CVE-2021-30246 Affected Jsrsasign Versions

1 component(s)
Fixed Versions:
10.2.0
Product / Package Ecosystem Affected Versions Fixed Version
jsrsasign
npm
< 10.2.0
10.2.0

References

Frequently Asked Questions

What is CVE-2021-30246?
CVE-2021-30246 is a security vulnerability in Jsrsasign involving RSA signature validation vulnerability on maleable encoded message in jsrsasign under CWE-347: Improper Verification of Cryptographic Signature.
Which Jsrsasign versions are affected?
Affected versions include releases prior to 10.2.0 across affected packages: jsrsasign.
What version fixes CVE-2021-30246?
Upgrading to 10.2.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is jsrsasign affected?
Yes, jsrsasign is affected in releases prior to 10.2.0. Upgrade your dependency to 10.2.0 or later.
What is the CVSS score of CVE-2021-30246?
CVE-2021-30246 has a CVSS v3.1 base score of 9.1 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2021-30246?
CVE-2021-30246 is classified under CWE-347: Improper Verification of Cryptographic Signature (The product does not verify, or incorrectly verifies, the cryptographic signature for data.).
How can I check npm dependencies for CVE-2021-30246?
Run the dependency tree command: 'npm ls jsrsasign'. 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-27fj-mc8w-j9wg",
  "modified" : "2023-09-11T18:42:06Z",
  "published" : "2021-04-16T19:52:35Z",
  "aliases" : [ "CVE-2021-30246" ],
  "summary" : "RSA signature validation vulnerability on maleable encoded message in jsrsasign",
  "details" : "### Impact\nVulnerable jsrsasign will accept RSA signature with improper PKCS#1.5 padding.\nDecoded RSA signature value consists following form:\n`01(ff...(8 or more ffs)...ff)00[ASN.1 OF DigestInfo]`\nIts byte length must be the same as RSA key length, however such checking was not sufficient.\n\nTo make crafted message for practical attack is very hard.\n\n### Patches\nUsers validating RSA signature should upgrade to 10.2.0 or later.\n\n### Workarounds\nThere is no workaround. Not to use RSA signature validation in jsrsasign.\n\n### ACKNOWLEDGEMENT\nThanks to Daniel Yahyazadeh @yahyazadeh for reporting and analyzing this vulnerability.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "jsrsasign"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "10.2.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/kjur/jsrsasign/security/advisories/GHSA-27fj-mc8w-j9wg"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-30246"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/kjur/jsrsasign/issues/478"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/kjur/jsrsasign/releases/tag/10.1.13"
  }, {
    "type" : "WEB",
    "url" : "https://kjur.github.io/jsrsasign"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-347" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-04-13T17:30:34Z",
    "nvd_published_at" : "2021-04-07T21:15:00Z"
  }
}