{"id":"CVE-2026-31873","aliases":["CVE-2026-31873","GHSA-5339-hvwr-7582"],"related":[],"kind":"vulnerability","state":"published","title":"Unhead has a Bypass of URI Scheme Sanitization in makeTagSafe via Case-Sensitivity","summary":"Unhead is a document head and template manager. Prior to 2.1.11, The link.href check in makeTagSafe (safe.ts) uses String.includes(), which is case-sensitive. Browsers treat URI schemes case-insensitively. DATA:text/css,... is the same as data:text/css,... to the browser, but 'DATA:...'.includes('data:') returns false. An attacker can inject arbitrary CSS for UI redressing or data exfiltration via CSS attribute selectors with background-image callbacks. This vulnerability is fixed in 2.1.11.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Unhead is a document head and template manager. Prior to 2.1.11, The link.href check in makeTagSafe (safe.ts) uses String.includes(), which is case-sensitive. Browsers treat URI schemes case-insensitively. DATA:text/css,... is the same as data:text/css,... to the browser, but 'DATA:...'.includes('data:') returns false. An attacker can inject arbitrary CSS for UI redressing or data exfiltration via CSS attribute selectors with background-image callbacks. This vulnerability is fixed in 2.1.11.","source":"cvelist"},{"lang":"en","text":"The `link.href` check in `makeTagSafe` (safe.ts, line 68-71) uses `String.includes()`, which is case-sensitive:\n\n```typescript\nif (key === 'href') {\n  if (val.includes('javascript:') || val.includes('data:')) {\n    return\n  }\n  next[key] = val\n}\n```\n\nBrowsers treat URI schemes case-insensitively. `DATA:text/css,...` is the same as `data:text/css,...` to the browser, but `'DATA:...'.includes('data:')` returns `false`.\n\n### PoC\n\n```javascript\nuseHeadSafe({\n  link: [{\n    rel: 'stylesheet',\n    href: 'DATA:text/css,body{display:none}'\n  }]\n})\n```\n\nSSR output:\n\n```html\n<link rel=\"stylesheet\" href=\"DATA:text/css,body{display:none}\">\n```\n\nThe browser loads this as a CSS stylesheet. An attacker can inject arbitrary CSS for UI redressing or data exfiltration via CSS attribute selectors with background-image callbacks.\n\nAny case variation works: `DATA:`, `Data:`, `dAtA:`, `JAVASCRIPT:`, etc.\n\n## Suggested fix\n\n```typescript\nif (key === 'href') {\n  const lower = val.toLowerCase()\n  if (lower.includes('javascript:') || lower.includes('data:')) {\n    return\n  }\n  next[key] = val\n}\n```","format":"markdown","source":"ghsa"},{"lang":"es","text":"Unhead es un gestor de cabeceras de documento y plantillas. Antes de la versión 2.1.11, la comprobación de link.href en makeTagSafe (safe.ts) utiliza String.includes(), que distingue entre mayúsculas y minúsculas. Los navegadores tratan los esquemas URI sin distinguir entre mayúsculas y minúsculas. DATA:text/css,... es lo mismo que data:text/css,... para el navegador, pero 'DATA:...'.includes('data:') devuelve falso. Un atacante puede inyectar CSS arbitrario para la manipulación de la interfaz de usuario o la exfiltración de datos a través de selectores de atributos CSS con retrollamadas de background-image. Esta vulnerabilidad se corrige en la versión 2.1.11.","source":"nvd"}],"published":"2026-03-12T14:19:25.000Z","modified":"2026-06-17T10:34:40.490Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N","score":0,"rating":"NONE"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N","score":0,"rating":"NONE"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N","score":0,"rating":"LOW"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":"< 2.1.11","status":"affected"}],"vendor":"unjs","product":"unhead","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.1.11"}],"ecosystem":"npm","package":"unhead","purl":"pkg:npm/unhead","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"2.1.11"}],"vendor":"unjs","product":"unhead","cpe":"cpe:2.3:a:unjs:unhead:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/unjs/unhead/security/advisories/GHSA-5339-hvwr-7582","tags":["exploit","mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-31873","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/unjs/unhead","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/unjs/unhead/releases/tag/v2.1.11","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-03-12T17:46:23.897Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-31873","url":"https://www.cve.org/CVERecord?id=CVE-2026-31873","licence":"CVE Terms of Use","modified":"2026-03-12T17:46:46.723Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-5339-hvwr-7582","url":"https://github.com/advisories/GHSA-5339-hvwr-7582","licence":"CC-BY-4.0","modified":"2026-03-14T06:26:21.006Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-31873","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-31873","licence":"Public domain","modified":"2026-06-17T10:34:40.490Z"}],"updatedAt":"2026-11-25T22:59:15.839Z","epss":{"score":0.00268,"percentile":0.20223,"date":"2026-12-01T12:00:22.000Z"}}