Skip to main content

XSS CVE-2026-40262

HIGH
Cross-site Scripting (XSS) (CWE-79)
2026-04-13 https://github.com/enchant97/note-mark GHSA-9pr4-rf97-79qh
8.7
CVSS 3.1 · GitHub Advisory
Share

Severity by source

GitHub Advisory PRIMARY
8.7 HIGH
AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N

Primary rating from GitHub Advisory · only source for this CVE.

CVSS VectorGitHub Advisory

CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N
Attack Vector
Network
Attack Complexity
Low
Privileges Required
Low
User Interaction
Required
Scope
Changed
Confidentiality
High
Integrity
High
Availability
None

Lifecycle Timeline

6
Analysis Updated
Apr 17, 2026 - 01:29 vuln.today
v2 (cvss_changed)
Re-analysis Queued
Apr 17, 2026 - 01:22 vuln.today
cvss_changed
Analysis Generated
Apr 15, 2026 - 12:35 vuln.today
Analysis Generated
Apr 13, 2026 - 19:30 vuln.today
Patch released
Apr 13, 2026 - 19:30 nvd
Patch available
CVE Published
Apr 13, 2026 - 19:23 nvd
HIGH 8.7

DescriptionGitHub Advisory

Summary

A stored same-origin XSS vulnerability allows any authenticated user to upload an HTML, SVG, or XHTML file as a note asset and have it executed in a victim’s browser under the application’s origin. Because the application serves these files inline without a safe content type and without nosniff, browsers can sniff and render active content, giving the attacker access to authenticated Note Mark API actions as the victim.

Details

This issue results from three compounding flaws in the asset handling and delivery path.

1. Asset delivery can be used as an attack vector

The asset delivery route can be used to deliver attacker-controlled uploaded content directly to a victim by URL.

Relevant route:

  • handlers/assets.go:40
go
huma.Get(api, "/api/notes/{noteID}/assets/{assetID}", h.GetNoteAssetContentByID)

This makes the uploaded asset reachable by direct navigation, which provides the delivery mechanism for the payload.

2. Text-based active content is served with an empty Content-Type

The asset handler relies on h2non/filetype for content-type detection:

  • handlers/assets.go:147
go
kind, _ := filetype.Match(buf)
if kind != filetype.Unknown {
    contentType = kind.MIME.Value
}

The detection library uses magic-byte matching and does not identify text-based formats such as HTML, SVG, JavaScript, XML, or XHTML. For those files, filetype.Match returns Unknown, leaving Content-Type unset or empty.

As a result, uploaded active content is served without an authoritative MIME type.

3. Files are rendered inline and sniffed by the browser

The asset response is sent with inline disposition:

  • handlers/assets.go:153
go
w.Header().Set("Content-Disposition", fmt.Sprintf("inline; filename=\"%s\"", asset.Name))

At the same time, the response does not set:

http
X-Content-Type-Options: nosniff

This combination is dangerous:

  • the uploaded file contains attacker-controlled active markup
  • the browser is instructed to render it inline
  • the response does not provide a trustworthy content type
  • content sniffing is not disabled

Under these conditions, browsers may detect HTML or SVG content and execute embedded JavaScript. Because the asset is served from the application’s own origin, the script runs with same-origin access to the application and its authenticated APIs.

This turns an uploaded asset into a stored XSS payload that executes when a victim opens the asset URL.

PoC

The issue can be reproduced by uploading a text-based active content file such as HTML or SVG as a note asset, then opening the served asset URL in a browser and observing that script executes in the context of the application origin.

Impact

  • Type: Stored same-origin cross-site scripting (XSS)
  • Who is impacted: Any user who can be induced to open a malicious asset URL, and any deployment allowing asset uploads
  • Security impact: An attacker can execute JavaScript in the victim’s authenticated application context, allowing access to private notes, books, profile data, and authenticated API actions
  • Privileges required: A valid low-privilege user account capable of uploading note assets
  • User interaction: Required, because the victim must navigate to the malicious asset URL
  • Scope: Changed, because attacker-controlled content executes in the victim’s origin and impacts other users rather than remaining confined to the attacker’s own account

AnalysisAI

Stored cross-site scripting in Note Mark note-taking application allows authenticated users to execute arbitrary JavaScript in victims' browsers by uploading HTML/SVG files as note assets. The vulnerability affects the Go backend's asset delivery mechanism (github.com/enchant97/note-mark), which serves uploaded files inline without setting Content-Type headers or X-Content-Type-Options: nosniff, enabling browser MIME-sniffing attacks. Attackers with low-privilege accounts can create malicious asset URLs that, when opened by victims, execute scripts with full access to authenticated API endpoints, private notes, and user data. CVSS 8.7 (High) reflects the changed scope impact where one user's malicious upload affects other users' security context. Vendor-released patch available in v0.19.2.

Technical ContextAI

This vulnerability exploits the interaction between Go's asset serving implementation and browser MIME-sniffing behavior. The Note Mark backend uses the h2non/filetype library for content-type detection, which relies on magic-byte matching and cannot identify text-based formats (HTML, SVG, XML, XHTML, JavaScript). When these files are uploaded, filetype.Match returns Unknown, leaving the Content-Type header empty or unset. The asset handler in handlers/assets.go serves files with Content-Disposition: inline but fails to set X-Content-Type-Options: nosniff. According to browser security specifications, when no authoritative MIME type is provided and nosniff is absent, browsers perform content sniffing to determine file types. Modern browsers can detect HTML/SVG markup patterns and execute embedded scripts. Since assets are served from the application's own origin (same-origin context) rather than a separate asset domain, any executed JavaScript inherits the full security context of the authenticated session, including cookies, localStorage, and CSRF tokens. This is a textbook CWE-79 (Improper Neutralization of Input During Web Page Generation) where user-controlled content becomes executable code due to improper content handling.

RemediationAI

Upgrade to Note Mark v0.19.2 or later, which contains the security fix committed in 6bb62842ccb956870b9bf183629eba95e326e5e3 (release notes: https://github.com/enchant97/note-mark/releases/tag/v0.19.2, patch commit: https://github.com/enchant97/note-mark/commit/6bb62842ccb956870b9bf183629eba95e326e5e3). The patch likely implements one or more of these mitigations: setting X-Content-Type-Options: nosniff on asset responses to prevent MIME-sniffing, forcing Content-Type to application/octet-stream for unrecognized file types to trigger download instead of inline rendering, or serving user-uploaded assets from a separate sandboxed domain to break same-origin context. If immediate upgrade is not feasible, implement these compensating controls: configure a reverse proxy (nginx/Apache) to add X-Content-Type-Options: nosniff and Content-Security-Policy: default-src 'none'; sandbox headers to all /api/notes/*/assets/* responses (trade-off: breaks legitimate inline viewing of safe assets like images), restrict asset upload functionality to trusted administrative users only via application access controls (trade-off: limits core note-taking functionality), or serve assets through a dedicated CDN/subdomain with restrictive CORS policies to break same-origin access (trade-off: requires infrastructure changes and may affect application architecture). Review access logs for suspicious asset access patterns or unusual file upload activity as potential indicators of exploitation attempts during the vulnerable window.

Share

CVE-2026-40262 vulnerability details – vuln.today

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy