0.0none
Unhead has a Bypass of URI Scheme Sanitization in makeTagSafe via Case-Sensitivity
- Severity
- 0.0none CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.27% (higher than 20% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-5339-hvwr-7582
Description
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| unjs unhead | < 2.1.11, before 2.1.11 | CVE List, NVD |
| unhead (npm) | before 2.1.11 | GitHub Advisory Database |
All scores
| GitHub_M | 0.0none CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N |
| GitHub | 0.0low CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N |
| NVD | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
Classification
SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact partial.
What each source says
CVE List
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.
GitHub Advisory Database
The link.href check in makeTagSafe (safe.ts, line 68-71) uses String.includes(), which is case-sensitive:
if (key === 'href') {
if (val.includes('javascript:') || val.includes('data:')) {
return
}
next[key] = val
}
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.
PoC
useHeadSafe({
link: [{
rel: 'stylesheet',
href: 'DATA:text/css,body{display:none}'
}]
})
SSR output:
<link rel="stylesheet" href="DATA:text/css,body{display:none}">
The 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.
Any case variation works: DATA:, Data:, dAtA:, JAVASCRIPT:, etc.
Suggested fix
if (key === 'href') {
const lower = val.toLowerCase()
if (lower.includes('javascript:') || lower.includes('data:')) {
return
}
next[key] = val
}
NVD (es)
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.
References
| https://github.com/unjs/unhead/security/advisories/GHSA-5339-hvwr-7582 | exploit, mitigation, vendor-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2026-31873 | advisory | |
| https://github.com/unjs/unhead | package | |
| https://github.com/unjs/unhead/releases/tag/v2.1.11 | web | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-31873 changed 2026-03-12 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-5339-hvwr-7582 changed 2026-03-14 | CC-BY-4.0 |
| NVD | CVE-2026-31873 changed 2026-06-17 | Public domain |