Dynamic Import Host Adjustment
|Reviewers||@bakkot, @erights, @bmeck|
Trusted Types guards sensitive APIs; it double checks that values have been trusted by policy code before performing operations that cannot be undone.
The dynamic import operator,
import(...), loads code and initializes modules.
Loading code from an untrustworthy source is an operation that cannot be undone.
This adjusts the host callout which enables dynamic loading. With it:
- The host receives the original specifier (before it is stringified) so can use runtime type information to decide whether to allow code loading to proceed.
- The host callout can control stringification and convey the result to FinishDynamicImport to avoid repeated stringification, and to integrate with default policies.
Tests, to be written, will be implemented as web-platform-tests and will focus on the following properties:
- Polymorphic objects stringified once. Something like
- The above, with coverage for both null and non-null referencing modules.
- Tests specific to trusted-types host implementation.
See also webappsec-csp #243
import('data:...') as CSP bypass.