Repository navigation
Don't fetch when loading the config property - #440
Merged
Merged
Conversation
Setting the `config` property on <playground-ide> or <playground-project> used to fetch any file listed without `content`, follow `extends`, and adopt `cdnBaseUrl` from the config. The `config` property is the documented way to load a shared project, so a config from an untrusted source (e.g. decoded from a URL) could make the host page fetch arbitrary URLs with the user's credentials. The responses became project files, which code running in the preview could then read. The `config` property now only uses files with inline string `content` and the `importMap`. Files without `content`, `extends`, and `cdnBaseUrl` are ignored with a console warning, and malformed file entries are skipped instead of throwing. Manifests loaded with `project-src` are unchanged. BREAKING CHANGE: configs set through the `config` property that rely on fetched files, `extends`, or `cdnBaseUrl` must be loaded with `project-src` instead, with the CDN set through the `cdnBaseUrl` property or `cdn-base-url` attribute.
augustjk
force-pushed
the
restrict-untrusted-config
branch
from
November 19, 2026 17:27
361e884 to
ce7f4eb
Compare
rictic
approved these changes
Nov 23, 2026
The config property now has its own type, ProjectConfig, instead of ProjectManifest. It requires inline content for every file and has no extends or cdnBaseUrl, which the setter does not support. Setting them in a config object literal is now a compile error in TypeScript, rather than only a console warning at runtime. The runtime handling stays, because configs parsed from JSON bypass the type. ProjectManifest goes back to describing only manifests loaded with project-src. The README and changelog now describe the config format in its own terms, and say that these are not allowed rather than ignored.
The TypeScript worker fetched typings for import map URLs with the page's credentials. An import map from an untrusted config could use that to make the host page send authenticated requests to URLs of its choosing. Fetch them with credentials: 'omit' instead. Typings that can only be fetched with credentials will no longer load. Also stop overstating what loading a config guarantees. A code comment, the console warning, the README's sharing FAQ and a test comment said or implied that it never makes the page fetch anything, but a project can still make the worker fetch modules from the CDN and fetch typings. Say what it does guarantee: loading a config does not fetch the files or manifests it names, and the config cannot change the CDN. Likewise, a test used a fetch-marker URL for cdnBaseUrl without checking for fetches. That check could not work, because CDN fetches happen in the worker, so use a plain URL.
The field now only ever holds the CDN base URL of a manifest loaded with project-src, since a config can no longer set one. Rename it and fix its comment. Also test that the value does not carry over when config is set after project-src.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Setting the
configproperty on<playground-ide>or<playground-project>used to fetch any file listed withoutcontent, followextends, and adoptcdnBaseUrlfrom the config.configis the documented way to load a shared project, so a config from an untrusted source could make the host page fetch arbitrary URLs with the user's credentials and expose the responses to code running in the preview.Changes
configno longer fetches project files or other manifests. Only files with inlinecontentand theimportMapare used. Files withoutcontent,extends, andcdnBaseUrlare dropped with a console warning.project-srcis unchanged.confighas its own type,ProjectConfig, which requirescontenton every file and has noextendsorcdnBaseUrl. The runtime handling stays for configs parsed from JSON.Breaking changes
This needs a 0.22.0 release.
extendsorcdnBaseUrlmust be loaded withproject-src, with the CDN set through thecdnBaseUrlproperty orcdn-base-urlattribute.ProjectManifesttoconfig, or set the removed fields in a literal, no longer compile.