Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub

Security & Sanitization (@methane-ui/sanitize)

Every rich text, Markdown, and AI streaming surface in Methane sanitizes untrusted HTML through @methane-ui/sanitize. Raw innerHTML and LitunsafeHTML outside @methane-ui/sanitize are statically banned by@methane-ui/lint-plugin.

Defense-in-Depth Rules

  • Native Sanitizer API + DOMPurify Parity: Feature-detects'setHTML' in Element.prototype and falls back to bundled DOMPurify configured for strict native parity (ALLOW_ARIA_ATTR: false,ALLOW_DATA_ATTR: false, KEEP_CONTENT: false,RETURN_TRUSTED_TYPE: true under Trusted Types CSP).
  • Zero innerHTML Re-Serialization: Parsed fragments move directly into the DOM without round-tripping strings.
  • URL Allowlist (isSafeUrl): Allows only https:,http:, mailto:, tel:, and relative / or# paths; rejects javascript:, data:, andvbscript:.
  • User SVGs & Uploads: Uploaded SVGs render exclusively via<img src> (never inline <svg>). Client-side upload MIME/size checks are advisory UX checks only; server-side validation is mandatory.
import { safeSetHTML, parseSafeFragment, isSafeUrl } from '@methane-ui/sanitize';

safeSetHTML(containerEl, untrustedHtml);