Summary
Trilium's automatic image-download feature can treat local file URLs in note images as readable resources, allowing an authenticated user to disclose files accessible to the Trilium process. The same behavior may also enable uncontrolled memory consumption when the feature reads an effectively unbounded local source, potentially crashing the server.
Affected context
The issue occurs in Trilium deployments where automatic image downloading is enabled and note HTML is processed through the image-fetching workflow. It may be reachable through the web interface, ETAPI, web clipper, or note-import mechanisms when an authenticated session or valid ETAPI token can create or update notes containing image references.
Exploit preconditions
- Attack surface: Note creation or modification flows that scan HTML image sources
- Required access: An authenticated Trilium session or an ETAPI token
- Trigger point: Saving or importing a note causes image sources to be fetched and stored as attachments
- Why exploitation is possible: Local-file schemes remain accepted after sanitization, and the resulting paths are passed to filesystem-reading logic without sufficient path validation
Why this happens
The vulnerability results from trusting a user-controlled image source as though it were an external network resource while allowing local-file schemes to reach filesystem access code. Without restricting resource schemes and validating permitted paths, the application can read files available to its process and persist their contents as note attachments. This maps primarily to CWE-73: External Control of File Name or Path, with related consequences involving excessive resource consumption and exposure of files to unauthorized users.
Potential impact
- An attacker may disclose sensitive files readable by the Trilium process.
- Retrieved contents could expose credentials, configuration data, or application secrets.
- The application may store unauthorized local data as note attachments.
- An attacker could cause excessive memory allocation and crash the server process.
- Repeated abuse could reduce availability for other users.
General mitigation guidance
Mitigation generally focuses on removing local filesystem access from user-controlled resource-fetching workflows.
Common defensive patterns include:
- Allowing only explicitly required network schemes and rejecting local-file and device-oriented schemes by default.
- Separating remote media retrieval from local filesystem APIs.
- Enforcing strict URL parsing, canonicalization, destination validation, and bounded resource sizes.
- Applying response-size, time, and memory limits to automatic downloads.
- Restricting the Trilium process to the minimum filesystem permissions needed for operation.
- Using isolated temporary storage and avoiding retention of fetched content unless it is authorized and validated.
- Applying the vendor's security fix through the organization's normal supported update process.
How teams detect issues like this
Organizations can look for this vulnerability through:
- Static analysis rules identifying user-controlled URLs passed to filesystem or generic resource-reading APIs.
- Code review checks for local-file, device, loopback, and other non-network schemes accepted by media fetchers.
- Tests confirming that sanitization and URL allowlists reject local resources before any I/O occurs.
- Monitoring note-save, import, and ETAPI activity for unusual attachment creation, repeated fetch failures, or abnormal resource sizes.
- Runtime alerts for unexpected access to sensitive filesystem locations and memory or process exhaustion.
- Policy enforcement requiring bounded downloads and explicit scheme allowlists.
Automated application-security review tools may help identify unvalidated path and URL flows during development.

