fix(html,ansi): escape plugin fallbacks and strip terminal control characters - #377
Open
atinux wants to merge 5 commits into
Open
fix(html,ansi): escape plugin fallbacks and strip terminal control characters#377atinux wants to merge 5 commits into
atinux wants to merge 5 commits into
Conversation
When KaTeX or the mermaid renderer throw on malformed input, the catch branches interpolated the raw markdown-controlled source into the returned HTML — stored XSS, although raw HTML is otherwise opt-in. Route the fallback through a shared escapeHtml helper (also deduplicating the binding plugin's local copy).
The ANSI renderer concatenates node text, code bodies, and hrefs verbatim, so raw ESC/BEL/C1 bytes from untrusted markdown reached the terminal: forged output, overwritten lines, and OSC sequences (window title, clipboard on permissive terminals). Sanitize the document (copy, no mutation) in renderAnsiFromDocument: remove C0 controls except tab/newline, DEL, and the C1 range from strings and attribute values before rendering.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
comark
@comark/angular
@comark/ansi
@comark/html
@comark/nuxt
@comark/react
@comark/svelte
@comark/vue
commit: |
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.
What
Escapes the raw source in
@comark/html's math and mermaid catch branches (via a sharedescapeHtmlhelper, deduplicating the binding plugin's copy), and strips C0/C1/DEL control characters from the document before rendering in@comark/ansi.Why
A security scan found two output-encoding gaps in the renderer packages: when KaTeX or the mermaid renderer throw on malformed input, the fallback interpolated the author-controlled source into raw HTML (stored XSS even without the raw-HTML plugin); and the ANSI renderer passed ESC/BEL/OSC bytes from untrusted markdown straight to the terminal, enabling forged output and clipboard/title manipulation on permissive terminals. The ANSI sanitization copies the document rather than mutating it, and keeps tab/newline intact.
🤖 Prepared by an AI agent (OpenCode) from a security-audit findings list; commits are signed by the repository owner's key.