Skip to content

Replace vulnerable dependency to jwk-to-pem with function from node:crypto [SOLVED] (by using a shim, see comment in this issue) #330

Description

@mn4367

Grant uses jwk-to-pem that has a dependency to elliptic which itself has a vulnerability but seems to be abandoned.

jwk_to_pem can be replaced completely by two functions which are part of the Node.js crypto module: createPublicKey and createPrivateKey.

In the case of grant it's sufficient to replace

var pem = require('jwk-to-pem');
return pem(jwk, { private: true });

in oidc.js (lines 29,30) with

return crypto.createPrivateKey({
  key: jwk,
  format: "jwk"
}).export({
  type: "pkcs8",
  format: "pem"
});

and to remove the jwk-to-pem dependency from package.json. See also Brightspace/node-jwk-to-pem#193.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions