{"id":"GHSA-5339-hvwr-7582","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\u003clink rel=\"stylesheet\" href=\"DATA:text/css,body{display:none}\"\u003e\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```","aliases":["CVE-2026-31873"],"modified":"2026-03-12T19:31:22.833976Z","published":"2026-03-12T14:19:25Z","database_specific":{"github_reviewed_at":"2026-03-12T14:19:25Z","nvd_published_at":"2026-03-12T18:16:24Z","cwe_ids":["CWE-79"],"severity":"LOW","github_reviewed":true},"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"}],"affected":[{"package":{"name":"unhead","ecosystem":"npm","purl":"pkg:npm/unhead"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"2.1.11"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/03/GHSA-5339-hvwr-7582/GHSA-5339-hvwr-7582.json","last_known_affected_version_range":"\u003c= 2.1.10"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N"}]}