Summary
NoteGen before version 0.32.0 is vulnerable to cross-site scripting in its AI chat preview, where markdown responses are rendered as raw HTML without sanitization or Content Security Policy.
If attacker-controlled content can influence the AI prompt, the resulting response may contain executable markup that runs in the privileged Tauri webview, leading to arbitrary script execution in the application context.
Affected context
This vulnerability occurs in NoteGen's AI chat preview feature, where AI-generated markdown responses are converted to HTML using markdown-it with html:true and then injected into the DOM using dangerouslySetInnerHTML.
It arises in deployments where model prompts can be influenced by attacker-controlled artifacts (such as malicious REFERENCE.md skills) and where HTML output is trusted by the rendering layer, combined with a CSP that is unset or permissive.
Exploit preconditions
- Attack surface: NoteGen AI chat preview rendered inside the Tauri webview.
- Required access: Ability to introduce or modify content that reaches the AI model prompt (e.g., supplying a malicious skill file or document influencing generation).
- Trigger point: User opens or views a chat response that includes crafted HTML/JavaScript markup produced by the model.
- Why exploitation is possible: The application allows full HTML output from markdown-it, injects it via
dangerouslySetInnerHTML, performs no HTML sanitization, and uses anullContent Security Policy, allowing script-like constructs (e.g.,img onerror) to execute.
Why this happens
The root cause is an unsafe rendering pipeline that treats AI-generated markdown as trusted HTML and injects it directly into the DOM.
By configuring markdown-it with html:true and using dangerouslySetInnerHTML without sanitization or CSP protections, NoteGen exposes a classic CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).
Abstractly, the bug class is rendering untrusted, model-influenced content as executable markup in a privileged web context, without applying output encoding or filtering based on a strict allowlist of safe HTML constructs.
Potential impact
- Attacker-controlled scripts may execute within the NoteGen Tauri webview.
- Malicious code could access, modify, or exfiltrate application data and user content.
- The application state and configuration could be tampered with or corrupted.
- Further compromise of the local environment may be possible depending on available Tauri APIs and integrations.
General mitigation guidance
Effective mitigation focuses on treating AI-generated content as untrusted and restricting what can be executed in the rendering context.
Patterns that typically reduce risk include:
- Applying robust HTML sanitization with a strict allowlist before inserting content into the DOM.
- Preferring text-based rendering (e.g., markdown-to-safe-HTML with scripts and event handlers stripped) and avoiding direct usage of
dangerouslySetInnerHTMLwherever possible. - Enforcing a conservative Content Security Policy that blocks inline scripts, event handlers, and dynamic code injection, even within the desktop webview.
- Segmenting privileged functionality from the content-rendering surface, ensuring that rendered output cannot directly invoke sensitive APIs.
How teams detect issues like this
Detection can rely on a mix of code-level and behavioral analysis:
- Static analysis rules that flag use of
dangerouslySetInnerHTMLor equivalent sinks combined with unvalidated, unescaped content sources, especially AI-generated data. - Code review practices that treat any HTML-capable markdown renderer with
html:trueas a high-risk component and require sanitization or encoding checks. - Security policies that mandate CSP definitions and prohibit inline event handlers,
javascript:URLs, and other script-capable constructs in rendered content. - Automated tooling or linters integrated into CI pipelines to identify unsanitized rendering paths and unsafe DOM insertion patterns.

