/

CVE-2026-42090

Severity:

CRITICAL RISK

(9.6)

Stored Cross-Site Scripting (XSS) in Notesnook Export Flow

CVE-2026-42090

Analyzed

Vulnerability type

Category:

Stored Cross-Site Scripting (XSS)

CWE:

CWE-79, CWE-94

Impact:

Remote Code Execution via Stored XSS in Desktop Application

Severity:

CRITICAL RISK

(9.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A stored cross-site scripting vulnerability in Notesnook's note export flow allows unescaped note fields to be injected into an HTML template and executed when exporting notes to PDF.

When this malicious HTML is rendered in an unsandboxed, same-origin iframe, it enables script execution in the Notesnook origin, which can escalate to remote code execution in the Electron-based desktop app due to permissive WebView settings.

Affected context

This vulnerability occurs in the Notesnook export-to-PDF functionality, where user-controlled note data (such as title, headline, and content) is embedded into an HTML template.

The issue is present when:

  • Notes are created or edited with untrusted content that later gets exported;
  • The export pipeline inserts these fields into HTML without escaping or sanitization;
  • The resulting HTML is rendered inside a same-origin, unsandboxed iframe (via iframe.srcdoc) in the Web/Desktop and mobile apps.

The most severe impact is seen in the desktop app, where the Electron environment allows Node.js access from rendered web content.

Exploit preconditions

  • Attack surface: Notesnook note content and metadata that eventually pass through the export-to-HTML/PDF functionality.
  • Required access: Ability to create, edit, or otherwise influence the contents of a note (e.g., via a shared device, compromised user account, or any workflow where untrusted content can land in a note).
  • Trigger point: User-initiated note export, particularly export to PDF, which causes the generated HTML to be rendered in a same-origin iframe using iframe.srcdoc.
  • Why exploitation is possible:
  • Note fields are inserted into the HTML export template without HTML escaping or sanitization.
  • The HTML is rendered in an iframe that is not sandboxed and shares the same origin as the main Notesnook application.
  • In the desktop app, Electron is configured with nodeIntegration: true and contextIsolation: false, exposing powerful Node.js APIs to injected scripts and enabling RCE.

Why this happens

The root cause is improper output encoding of user-controlled note fields when generating HTML for export.

Instead of treating note titles, headlines, and content as plain text and encoding them before insertion into the HTML template, the application directly interpolates these values into HTML.

This behavior maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting), because it allows attacker-controlled data to become active script.

The escalation to remote code execution in the desktop app ties into CWE-94: Improper Control of Generation of Code, as injected JavaScript is given access to Node.js APIs due to permissive Electron configuration, allowing arbitrary code execution on the host machine.

Potential impact

  • Stored XSS that executes whenever a malicious note is exported to PDF.
  • Theft or manipulation of user data accessible within the Notesnook origin (e.g., reading or modifying notes).
  • Account takeover scenarios, such as exfiltrating authentication tokens or session data, where available in the renderer context.
  • Arbitrary command execution on the host machine for desktop users, via Node.js APIs exposed by Electron.
  • Installation of additional malware or persistence mechanisms on systems running the desktop app.

General mitigation guidance

Effective mitigation focuses on strict output encoding, content isolation, and hardening of the desktop runtime:

  • Apply context-appropriate HTML escaping to all user-controlled fields (titles, headlines, content) before inserting them into any HTML template. Treat note content as untrusted text by default.
  • Where rich text is required, use a whitelisting HTML sanitizer that strips or neutralizes scripts, event handlers, and dangerous attributes, instead of attempting ad-hoc filtering.
  • Render untrusted or semi-trusted HTML in sandboxed iframes (sandbox attribute) with the minimal set of allowed capabilities, and avoid sharing the same origin if possible.
  • In the Electron desktop environment, follow secure-by-default settings:
  • Disable nodeIntegration in renderer processes that display web content.
  • Enable contextIsolation and use secure, well-defined IPC channels for privileged operations.
  • Avoid exposing Node.js or OS-level capabilities directly to web-origin JavaScript.
  • Enforce a defense-in-depth approach: treat any data that originated from users or external systems as untrusted at every processing step, not only at input time.

How teams detect issues like this

Organizations and projects can detect similar patterns through a combination of static analysis, review practices, and security testing:

  • Static analysis and linters:
  • Flag direct interpolation of user-controlled data into HTML strings, templates, or srcdoc without encoding.
  • Detect patterns where iframe.srcdoc is assigned dynamic content without sanitization.
  • For Electron apps, flag the use of nodeIntegration: true and contextIsolation: false in production builds.
  • Code review signals:
  • Review all export/preview flows where rich text or HTML is generated from note content or metadata.
  • Verify that any HTML templating layer applies consistent, centralized output encoding.
  • Inspect uses of iframe and webviews to ensure sandboxing and strict origins.
  • Security testing:
  • Perform manual and automated XSS testing on note creation, editing, and export functionality by injecting benign test payloads.
  • Use dynamic analysis tools that simulate note workflows and attempt payload execution on export and preview steps.
  • Policy and CI integration:
  • Integrate secure coding guidelines for Electron, including a policy that forbids Node.js access in standard renderer processes.
  • Add CI checks that enforce safe Electron configuration and template encoding patterns before merging changes.

Sources

SourceLink
github.comgithub.com/streetwriters/notesnook/releases/tag/3.3.20-android
github.comgithub.com/streetwriters/notesnook/releases/tag/v3.3.15
github.comgithub.com/streetwriters/notesnook/security/advisories/GHSA-fjm8-jg78-89h4

Frequently asked

questions

The vulnerability is exploitable wherever an attacker can influence note content that is later exported. In shared or multi-device scenarios, or if an account is compromised, an attacker can plant a malicious note that triggers when the user exports it to PDF, leading to stored XSS in all clients and RCE specifically in the desktop app.

Direct device access is not strictly required. The attacker mainly needs a path to inject malicious content into a note under the victim's account. Once the victim exports that note to PDF in a vulnerable desktop environment, the attacker's script can execute and potentially run arbitrary code on the victim's machine.

The safest pattern is to treat all note content and metadata as untrusted and enforce strict output encoding or sanitization at every point where this data is rendered into HTML. Additionally, untrusted content should be isolated (e.g., sandboxed iframes), and Electron configurations must follow secure defaults by disabling Node integration and enabling context isolation in renderer processes.

Adopt a standard encoding/sanitization library for all HTML rendering, enforce a "no raw HTML from user input" rule unless explicitly sanitized, and add security reviews for any new export, preview, or rich-text features. For desktop and hybrid apps, maintain hardened Electron/webview settings as a baseline policy, and verify these configurations through automated checks in the build and review pipelines.

Find out what's already
exploitable in your codebase.