Open larixer opened 5 years ago
The alternative is to not execute microkernel code from .pnp.js, but rather have a library with the code, that reads PnP map and answers to resolve queries itself. With such a library it is far too difficult to support all microkernel behaviour for past releases.
We actually already have that! If set to false, the pnpEnableInlining
setting will cause Yarn to emit a .pnp.meta.json
file which can be consumed through the hydratePnpApi
function of @yarnpkg/pnp
.
That said I think it's a nice idea - the main problem will be to put markers around the dynamic parts, and validate that it's proper JSON 🤔
Describe the user story
I am an IDE developer and I want to be sure that
.pnp.js
has the code developed by Yarn v2 authors, and not by some adversary.Describe the solution you'd like
The
@yarnpkg/pnp-loader
package is introduced which will verify that microkernel code inside.pnp.js
is developed by Yarn v2 authors, prior to requiring and executing it.In order for the microkernel code to be verifiable, two values are attached to each microkernel code being released:
@yarnpkg/pnp-loader
will have in its source code ALL the previous hash values for all the previous microkernel code releases. It will also has the LAST non-compromised digital signature public key.The verification algorithm is the following:
.pnp.js
has microkernel hash value known to@yarnpkg/pnp-loader
, if yes - the microkernel was produced by Yarn v2 authors in the past and the microkernel can be executed, if no - proceed to step 2..pnp.js
microkernel has digital signature that can be verified with public key stored inside@yarnpkg/pnp-loader
, if yes - the code was signed by Yarn v2 authors and can be trusted until the key pair is compromised.The algorithm to change compromised digital signature key pair:
@yarnpkg/pnp-loader
The algorithm to revoke past microkernel version due to known security vulnerability in the code:
@yarnpkg/pnp-loader
Describe the drawbacks of your solution
Not sure, but the discussion is needed.
Describe alternatives you've considered
The alternative is to not execute microkernel code from
.pnp.js
, but rather have a library with the code, that reads PnP map and answers to resolve queries itself. With such a library it is far too difficult to support all microkernel behaviour for past releases.