-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vetted shims #422
Comments
cc @erights |
LGTM |
Some thoughts I want to persist so I don't forget to bring them up in the meeting. May or may not be discussed asynchronously here.
|
In theory the final "lockdown" phase is basically: for (const [name, intrinsic] of getIntrinsics()) {
harden(intrinsic);
} |
We could make a gross overload of |
Please no. That implies that harden has access to getIntrinsics, whereas its normal behavior does not imply that. |
I’m open to the alternative: Security.repair(options)
Security.lockdown() With backward-compatibility preserved only in the form |
+1 to that. I only brought up the context of a future namespace to back up the idea of adding another 2 methods instead of 1. |
How do we assure vetted shims are trust worthy? And yes, I do understand that this is the whole point behind a vetted shim - that you can trust it, and that if you can't than it isn't a vetted shim and that lockdown/SES can be justifiably compromised out of our control. However, is there a reason to consider making the user of Or does that approach introduces some fundamental wrongs I'm not grasping?
It was made clear to me that vetted shims are shims the user is willing to vet on, and that can and will have the power to leave your program fully vulnerable by definition, and therefore the answer to my question is: No. There's no use for what I propose in this comment. |
Once we have vetted shims, I'd like to migrate the |
To improve compatibility between Hardened JavaScript and shims, programs that upgrade the underlying language, some shims need to be in a position where they can introduce new properties to shared intrinsics and for those properties to remain visible after lockdown.
Enable Vetted Shims
In the first phase of this design, we would introduce a separate
repair(options)
such that the following programs are equivalent:In the latter form, shims can be executed between
repair
andlockdown
that alter the shared intrinsics in ways that will not be erased by callinglockdown
. These are vetted shims.repair()
will introduce the globalharden()
, but betweenrepair()
andlockdown()
,harden
will simply mark objects that must be hardened bylockdown()
. Currently, initializing theses
module introducesharden()
, and it throws an error until after callinglockdown()
. Introducingharden
at time ofrepair
is consistent with the idea thatrepair
is effectively a shim that upgrades the base JavaScript to Almost-Hardened JavaScript, such that shims can run, thenlockdown
is effectively a shim that completes the job.In the following program,
lockdown()
will throw an error because repair options were already applied.Allowing
lockdown(options)
to serve as bothrepair
andlockdown
ifrepair
has not already been called gives us a graceful migration path from the status quo, and may even be desirable as a feature of the Hardened JavaScript standard since it simplifies usage in scenarios that do not have vetted shims.Enable Hardened Vetted Shims
The above design is consistent with further work, to be tracked in subsequent issues:
repair
introduces new shared intrinsics but does not expose them in a way that vetted shims would be able to alter them. For this to become possible,repair
would need to upgradegetIntrinsic
andgetIntrinsics
in place such that, for example,getIntrinsic('%SharedMath%')
could be upgraded in place. This would presumably also introduce a%sharedGetIntrinsic%
and%sharedGetIntrinsics%
function that could be safely shared with compartments, providing access only to the shared intrinsics and no others. Further intrinsics would be introduced to compartments by either writing a wrapper for these or possibly additional compartment constructor options with the same effect.Eject Internal Shims
Separating
repair
andlockdown
will allow us to refactorses
such that some of the internal layers can become separate shims. For example, the internal compartment-shim could be refactored into a layers: compartment-as-module-loader and compartment-as-confinement. We can removeHandledPromise
from the permits, since thehandled-promise-shim
can be applied betweenrepair
andlockdown
instead. Theconsole
,assert
, andError
shims could be separated, and alternate implementations can be used to provide the same services.Alternatives Considered
The other major design family that we considered and rejected was a variant on this design that lacked a separable
repair()
phase, also allowed but deferredharden
until afterlockdown()
, and had an additional API for submitting plans for changes to the permits structure thatlockdown()
would apply. The crux of the design decision is the emergent behavior of shims that must have a follow-up shim to accommodate Hardened JavaScript. In both design spaces, these shims would need to usegetIntrinsic
to make changes to shared shims and mark new intrinsics withharden
. The only material difference is that these hardening-shims would also need to use permit objects to plan for behaviors to be applied during lockdown instead of immediately. We elected to preserve the current convention, that shims modify the environment in place, at the expense of having a separaterepair()
call that serves as a shim for taming and repairing the JavaScript environment, upgrading it to Almost-Hardened JavaScript.[original description, 2020-08-18 by kriskowal:]
Endo needs the ability to promote packages and modules that serve as vetted shims, such that they execute after repairs and before lockdown, before any non-shim modules execute. This is a form of dependency “hoisting”. We will need to incorporate the allow-list metadata into the
package.json
of either the shim, the module that depends upon the shim, or create shim envelope packages to host the metadata. The metadata would be collected by Endo and captured in the compartment map.The text was updated successfully, but these errors were encountered: