Skip to content

Replace dependency to jwk-to-pem with function from node:crypto #330

@mn4367

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.

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