Summary
Trilium Notes contains a stored cross-site scripting vulnerability in search and note-autocomplete interfaces that insert a note icon value into an HTML class attribute without adequate encoding. When a victim opens a new tab or uses the Ctrl+J shortcut, stored content may execute in the Electron application context and could allow operating-system command execution as the victim.
Affected context
The issue occurs in Trilium Notes versions before the security fix when the #iconClass label value is retrieved and rendered by the quick-search or note-autocomplete interfaces. Risk is higher when an attacker can create or modify notes or labels and when the application runs with Node.js integration enabled and context isolation disabled, allowing renderer-side script execution to access operating-system capabilities.
Exploit preconditions
- Attack surface: The desktop application's quick-search and note-autocomplete rendering paths
- Required access: Ability to create or modify stored note or label content that is later viewed by another user
- Trigger point: The victim opens a new tab or invokes the Ctrl+J search interface
- Why exploitation is possible: A stored label value is inserted into an HTML class attribute without sufficient attribute encoding, and the Electron renderer has elevated integration capabilities
Why this happens
The underlying bug is context-insensitive output handling: a value returned from getNoteIcon() is treated as trusted markup when inserted into an HTML attribute. This permits stored data to alter the rendered document and execute script, mapping primarily to CWE-79: Improper Neutralization of Input During Web Page Generation. The related CWE-83 and CWE-693 classifications reflect unsafe script-related HTML handling and insufficient defensive controls in the rendering environment.
Potential impact
- A malicious stored value may execute script when a vulnerable interface is opened.
- An attacker could act with the victim's application privileges.
- Operating-system commands could be executed as the victim where Electron integration permits it.
- Local notes, application data, or connected services could be accessed or modified.
- The application environment could be used as a stepping stone for further compromise.
General mitigation guidance
Mitigation generally focuses on treating all note, label, and metadata values as untrusted before rendering them.
Common defensive patterns include:
- Apply context-appropriate HTML attribute encoding at every rendering sink.
- Prefer DOM APIs that assign data as text or attributes rather than concatenating markup.
- Validate icon-class values against a narrow allowlist of permitted class names.
- Reduce renderer privileges by disabling Node.js integration and enabling context isolation where compatible.
- Expose only narrowly scoped, least-privilege functionality through secure preload bridges.
- Apply a restrictive content security policy and avoid inline script execution.
- Limit which users or synchronization sources can create stored metadata.
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules identifying string interpolation or concatenation into HTML attributes.
- Code review checks for raw values returned from note metadata, labels, or search results.
- Tests that render special-character and markup-like values in every search and autocomplete view.
- Policy enforcement requiring contextual output encoding and safe DOM APIs.
- Electron configuration checks for Node.js integration, disabled context isolation, and broad preload exposure.
- Runtime monitoring for unexpected renderer process behavior or child-process creation.
Automated security review tools can help identify likely DOM XSS sinks, but findings should be confirmed against the actual rendering context and Electron security configuration.

