Skip to content

fix(plugins): broaden SVG plain-geometry boundary and log rejected icons in dev builds - #261

Merged
Hona merged 1 commit into
devfrom
ws6/svg-sanitizer-boundary
Nov 20, 2026
Merged

Hona merged 1 commit into
devfrom
ws6/svg-sanitizer-boundary

Conversation

@Hona

@Hona Hona commented Nov 20, 2026

Copy link
Copy Markdown
Member

Fixes the dialog-wsl warning icon regression caught by REFERENCE after #251 (51986c66), where plugins/wsl/icons/warning.svg was rejected because clip-rule="evenodd" was missing from PRESENTATION_ATTRS.

Boundary Audit (crates/opencode-plugin-runtime/src/svg/{mod,validate}.rs)

  • Allowed & value-validated plain-geometry attributes:
    • fill-rule / clip-rule: "nonzero" | "evenodd" only.
    • stroke-dasharray: "none" or 1..=32 finite lengths in [0, 1024] with sum >= 0.5 (blocks tiny-dash tiny-skia stroking DoS); stroke-dashoffset: [-1024, 1024].
    • stroke-linecap (butt|round|square), stroke-linejoin (miter|round|bevel), stroke-miterlimit ([1, 100]), stroke-width ([0, 256]), opacity/fill-opacity/stroke-opacity ([0, 1]).
    • paint-order (normal or distinct fill/stroke/markers), shape-rendering, vector-effect (none|non-scaling-stroke), visibility, display (none emitted; block|inline|initial dropped), fill/stroke/color (none, currentColor, inherit, transparent, black, white, #hex, canonicalized rgb()/rgba()).
    • Root metadata (validated & stripped): xmlns="http://www.w3.org/2000/svg", xmlns:xlink="http://www.w3.org/1999/xlink", version, xml:space, overflow, preserveAspectRatio, image-rendering, text-rendering, x/y, percentage width/height (when viewBox is present), pathLength, and safe style declarations (only validated presentation attrs + color: var(--<ident>); arbitrary CSS properties are now refused).
  • Still refused everywhere: <script>, <foreignObject>, <style>, <image>, <use>, <filter>, <defs>, <mask>, <clipPath>, on*, href, xlink:href, src, filter, clip-path, mask, marker-*, url(...), http(s):, data:, file:, javascript:, expression(, @import, arbitrary CSS in style, tiny-dash DoS, and all size/depth/element/shape/path caps.
  • Dev-build diagnostics (icons.rs, svg/{mod,validate}.rs):
    • Sanitizer returns Result<SanitizedIcon, String> naming the exact offending element, attribute, or CSS property.
    • icons::replace_plugin / icons::intern_svg emit one eprintln! line in debug_assertions builds (plugin <id>: icons/<name>.svg rejected: <reason>) in addition to the plugin console warning.

Proof (proof/ws6/svg-boundary-fix/)

  • Built-in plugin icon audit (before -> after):
    Icon Before (feat(plugins): contract 1.6 with hardened plugin-declared SVG icons #251) After
    plugins/goal/icons/active.svg pass pass
    plugins/goal/icons/complete.svg pass pass
    plugins/goal/icons/paused.svg pass pass
    plugins/pairing/icons/dialog-close.svg pass pass
    plugins/pairing/icons/pair.svg pass pass
    plugins/wsl/icons/chevron.svg pass pass
    plugins/wsl/icons/download.svg pass pass
    plugins/wsl/icons/warning.svg (clip-rule="evenodd") FAIL pass
    Upstream Figma browser/assets/{viewport-device-chevron,viewport-rotate}.svg (overflow="visible", style="display: block;") FAIL pass
  • dialog-wsl vs proof/reference/captures/local/ warning icon box:
    • 1x light ([620..660, 320..360]): 0 diff px (>2), maxDelta = 0, filled triangle 520/520 px.
    • 1x dark ([620..660, 320..360]): 0 diff px (>2), maxDelta = 1, filled triangle 520/520 px.
    • 1.5x light ([930..990, 480..540]): 0 diff px (>2), maxDelta = 1, filled triangle 1200/1200 px.
    • 1.5x dark ([930..990, 480..540]): 0 diff px (>2), maxDelta = 0, filled triangle 1200/1200 px.
  • Hostile/invalid icons (15/15 refused with explicit dev-build stderr diagnostics): use-bomb, filter-dos, huge-paths-20k, deep-2000, script-tag, foreign-obj, external-href, clip-path-attr, mask-attr, bad-clip-rule, bad-fill-rule, bad-style-css, tiny-dash-dos, zero-vb, malformed.
  • scripts/guardrails.ps1 (5/5), cargo check --workspace, and scripts/web.ps1 -Check green.

…ons in dev builds

- Allow Figma and common plain-geometry SVG attributes with strict value validation in crates/opencode-plugin-runtime/src/svg/{mod,validate}.rs: clip-rule and fill-rule (nonzero|evenodd only), stroke-dasharray (<= 32 finite entries, sum >= 0.5 to block tiny-dash DoS), stroke-dashoffset, paint-order, shape-rendering, vector-effect (none|non-scaling-stroke), visibility, display (none emitted; block/inline/initial dropped), color, rgb()/rgba()/inherit paints, root overflow/version/xml:space/preserveAspectRatio/percentage dims (when viewBox is present), and validated style declarations (refusing arbitrary CSS properties).
- Keep all security boundaries intact: refuse <script>, <foreignObject>, <style>, <image>, <use>, <filter>, <defs>, <mask>, <clipPath>, on* handlers, href/xlink:href/src/filter/clip-path/mask/marker-*, external URLs/data URIs/url(...), arbitrary CSS, and size/depth/element/shape/path/dash limits.
- Return structured error strings naming the offending element, attribute, or CSS property, and emit a dev-build stderr diagnostic (`plugin <id>: icons/<name>.svg rejected: <reason>`) in icons::replace_plugin and icons::intern_svg so rejected icons are never silent during development.
- Fixes the dialog-wsl warning icon regression introduced by #251 (plugins/wsl/icons/warning.svg uses clip-rule="evenodd").
@Hona
Hona merged commit b8cdd71 into dev Nov 20, 2026
@Hona
Hona deleted the ws6/svg-sanitizer-boundary branch November 20, 2026 09:11
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR test build retired — merged into dev. Install or auto-update OpenCode (Rune) from https://anoma.ly/release/opencode/desktop-rune/dev/macos-arm64-dmg.

Hona added a commit that referenced this pull request Nov 20, 2026
…ing (#266)

- Fold verified fleet PRs #247, #251, #252, #253, #254, #255, #256, #257,
  #258, #260, #261, #262, #263, #264, and #265 (Rune #1290 PRE-11 / #1296)
  into docs/upstream-sync/ledger.{json,md}
- Audit upstream anomalyco/opencode through 92d35f8e18 (+9 commits past
  bf683129fa), adding UP-107..UP-113 and assigning UP-106/UP-108/UP-111 to
  BROWSER-UI
- Update scripts/upstream-sync-check.ts to skip pure *.fixture.* test files
  and route browser UI/history vs extensions commits to BROWSER-UI and WS-9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant