XSS to RCE found in Trilium in zadam/trilium
Reported on
Mar 24th 2023
Vulnerability Type
Remote Code Execution (RCE)
Authentication Required?
No
Affected Location
- Search Notes > Search Ancestor (Output)
- Jump to Note > Search Note (Output)
- New Tab > Search Notes (Output)
Issue Summary
The application contains a vulnerability where HTML characters within the title name of notes are not properly sanitized, leaving it susceptible to cross-site scripting (XSS) attacks. If a victim searches for specific keywords, this vulnerability can be exploited, potentially leading to code execution. Notably, since the application is developed using Electron with ContextIsolation disabled and NodeIntegration enabled, the severity of this vulnerability could enable an attacker to execute commands on the system where the application is running.
Recommendation
Implement input validation and sanitization in the output of searching to ensure that HTML characters are properly escaped and cannot be used to trigger XSS attacks. Ensure to set NodeIntegration to 'FALSE' and ContextIsolation to 'TRUE' as this could protect against RCE attacks. Stay up-to-date with security patches and updates for all third-party libraries and dependencies used by the application.
Credits
Ali Radzali (muhammadali.radzali@baesystems.com)
Issue Reproduction
Create a new note and insert the payload below into the title of the note.
<img src=x onerror=require(`child_process`).execSync(`/usr/bin/mate-calc`)
NOTE: Triggering the XSS payload is not limited to using double quotes. In the case of this particular payloads, only the characters `, 1, #, ", > can be used to trigger the XSS.
Search Notes (Ancestor)
Click on "Search Notes" on the left sidebar and search for double quotes ("). This should trigger the XSS payload in the title of the note.
Jump to Notes (Note)
Click on "Jump to Note" on the left sidebar and search for double quotes ("). This should trigger the XSS payload in the title of the note.
New Tab (Note)
Create a new tab and search for double quotes ("). This could trigger the XSS payload in the title of the note.
Impact
This vulnerability allows an an attacker to execute arbitrary code on the Trilium App if a victim searches for specific keywords
References
Thank you @zadam !
Here the commit that fix the issue sent by the maintainer: https://github.com/zadam/trilium/commit/4c3fcc3ea6f37debcb87ac1a7f5698c27be0e67b
Dear @admin , maintainer had responded and confirmed the fixed, could you please follow up on the CVE creation? Thank you.
Dear @admin,
It was mentioned that validated report from this repo should get me a CVE.
Could you please follow up on the CVE creation.
Thank you.
We would need the maintainer to confirm they wish to have a CVE assigned.
@maintainer?