CVE-2023-39517 (published 2024-06-21T20:15Z)

Joplin is a free, open source note taking and to-do application. A Cross site scripting (XSS) vulnerability in affected versions allows clicking on an untrusted image link to execute arbitrary shell commands. The HTML sanitizer (`packages/renderer/htmlUtils.ts::sanitizeHtml`) preserves `<map>` `<area>` links. However, unlike `<a>` links, the `target` and `href` attributes are not removed. Additionally, because the note preview pane isn't sandboxed to prevent top navigation, links with `target` set to `_top` can replace the toplevel electron page. Because any toplevel electron page, with Joplin's setup, has access to `require` and can require node libraries, a malicious replacement toplevel page can import `child_process` and execute arbitrary shell commands. This issue has been fixed in commit 7c52c3e9a81a52ef1b42a951f9deb9d378d59b0f which is included in release version 2.12.8. Users are advised to upgrade. There are no known workarounds for this vulnerability.


Weakness information:
cwe_id: NVD-CWE-noinfo
cwe_name: Insufficient Information
description: There is insufficient information about the issue to classify it; details are unkown or unspecified.
extended_description: Insufficient Information

Fix information:
repo_url: https://github.com/laurent22/joplin
commit_details: repo_url: https://github.com/laurent22/joplin
author: Henry Heino
author_date: 2023-07-15 03:56:12-07:00
msg: Desktop: Security: Disallow map and area tags (#8479)
repository: repo_url: https://github.com/laurent22/joplin
repo_name: laurent22/joplin
description: Joplin - the secure note taking and to-do app with synchronisation capabilities for Windows, macOS, Linux, Android and iOS.
repo_language: TypeScript
owner: laurent22
file_changes: filename: sanitize_16.html
change_type: ModificationType.MODIFY
diff: @@ -1 +1 @@
-<map name="test" class="jop-noMdConv"><area coords="0,0,1000,1000" href="#" class="jop-noMdConv"/></map><img usemap="#test" src="https://github.com/Ry0taK.png" class="jop-noMdConv"/>
\ No newline at end of file
+<img usemap="#test" src="https://github.com/Ry0taK.png" class="jop-noMdConv"/>
\ No newline at end of file

programming_language: Markdown
filename: htmlUtils.ts
change_type: ModificationType.MODIFY
diff: @@ -203,6 +203,11 @@ class HtmlUtils {
 			'embed', 'link', 'meta', 'noscript', 'button', 'form',
 			'input', 'select', 'textarea', 'option', 'optgroup',
 			'svg',
+
+			// Disallow map and area tags: <area ...> links are currently not
+			// sanitized as well as <a ...> links, allowing potential sandbox
+			// escape.
+			'map', 'area',
 		];
 
 		const parser = new htmlparser2.Parser({
@@ -300,8 +305,15 @@ class HtmlUtils {
 
 				if (current === name.toLowerCase()) tagStack.pop();
 
-				if (disallowedTags.includes(current)) {
-					disallowedTagDepth--;
+				// The Markdown sanitization code can result in calls like this:
+				//     sanitizeHtml('<invlaid>')
+				//     sanitizeHtml('</invalid>')
+				// Thus, we need to be able to remove '</invalid>', even if there is no
+				// corresponding opening tag.
+				if (disallowedTags.includes(current) || disallowedTags.includes(name)) {
+					if (disallowedTagDepth > 0) {
+						disallowedTagDepth--;
+					}
 					return;
 				}
 

programming_language: JavaScript