Skip to content
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

Fail-safe for environments without unsafe-eval CSP #903

Open
mhofman opened this issue Sep 21, 2021 · 0 comments
Open

Fail-safe for environments without unsafe-eval CSP #903

mhofman opened this issue Sep 21, 2021 · 0 comments
Assignees
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

Comments

@mhofman
Copy link
Contributor

mhofman commented Sep 21, 2021

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 its script-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).

try {
// Verify that the method is not callable.
// eslint-disable-next-line @endo/no-polymorphic-call
FERAL_FUNCTION.prototype.constructor('return 1');
} catch (ignore) {
// Throws, no need to patch.
return {};
}

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 between repairFunction and getAnonymousIntrinsics.

It could also be argued that in an environment with no dynamic eval, the intrinsic eval and Function 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.

@mhofman mhofman added the confinement Pertaining to confinement of guest programs. label Sep 21, 2021
@mhofman mhofman self-assigned this Nov 8, 2021
@mhofman mhofman added endo ses and removed endo labels Feb 8, 2022
@kriskowal kriskowal added the kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024 label Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants