/

CVE-2026-40262

Severity:

HIGH RISK

(8.7)

Stored Cross-Site Scripting (XSS) via File Upload

CVE-2026-40262

Deferred

Vulnerability type

Category:

Stored Cross-Site Scripting (XSS) via File Upload

CWE:

CWE-79, CWE-434

Impact:

Authenticated Session Hijacking and Stored Cross-Site Scripting

Severity:

HIGH RISK

(8.7)

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

Note Mark's asset delivery handler can serve user-uploaded HTML and SVG files without a proper Content-Type or nosniff protection, allowing browsers to treat them as executable documents.

An authenticated attacker can upload active content (for example, HTML or SVG with JavaScript) and trick a victim into visiting the asset URL, leading to stored cross-site scripting under the Note Mark origin with access to the victim's authenticated session and API capabilities.

Affected context

This vulnerability arises in Note Mark deployments that:

  • Allow authenticated users to upload note assets (attachments),
  • Use the asset delivery handler that serves files inline,
  • Rely on magic-byte detection for content type, which does not classify HTML/SVG/XHTML as text-based formats,
  • Return these files with an empty Content-Type, no X-Content-Type-Options: nosniff, and inline disposition.

In that context, browsers are free to sniff and interpret uploaded HTML or SVG as active web documents, running attacker-supplied JavaScript in the context of the Note Mark application.

Exploit preconditions

  • Attack surface: HTTP(S) asset URLs served by the Note Mark instance.
  • Required access: An attacker must have an authenticated account with permission to upload note assets.
  • User interaction: A victim must open or be redirected to the attacker-controlled asset URL (for example, via a shared link, embedded reference, or social engineering).
  • Trigger point: The browser requests the uploaded file, receives it with no Content-Type and no X-Content-Type-Options: nosniff, and then performs content sniffing.
  • Why exploitation is possible: Because the server does not explicitly identify the file type or prevent sniffing, the browser may treat HTML/SVG/XHTML uploads as web pages or scripts, allowing embedded JavaScript to execute under the Note Mark origin.

Why this happens

The root cause is a combination of:

  • CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting): User-controlled content (HTML/SVG) is delivered in a way that allows it to be interpreted as part of the web application's active content, rather than as a passive download.
  • CWE-434: Unrestricted Upload of File with Dangerous Type: Uploaded files capable of executing script in the browser are not restricted, transformed, or safely delivered.

The asset delivery handler:

  • Serves user uploads inline instead of as downloads,
  • Relies on magic-byte detection that does not correctly identify text-based active formats,
  • Omits explicit Content-Type and protective headers such as X-Content-Type-Options: nosniff.

This abstractly represents an insecure pattern where file upload endpoints allow active content to be hosted and executed from the same origin as the application, enabling stored XSS.

Potential impact

  • Theft or misuse of the victim's authenticated session within the Note Mark application.
  • Unauthorized execution of API actions on behalf of the victim, such as reading, modifying, or deleting notes.
  • Exfiltration of sensitive data stored in the application, including private notes or shared workspaces.
  • Cross-account attack paths, where compromised accounts are used to propagate additional malicious content or links.
  • Potential pivoting into integrated services if the application exposes connectors or webhooks tied to the user's identity.

General mitigation guidance

Effective mitigations focus on hardening file upload handling and output contexts so that user content cannot be executed as active code:

  • Serve uploads as passive content: Prefer Content-Disposition: attachment for untrusted file types, especially HTML, SVG, XHTML, and other active formats.
  • Set explicit, conservative Content-Type: Do not leave Content-Type empty; use explicit types and avoid serving untrusted files as HTML or other executable types.
  • Enforce X-Content-Type-Options: nosniff: Prevent browsers from content-sniffing and interpreting arbitrary uploads as executable documents.
  • Restrict dangerous file types: Consider blocking or transforming uploads that can host script (e.g., HTML, SVG, XHTML) when they are not strictly required.
  • Isolate user content origins: Where possible, serve uploaded files from a separate domain or origin that does not share authentication or powerful APIs with the main application.
  • Apply least-privilege access to APIs: Design client-side APIs so that a single authenticated session has only the minimum capabilities required for normal use, reducing impact if it is abused via XSS.

How teams detect issues like this

Detection efforts can combine review of HTTP behavior, code paths, and security policies:

  • Code review signals:
  • Asset or upload handlers that return inline content without strict Content-Type handling.
  • Absence of X-Content-Type-Options: nosniff on responses serving user-uploaded files.
  • Logic that permits HTML, SVG, or similar file types to be uploaded without transformation or isolation.
  • Static analysis patterns:
  • Rules flagging endpoints that serve arbitrary files from user-controlled locations.
  • Checks for uses of content-type detection that may default to unknown or empty types.
  • Runtime and configuration checks:
  • Security scanners that crawl the app, upload test payloads, and verify how uploads are served.
  • HTTP response inspection in staging environments to ensure headers and MIME types are correctly set for user content.
  • Policy enforcement:
  • CI/CD gates that require explicit MIME handling and security headers for routes serving uploaded content.

Sources

SourceLink
github.comgithub.com/enchant97/note-mark/commit/6bb62842ccb956870b9bf183629eba95e326e5e3
github.comgithub.com/enchant97/note-mark/releases/tag/v0.19.2
github.comgithub.com/enchant97/note-mark/security/advisories/GHSA-9pr4-rf97-79qh

Frequently asked

questions

The issue is exploitable in any deployment where attackers can register or obtain accounts that allow file uploads, and where they can convince other users to open links to their uploaded assets. Because the attack executes under the application's origin, the impact can be significant for affected users.

No special administrative privileges are required beyond the ability to upload note assets. Any authenticated user with upload capability can prepare a malicious HTML or SVG asset and then distribute the corresponding URL to potential victims.

The safest pattern is to ensure that user-uploaded files cannot execute as active content from the application origin. This typically involves serving uploads with explicit, non-executable MIME types, using Content-Disposition: attachment for unsafe types, setting X-Content-Type-Options: nosniff, and optionally isolating uploads on a separate domain.

Treat file uploads as untrusted data by default and design delivery paths that never render uploads as first-class application pages. Establish secure defaults for response headers, thoroughly review new upload or asset-handling functionality, and include automated checks to detect when user-controlled content might be interpreted as script or HTML by the browser.

Find out what's already
exploitable in your codebase.