CVE-2026-31873: Unhead Unhead Vulnerable To Bypass Of Vulnerability
LOWCVE-2026-31873 is a LOW (CVSS 0.0) unhead vulnerable to bypass of vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Unhead libraries in the npm ecosystem. The issue involves unhead vulnerable to bypass of uri scheme sanitization in maketagsafe via case-sensitivity. Remediation is available by upgrading affected packages to version 2.1.11.
CVE-2026-31873 at a Glance
Security Impact
CVSS: 0.0
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N).
How to Fix CVE-2026-31873
To remediate this vulnerability, upgrade all affected Unhead dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install unhead@2.1.11
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls unhead
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-31873, inspect your project dependencies using npm:
npm ls unhead
Analyze the terminal output to locate any version of Unhead in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.1.11), your application is affected.
Note: The npm ls unhead command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Unhead, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-31873 Affected Unhead Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
unhead
|
npm |
< 2.1.11
|
2.1.11
|
References
Frequently Asked Questions
What is CVE-2026-31873?
Which Unhead versions are affected?
What version fixes CVE-2026-31873?
Is unhead affected?
What is the CVSS score of CVE-2026-31873?
What CWE is associated with CVE-2026-31873?
How can I check npm dependencies for CVE-2026-31873?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-5339-hvwr-7582",
"modified" : "2026-03-12T19:14:29Z",
"published" : "2026-03-12T14:19:25Z",
"aliases" : [ "CVE-2026-31873" ],
"summary" : "Unhead Vulnerable to Bypass of URI Scheme Sanitization in makeTagSafe via Case-Sensitivity",
"details" : "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```",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "unhead"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.1.11"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 2.1.10"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/unjs/unhead/security/advisories/GHSA-5339-hvwr-7582"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-31873"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/unjs/unhead"
}, {
"type" : "WEB",
"url" : "https://github.com/unjs/unhead/releases/tag/v2.1.11"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "LOW",
"github_reviewed" : true,
"github_reviewed_at" : "2026-03-12T14:19:25Z",
"nvd_published_at" : "2026-03-12T18:16:24Z"
}
}