# unhead streaming SSR streamKey script injection

Source: https://junglewise.ai/threats/unhead-streaming-ssr-streamkey-script-injection-7d041c56  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-04-10. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

Severity: medium · CVSS 4 · Published 2026-04-10

unhead is a JavaScript library for managing HTML head tags in server-side rendering (SSR) applications. A vulnerability in how it processes the `streamKey` configuration parameter allows an attacker to inject arbitrary JavaScript code into generated HTML pages if an application passes untrusted data into this setting. Most applications are unaffected because they use hardcoded, default, or safe custom keys; exploitation requires explicit routing of untrusted input to a developer configuration sink.

Technologies: [unhead (npm)](https://junglewise.ai/threats/technologies/unhead). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is This vulnerability exploited in the wild?** No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.

**How severe is This vulnerability?** Medium severity, with a CVSS score of 4, published 10 April 2026.

**Which products and versions are affected?** unhead (npm) SEMVER:introduced=3.0.0-beta.5,fixed=3.0.1.

**Is there a fix for This vulnerability?** Yes. unhead (npm): upgrade to 3.0.1 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is This vulnerability attacked?** It is attacked over the network.

**Am I affected?** Check whether you run unhead (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- unhead (npm): upgrade to 3.0.1 or later

  ```sh
  npm install unhead@3.0.1
  ```


## Technical details

The vulnerability is a script injection (CWE-79) stemming from insufficient input validation. The `createStreamableHead()` and `createBootstrapScript()` functions embed the `streamKey` parameter directly into inline script tags via string interpolation (e.g., `window.${streamKey}={...}`) without identifier validation or escaping. An attacker-controlled value like `__unhead__;globalThis.PWNED=1;//` breaks out of the intended dot-notation property access and injects arbitrary JavaScript. The vulnerability requires that an application explicitly routes untrusted request data into the `streamKey` configuration parameter—a pattern that is neither documented nor recommended. The fix, released in unhead 3.0.1, validates `streamKey` against a conservative ASCII JavaScript-identifier regex (`/^[$_a-z][$\w]*$/i`) at all injection points and throws immediately on invalid values.

## Affected products

- unjs unhead 3.0.0-beta.5 through 3.0.0

## Timeline

- 2026-04-10: disclosed: Advisory GHSA-x7mm-9vvv-64w8 published
- 2026-04-10: patched: Fixed in unhead 3.0.1 via commit 64b5ac0

## References

- [https://github.com/unjs/unhead/security/advisories/GHSA-x7mm-9vvv-64w8](https://github.com/unjs/unhead/security/advisories/GHSA-x7mm-9vvv-64w8)
- [https://github.com/unjs/unhead/commit/64b5ac0aa30cc256ea6677ce3dc4f132f81b2ff6](https://github.com/unjs/unhead/commit/64b5ac0aa30cc256ea6677ce3dc4f132f81b2ff6)

## Related threats

- [Unhead hasDangerousProtocol bypass via padded HTML entities](https://junglewise.ai/threats/cve-2026-39315-unhead-hasdangerousprotocol-bypass-via-padded-html-entities)
- [Unhead URI scheme sanitization bypass via case-sensitivity](https://junglewise.ai/threats/cve-2026-31873-unhead-uri-scheme-sanitization-bypass-via-case-sensitivity)
- [Unhead useHeadSafe XSS bypass via attribute name injection](https://junglewise.ai/threats/cve-2026-31860-unhead-useheadsafe-xss-bypass-via-attribute-name-injection)
