CVE-2026-31873: Unhead has a Bypass of URI Scheme Sanitization in makeTagSafe via Case-Sensitivity

Published Mar 12, 2026
·
Updated

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 }

Other sources

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.

MITRE

Affected Software

2 affected componentsFixes available
npm/unhead<=2.1.10
2.1.11
unjs Unhead<2.1.11

Event History

Mar 12, 2026
Advisory Published
via GitHub·02:19 PM
Data Sourced
via GitHub·02:19 PM
DescriptionWeaknessAffected Software
CVE Published
via MITRE·05:20 PM
Data Sourced
via MITRE·05:20 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·06:16 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·06:16 PM
Affected Software
Nov 20, 58180
Event
via FIRST·09:38 AM

Frequently Asked Questions

1

What is the severity of CVE-2026-31873?

CVE-2026-31873 is considered a high severity vulnerability due to its potential for bypassing URI scheme sanitization.

2

How do I fix CVE-2026-31873?

To fix CVE-2026-31873, upgrade the unhead package to version 2.1.11 or later.

3

What software is affected by CVE-2026-31873?

CVE-2026-31873 affects unhead versions up to and including 2.1.10.

4

What is the nature of the vulnerability in CVE-2026-31873?

CVE-2026-31873 is a bypass vulnerability that arises from case-sensitivity in URI scheme sanitization.

5

Is CVE-2026-31873 a critical security issue?

Yes, CVE-2026-31873 poses a critical security risk as it allows attackers to potentially execute unsafe URI schemes.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203