Skip to content

fix(deps): update dependency node-jose to v2 [security]#28

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-node-jose-vulnerability
Open

fix(deps): update dependency node-jose to v2 [security]#28
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-node-jose-vulnerability

Conversation

@renovate

@renovate renovate Bot commented Mar 16, 2023

Copy link
Copy Markdown

This PR contains the following updates:

Package Change Age Confidence
node-jose ^1.1.3^2.0.0 age confidence

Improper calculations in ECC implementation can trigger a Denial-of-Service (DoS)

CVE-2023-25653 / GHSA-5h4j-qrvg-9xhw

More information

Details

Description

When using the non-default "fallback" crypto back-end, ECC operations in node-jose can trigger a Denial-of-Service (DoS) condition, due to a possible infinite loop in an internal calculation. For some ECC operations, this condition is triggered randomly; for others, it can be triggered by malicious input.

Technical summary

The JOSE logic implemented by node-jose usually relies on an external cryptographic library for the underlying cryptographic primitives that JOSE operations require. When WebCrypto or the Node crypto module are available, they are used. When neither of these libraries is available, node-jose includes its own "fallback" implementations of some algorithms based on node-forge, in particular implementations of ECDH and ECDSA.

A various points, these algorithm implementations need to compute to the X coordinate of an elliptic curve point. This is done by calling the getX() method of the object representing the point, which is an alias of the function pointFpGetX() in lib/deps/ecc/math.js.

Computing the X coordinate from the form in which the point is stored requires computing the modular inverse of the Z coordinate, using the modInverse function from the jsbn library (e.g., this.z.modInverse(this.curve.p)). The output of this function call is multiplied by another value before being reduced with the barrettReduce() function.

The root cause of this issue is that the jsbn modInverse function sometimes returns negative results. These results are correct in that they are equivalent mod the relevant modulus, but can be problematic for functions that expect modular operations to always return positive results (in the range [0, p), where p is the modulus).

In particular, while the Barrett reduction algorithm in general can handle negative inputs, the implementation in node-jose explicitly does not. Therefore, while the negative value that is returned by modInverse() is mathematically correct, it leads to an error in barrettReduce() causing an infinite loop which may result in a Denial of Service condition.

For a given prime modulus, we estimate that roughly one in every 2^20 inputs produce a negative modInverse(). This estimate was validated with exhaustive testing on small primes (<30 bits) and randomized testing with regard to the P-256 prime.

Impact

This issue is only present in situations where the "fallback" cryptographic implementation is being used, i.e., situations where neither WebCrypto nor the Node crypto module is available.

The following elliptic curve algorithms are impacted by this issue (all in lib/deps/ecc/index.js):

  • Elliptic curve key generation (exports.generateKeyPair)
  • Converting an elliptic curve private key to a public key (ECPrivateKey.prototype.toPublicKey)
  • ECDSA signing (ECPrivateKey.prototype.sign)
  • ECDSA verification (ECPublicKey.prototype.verify)
  • ECDH key agreement (ECPrivateKey.prototype.computeSecret)

In the first three cases, the points being evaluated are generated randomly, so an attack could only arise due to a bad value being randomly selected (as noted above, with probability roughly 2^{-20}). In the latter two cases, the points being evaluated are provided from outside the library, and thus potentially by attackers.

Patches

Has the problem been patched? What versions should users upgrade to?

Workarounds

Since this issue is only present in the "fallback" crypto implementation, it can be avoided by ensuring that either WebCrypto or the Node crypto module is available in the JS environment where node-jose is being run.

References
For more information

If you have any questions or comments about this advisory:

Credits

Severity

  • CVSS Score: 7.5 / 10 (High)
  • Vector String: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Release Notes

cisco/node-jose (node-jose)

v2.2.0

Compare Source

v2.1.1

Compare Source

v2.1.0

Compare Source

v2.0.0

Compare Source

While all of the changes in this release are only dependency updates and otherwise patch-level changes, it does break compatibility with versions of node.js older than version 10.

Update
  • switch to karma-safari-applescript-launcher for improved local Safari testing (a0db723)
  • update dependencies for karma, karma-mocha, mocha, webpack-stream, and yargs (96ee8ff)
  • update node-forge to latest (shahar-h)(277aab5)
  • cherry-pick lodash modules to effect smaller footprint (tychenjianjun)(003ef1c)
  • replace browserify-zlib with pako (taymoork2)(85610d6)

Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate Bot force-pushed the renovate/npm-node-jose-vulnerability branch from 7933b7e to 0d86df6 Compare August 10, 2025 14:14
@renovate renovate Bot force-pushed the renovate/npm-node-jose-vulnerability branch from 0d86df6 to bfca929 Compare December 3, 2025 19:48
@renovate renovate Bot force-pushed the renovate/npm-node-jose-vulnerability branch from bfca929 to b92d54f Compare February 2, 2026 18:48
@renovate renovate Bot changed the title fix(deps): update dependency node-jose to v2 [security] fix(deps): update dependency node-jose to v2 [security] - autoclosed Mar 27, 2026
@renovate renovate Bot closed this Mar 27, 2026
@renovate renovate Bot deleted the renovate/npm-node-jose-vulnerability branch March 27, 2026 01:35
@renovate renovate Bot changed the title fix(deps): update dependency node-jose to v2 [security] - autoclosed fix(deps): update dependency node-jose to v2 [security] Mar 30, 2026
@renovate renovate Bot reopened this Mar 30, 2026
@renovate renovate Bot force-pushed the renovate/npm-node-jose-vulnerability branch 2 times, most recently from b92d54f to 7c16cef Compare March 30, 2026 22:25
@renovate renovate Bot force-pushed the renovate/npm-node-jose-vulnerability branch from 7c16cef to 3189257 Compare April 8, 2026 14:37
@renovate renovate Bot changed the title fix(deps): update dependency node-jose to v2 [security] fix(deps): update dependency node-jose to v2 [security] - autoclosed Apr 27, 2026
@renovate renovate Bot closed this Apr 27, 2026
@renovate renovate Bot changed the title fix(deps): update dependency node-jose to v2 [security] - autoclosed fix(deps): update dependency node-jose to v2 [security] Apr 27, 2026
@renovate renovate Bot reopened this Apr 27, 2026
@renovate renovate Bot force-pushed the renovate/npm-node-jose-vulnerability branch 2 times, most recently from 3189257 to 396aaf8 Compare April 27, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants