Skip to content

Harden Mermaid rendering, SVG delivery, and label colors - #38

Merged
Void-n-Null merged 3 commits into
VoidNullable:masterfrom
mjc:security/content-safety
Aug 27, 2026
Merged

Harden Mermaid rendering, SVG delivery, and label colors#38
Void-n-Null merged 3 commits into
VoidNullable:masterfrom
mjc:security/content-safety

Conversation

@mjc

@mjc mjc commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Make Mermaid's post-sanitization render boundary safe: errors are written as text, malformed or forged placeholders are rejected, source and complexity are capped, and comment threads share an aggregate render budget.
  • Serve SVG attachments as inert downloads with a non-active content type while retaining normal inline behavior for safe image and media formats.
  • Apply a safe fallback to invalid legacy, imported, or restored label colors before they reach frontend CSS sinks.

Regression coverage

  • Mermaid limit tests keep ordinary diagrams renderable while rejecting oversized and dense sources, enforce aggregate byte and block limits, and confirm rejected input does not consume the shared budget.
  • Mermaid render-boundary tests prove forged complex placeholders and malformed encoded sources never reach the renderer, multiple blocks share one budget, cancelled renders cannot mutate detached content, valid diagrams still render, and failures remain inert text.
  • The label-color helper test preserves valid hexadecimal colors and replaces CSS source with the default color.
  • The component rendering test feeds an unsafe stored color through the actual color picker and confirms neither the original value nor an injected CSS property reaches its rendered style.
  • The attachment response test uploads an SVG containing script, then verifies it is returned as an attachment with an inert content type and restrictive content policy.

@mjc
mjc marked this pull request as ready for review August 24, 2026 20:55
Copilot AI lite review requested due to automatic review settings August 24, 2026 20:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Void-n-Null
Void-n-Null merged commit fa3d81d into VoidNullable:master Aug 27, 2026
3 checks passed
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.

3 participants