Fail-safe for environments without unsafe-eval
CSP
#903
Labels
confinement
Pertaining to confinement of guest programs.
kriskowal-review-2024-01
Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024
ses
SES relies on dynamic eval for its own initialization and virtualizing Compartment evaluators.
Some environments prevent execution of such dynamic eval, such as a browser with
Content-Security-Policy
not including'unsafe-eval'
in itsscript-src
policy.SES's initialization does some dynamic eval to tame the Function constructors. However this currently includes an idempotency test which is too lax, and fails open if
'unsafe-eval'
is not allowed. Also, a dynamic eval is considered for addition to make SES more resilient against transpilers (#902).endo/packages/ses/src/tame-function-constructors.js
Lines 46 to 53 in 1ee0a1f
While this is not really a security issue since the Compartment API doesn't work at all without
'unsafe-eval'
, changes like the one proposed in #881 are looking into using the Compartment feature without requiring dynamic eval of code. The actual taming doesn't have to rely on dynamic eval anymore than the current way anonymous intrinsics are looked up by direct syntax. For that matter, the logic for looking up the intrinsic could probably be deduplicated betweenrepairFunction
andgetAnonymousIntrinsics
.It could also be argued that in an environment with no dynamic eval, the intrinsic
eval
andFunction
constructors are not feral and thus safe to leave in place. However making this behavior an explicit opt-in would be preferable, if at all allowed, instead of the current fail-open situation.The text was updated successfully, but these errors were encountered: