-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
NEFARIOUSPLAN-CANONICAL-V1
{"body_md":"## The encoder was written for one decoder and counted to two\n\n`escapeAriaLabel` lives in `app/src/util/escape.ts`. It is five lines:\n\n```typescript\nexport const escapeAriaLabel = (html: string) => {\n if (!html) {\n return html;\n }\n return html.replace(/\"/g, \""\").replace(/'/g, \"'\")\n .replace(/. The commit message references issue `#16640`, a `focusSideBlock` console-error report that has nothing to do with security. The commit is one of many that day; SiYuan's solo-maintainer rhythm rolls multiple unrelated changes into single commits. Among the files this commit creates, two are load-bearing for CVE-2026-44588:\n\n```\napp/src/util/escape.ts // new file, contains escapeAriaLabel\napp/src/block/popover.ts // new file, contains line 138 (now :144):\n // showTooltip(decodeURIComponent(tip), ...)\n```\n\nBoth functions are present in their CVE-2026-44588 form in the same commit. The encoder that gates `[\"'<]` and the consumer that calls `decodeURIComponent(tip)` were written by the same author on the same afternoon. The author's mental model of the pipeline existed; the encoder's character class is direct evidence of it. The encoder anticipates the HTML attribute decode and the `innerHTML` decode. It does not anticipate the function call between them, written into the same commit, in a file the author was editing in the same hour.\n\nThe line that introduced the unconditional `decodeURIComponent` on the same-file `assetTip` branch later (March 17, 2026, commit `badf737`, \"Improve support for URL-encoded local file names\") is from a different contributor, Jeffrey Chen / @TCOTC, working in popover.ts without re-examining what the producer side of the pipeline assumed. The decoder grew a second invocation site. The encoder did not grow a `%` to its character class.\n\nThe advisory's framing of CVE-2026-44588 as an \"incomplete fix for CVE-2026-34585\" describes the resolution of the prior CVE: SiYuan patched the encoder. The bug had already passed through the encoder by the time of the patch.\n\n## The payload\n\nThe PoC is a percent-encoded `
`. The attribute reads, in order, through the pipeline.\n\n```bash\n# 1. Create a document via the kernel API.\ncurl -X POST http://localhost:6806/api/filetree/createDocWithMd \\\n -H \"Authorization: Token \" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"notebook\":\"\",\"path\":\"/poc\",\"markdown\":\"poc\"}'\n\n# 2. Rename the document with the percent-encoded payload as its title.\ncurl -X POST http://localhost:6806/api/filetree/renameDocByID \\\n -H \"Authorization: Token \" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"id\":\"\",\"title\":\"%3Cimg src=x onerror=\\\"alert(1)\\\"%3E\"}'\n```\n\nWhen the user opens the search panel and the document name surfaces in the result list, SiYuan's search renderer emits `app/src/search/util.ts:1406`:\n\n```html\n\n poc\n\n```\n\n`escapeAriaLabel` has run. The two characters from its class that the payload contains, `\"` and `'`, have been replaced. `%3C` and `%3E` were never touched, because no character in `[%3CE]` is in `[\"'<]`.\n\nThe mouse moves over the result. `popover.ts:33` reads the attribute. The HTML attribute parser turns `"` back into `\"`. The string entering `decodeURIComponent` is:\n\n```\n%3Cimg src=x onerror=\"alert(1)\"%3E\n```\n\n`decodeURIComponent` runs. `%3C` becomes `<`. `%3E` becomes `>`. The string entering `innerHTML` is:\n\n```\n
\n```\n\n`innerHTML` parses it as HTML. The `
` element is created. The image fails to load. `onerror` fires.\n\n## What lives at `onerror` is Node.js\n\n`app/electron/main.js:407-411` configures the main BrowserWindow:\n\n```javascript\nwebPreferences: {\n nodeIntegration: true,\n webviewTag: true,\n webSecurity: false,\n contextIsolation: false,\n autoplayPolicy: \"user-gesture-required\"\n},\n```\n\n`nodeIntegration: true` exposes Node's `require` to renderer-side JavaScript. `contextIsolation: false` puts the page's scripts and the preload script in the same JS context, so the document's own scripts can call `require`. `webSecurity: false` disables same-origin restrictions on the renderer. The triple is the example Electron's own security docs use as the configuration not to ship.\n\nThis is the SiYuan main window. The search panel runs in this renderer. The file tree runs in this renderer. Every attribute-view tooltip runs in this renderer.\n\n`onerror=\"require('child_process').exec(...)\"` is one line. Percent-encoded, it goes through `escapeAriaLabel` unchanged. The chain from the encoder's character class to `child_process.exec` is six lines of code across three files.\n\n## The character classes are disjoint\n\nThis is the diagnostic of [Gate Before Canonicalize](/patterns/gate-before-canonicalize): a security check inspects an input for a forbidden form, a downstream subsystem canonicalizes the same input into that forbidden form, the check sees the wrapped representation and the action sees the unwrapped one. The prior exhibits live in URL routing. [Alfresco's path blacklist](/posts/alfresco-share-blacklist-misses-the-semicolon) gated on the URL Spring extracted; Tomcat then unwrapped `..;` into `..`. [Spring's `uriDecode`](/posts/spring-uridecode-ghost-bits-jetty-finishes) gated on a string Spring produced by truncating 16-bit chars; Jetty 12 finished a canonicalization Spring's pattern set was not written to recognize. [s3-proxy's auth middleware](/posts/s3-proxy-cve-2026-42882-two-parses-one-bouncer) globbed against `r.URL.RequestURI()` (encoded); the handler dispatched on `chi.URLParam` followed by `url.PathUnescape` (decoded).\n\nSiYuan's instance moves the pattern out of HTTP routing and into the DOM. The producer writes through an HTML-entity escape. The HTML attribute parser is the first canonicalizer. `decodeURIComponent` is the second. `innerHTML` is the third. The encoder's set is `[\"'<]`. The decoder's set is `%[0-9a-fA-F]{2}`. There is no character in one that the other names. The gate runs against a string the next-but-one stage has not yet manufactured.\n\nThe class signature applied to a DOM API. The encoder author understood the entity-decode pass and gated for it; the URL-decode pass lives in a different file the encoder author was editing in the same hour and never had to read as a sequence.\n\n## The aria-label tooltip is a [Design Debt Driver](/patterns/design-debt-driver)\n\n`escapeAriaLabel` is called from twelve distinct sites across SiYuan's source tree. Search result rows in `app/src/search/util.ts`, `app/src/search/assets.ts`, and `app/src/search/unRef.ts`. AI action lists in `app/src/ai/actions.ts`. File-tree entries in `app/src/layout/dock/Files.ts`. Outline and backlink labels in `app/src/util/Tree.ts`. Attribute-view column headers in `app/src/protyle/render/av/col.ts`. Attribute-view select-cell options and view tabs in `select.ts`, `view.ts`, `render.ts`, and `blockAttr.ts`. Twelve producers, all writing to the same attribute name with the same encoder.\n\nEvery one of them flows into one consumer: the global `popover.ts` mouseover handler, which reads `aria-label` and calls `decodeURIComponent` on the result before handing it to `innerHTML`. The pipeline is fan-in. One bypass in the consumer reaches every producer.\n\nThe component is the design debt. The prior CVE patched the encoder; the new CVE bypasses it through the same `popover.ts` line. As long as the producer and the consumer live in different files and the encoder's character class is computed by tracing canonicalization steps the encoder author knew about, the next person who adds a new decoder step (or a new attribute that reaches the same handler) will open the same shape.\n\n## The fix is not the encoder\n\nThe advisory's suggested remediations name three changes. Replace `messageElement.innerHTML` with `textContent` in `tooltip.ts:41`. Remove the unconditional `decodeURIComponent` call in `popover.ts:144`. Set `contextIsolation: true` in the BrowserWindow.\n\nThe change that is not on the list is \"patch `escapeAriaLabel`.\" The encoder was the fix for CVE-2026-34585 and is downstream of the bug for CVE-2026-44588. Hardening the encoder will not close this; one more `%`-class character the encoder does not gate, or one more attribute that gets `decodeURIComponent`'d before `innerHTML`, will reopen the same shape.\n\nThe GHSA advisory lists `Patched Versions: None`. As of writing, no version of SiYuan has shipped a fix. `popover.ts:144` and `tooltip.ts:41` remain on `main`.\n\nPoC: [advisories/GHSA-25rp-h46x-2hjm](https://github.com/advisories/GHSA-25rp-h46x-2hjm). Reporter: Curly-Haired-Baboon.","closing_line":"The encoder was patched. The decoder runs after.","hook_md":"SiYuan's encoder for `aria-label` attribute values is `escapeAriaLabel`. It double-escapes `<` to the literal six-character sequence `<`, an unusual encoding whose only reason to exist is that the author traced the value's path and counted two canonicalizers downstream: the HTML attribute parser (decodes `&` once) and the `innerHTML` setter (decodes `<` once). Pre-encode for two; the visible result is the character `<` rendered as text, not as a tag.\n\nThe vulnerability is a third one. `app/src/block/popover.ts:144` calls `decodeURIComponent` on the same string before `innerHTML` ever sees it. The character class the encoder gates against is `[\"'<]`. The character class `decodeURIComponent` rewrites is `%[0-9a-fA-F]{2}`. The two are disjoint. CVE-2026-34585 patched the encoder. CVE-2026-44588 is the second function call on the same string.","post_id":357,"slug":"siyuan-cve-2026-44588-patched-the-encoder-decoder-runs-after","title":"CVE-2026-44588: SiYuan Patched the Encoder. The Decoder Runs After.","type":"initial","unreadable_sentence":"CVE-2026-34585 patched the encoder. CVE-2026-44588 is the second function call on the same string."}
-----BEGIN PGP SIGNATURE-----
iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCakGCxQAKCRDeZjl4jgkQ
JpYzAQDTDs6aGwJoQpLvxDw5Y40MbDZ8lq/W+siTqCzKM3hNDgEA6f6Ggx491H8O
790DqJWCSHAvmxinrWZQ39+QgJ6ybww=
=lRY4
-----END PGP SIGNATURE-----