Summary
An XSS vulnerability allows note titles to execute arbitrary shell commands from the ctrl+p search dialog.
Details
This vulnerability is caused by adding note titles to the document using React's dangerouslySetInnerHTML, without first escaping HTML entities:
|
? `<span style="font-weight: bold; color: ${theme.color};">${item.title}</span>` |
Joplin lacks a Content-Security-Policy with a restrictive script-src. This allows arbitrary JavaScript execution via inline onclick/onload event handlers in unsanitized HTML. Additionally, Joplin's main window is created with nodeIntegration set to true, allowing arbitrary JavaScript execution to result in arbitrary code execution.
A git blame suggests that this vulnerability has existed since at least March 2020. A similar vulnerability may have existed before then — older logic used surroundKeywords on untrusted input, which also did not escape HTML.
PoC
- Create a note with the following title:
<style onload="alert(require('child_process').execSync('ls /'))"></style>
- Add
someuniqueword to the note body.
- Press ctrl-p and search for
someuniqueword.
Tested versions: 3.1.20, 3.0.14, and 2.14.23.
Note: Different shell command used with v2.14.23
While testing the PoC with v2.14.23, I used
t<style onload="require('child_process').exec('zenity --error')">*{}</style>t
as the note title. On my system, zenity --error is a shell command to display an alert dialog. The above command was used due to issues with alert().
Impact
Anyone who 1) receives notes from unknown sources and 2) uses ctrl-p to search is impacted.
Summary
An XSS vulnerability allows note titles to execute arbitrary shell commands from the ctrl+p search dialog.
Details
This vulnerability is caused by adding note titles to the document using React's
dangerouslySetInnerHTML, without first escaping HTML entities:joplin/packages/app-desktop/plugins/GotoAnything.tsx
Line 558 in 2fc9bd4
Joplin lacks a Content-Security-Policy with a restrictive script-src. This allows arbitrary JavaScript execution via inline
onclick/onloadevent handlers in unsanitized HTML. Additionally, Joplin's main window is created withnodeIntegrationset totrue, allowing arbitrary JavaScript execution to result in arbitrary code execution.A
git blamesuggests that this vulnerability has existed since at least March 2020. A similar vulnerability may have existed before then — older logic usedsurroundKeywordson untrusted input, which also did not escape HTML.PoC
someuniquewordto the note body.someuniqueword.Tested versions: 3.1.20, 3.0.14, and 2.14.23.
Note: Different shell command used with v2.14.23
While testing the PoC with v2.14.23, I used
as the note title. On my system,
zenity --erroris a shell command to display an alert dialog. The above command was used due to issues withalert().Impact
Anyone who 1) receives notes from unknown sources and 2) uses ctrl-p to search is impacted.