CVE-2026-31873
JSON

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 packageVersionsReported by
unjs unhead< 2.1.11, before 2.1.11CVE List, NVD
unhead (npm)before 2.1.11GitHub Advisory Database

All scores

GitHub_M0.0none CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N
GitHub0.0low CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N
NVD6.1medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

Classification

CWE-79

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

Sources

SourceRecordLicence
CVE ListCVE-2026-31873 changed 2026-03-12CVE Terms of Use
GitHub Advisory DatabaseGHSA-5339-hvwr-7582 changed 2026-03-14CC-BY-4.0
NVDCVE-2026-31873 changed 2026-06-17Public domain