CVE-2026-31873: Unhead Unhead Vulnerable To Bypass Of Vulnerability

LOW
Advisory Identifier: GHSA-5339-hvwr-7582
CVSS 0.0
CWE-79
Published
Advisory Summary

CVE-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

CVE Identifier CVE-2026-31873
GHSA Identifier GHSA-5339-hvwr-7582
Severity LOW
CVSS v3.1 Base Score 0.0
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Unhead
Package Ecosystem npm
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability None (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.

unhead fixed: 2.1.11
npm install unhead@2.1.11
Verify Direct and Transitive Dependencies

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

The `link.href` check in `makeTagSafe` (safe.ts, line 68-71) uses `String.includes()`, which is case-sensitive: ```typescript 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 ```javascript useHeadSafe({ link: [{ rel: 'stylesheet', href: 'DATA:text/css,body{display:none}' }] }) ``` SSR output: ```html <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 ```typescript if (key === 'href') { const lower = val.toLowerCase() if (lower.includes('javascript:') || lower.includes('data:')) { return } next[key] = val } ```

CVE-2026-31873 Affected Unhead Versions

1 component(s)
Fixed Versions:
2.1.11
Product / Package Ecosystem Affected Versions Fixed Version
unhead
npm
< 2.1.11
2.1.11

References

Frequently Asked Questions

What is CVE-2026-31873?
CVE-2026-31873 is a security vulnerability in Unhead involving Unhead Vulnerable to Bypass of URI Scheme Sanitization in makeTagSafe via Case-Sensitivity under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Unhead versions are affected?
Affected versions include releases prior to 2.1.11 across affected packages: unhead.
What version fixes CVE-2026-31873?
Upgrading to 2.1.11 (or the latest patched release for your respective branch) resolves the vulnerability.
Is unhead affected?
Yes, unhead is affected in releases prior to 2.1.11. Upgrade your dependency to 2.1.11 or later.
What is the CVSS score of CVE-2026-31873?
CVE-2026-31873 has a CVSS v3.1 base score of 0.0 (LOW) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N.
What CWE is associated with CVE-2026-31873?
CVE-2026-31873 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (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.).
How can I check npm dependencies for CVE-2026-31873?
Run the dependency tree command: 'npm ls unhead'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}