feat(web): add declarative community skins - #3340
Conversation
🦋 Changeset detectedLatest commit: 7d5e8ff The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d5e8ff691
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if ( | ||
| manifest.webSkin !== undefined && | ||
| (hasRuntimeCapabilities(manifest) || hasDeclaredRuntimeCapabilities(raw)) |
There was a problem hiding this comment.
Enforce runtime isolation for every webSkin declaration
When webSkin is malformed, references a missing file, or contains invalid tokens, readWebSkin returns undefined, so this condition skips the runtime-capability check. A plugin declaring that invalid skin alongside a system prompt, hook, MCP server, or Skill therefore remains in the ok state and executes those capabilities, violating the promised security boundary for code-free skins. Base the exclusivity check on the raw presence of webSkin, even when its contents fail validation.
Useful? React with 👍 / 👎.
| function hasUnsafeWebSkinTokenValue(value: string): boolean { | ||
| if ( | ||
| /[;{}@\\\u0000-\u001F\u007F]/u.test(value) || | ||
| /javascript\s*:|!\s*important|\/\*|\*\//iu.test(value) | ||
| ) { | ||
| return true; | ||
| } | ||
| for (const match of value.matchAll(/([A-Za-z][A-Za-z0-9-]*)\s*\(/gu)) { | ||
| if (!WEB_SKIN_SAFE_FUNCTION_NAMES.has((match[1] ?? '').toLowerCase())) return true; |
There was a problem hiding this comment.
Reject syntactically malformed CSS token values
When a value contains only allowlisted text but has unbalanced CSS syntax—for example an unmatched quote or calc(—this validator accepts it and compileWebSkinTokens writes it verbatim. The browser then discards the declaration, and an unterminated string or function can consume subsequent generated blocks, allowing one enabled skin to prevent later tokens or skins from applying. Validate balanced strings, functions, and delimiters rather than checking function names alone.
Useful? React with 👍 / 👎.
Summary
webSkin.tokenscontribution to Kimi plugin manifestsSecurity
!important, unknown functions, image/network-loading constructs, executable content, and arbitrary CSSno-store,nosniff, and same-origin resource policy headersVerification
pnpm --filter @moonshot-ai/agent-core-v2 typecheckpnpm --filter @moonshot-ai/kap-server typecheckpnpm lintpnpm --filter @moonshot-ai/kimi-code buildExample skin: https://github.com/sdfsfsk/kimi-code-skin-moonlight