GHSA-x7mm-9vvv-64w8 — unhead
Fix: unjs/unhead@64b5ac0GHSA-x7mm-9vvv-64w8 is a security vulnerability in unhead. A fix is available for unhead — see the affected versions and patch details below.
unhead: Streaming SSR `streamKey` injected into inline script without identifier validation
Real-World Exposure
How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.
unheadnpmDescription
Summary
createStreamableHead({ streamKey }) interpolated its streamKey argument directly into the streaming SSR bootstrap and suspense-chunk inline scripts without identifier validation or escaping. If an application forwards untrusted data into that configuration value, the rendered scripts become a script-injection sink.
Details
streamKey was embedded into JavaScript source via dot notation in two public helpers:
createBootstrapScript()returned<script>window.${streamKey}={...}</script>renderSSRHeadSuspenseChunk()returnedwindow.${streamKey}.push(...)
No escaping, quoting, or identifier validation was applied before these strings were embedded into HTML. A streamKey such as __unhead__;globalThis.PWNED=1;// broke out of the intended property access and injected arbitrary JavaScript into the page. The JSON escaping used for streamed head entries did not protect streamKey because streamKey was inserted as raw code rather than as serialized data.
Impact
streamKey is a developer-chosen configuration value rather than a data field — the intended usage is a hardcoded identifier-shaped constant (default __unhead__). Exploitation therefore requires an application to explicitly route untrusted input into a configuration sink, which is not a documented or recommended pattern. We have no reports of any downstream project sourcing streamKey from request data.
Applications using the default streamKey, or any hardcoded custom key, are not affected.
PoC
import { createStreamableHead, renderSSRHeadShell } from 'unhead/stream/server'
const { head } = createStreamableHead({
streamKey: '__unhead__;globalThis.PWNED=1;//',
})
const html = renderSSRHeadShell(
head,
'<!doctype html><html><head></head><body></body></html>',
)
// <!doctype html><html><head><script>window.__unhead__;globalThis.PWNED=1;//={_q:[],push(e){this._q.push(e)}}</script>…
Patch
Fixed on main in 64b5ac0. The fix will ship in the next patch release of unhead.
streamKey is now validated against a conservative ASCII JavaScript-identifier pattern (/^[$_a-z][$\w]*$/i) at every sink — createStreamableHead, createBootstrapScript, and the internal stream-key resolver. Invalid values throw immediately instead of being emitted into script output.
Workarounds
Do not pass untrusted data into createStreamableHead({ streamKey }) or createBootstrapScript(key). If per-tenant keys are required, whitelist them against an identifier-safe pattern before constructing the head instance.
Credit
Thanks to @Jvr2022 for the report.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | unhead | ≥ 3.0.0-beta.5&&< 3.0.1 | 3.0.1npm install unhead@3.0.1 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for unhead, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update unhead to 3.0.1 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-x7mm-9vvv-64w8 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
How O3 protects you
O3 Security's impact-aware SCA analyses which vulnerable code paths your application actually calls, so a match like GHSA-x7mm-9vvv-64w8 can be triaged on real exposure rather than presence alone.
Tailored to GHSA-x7mm-9vvv-64w8. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Frequently Asked Questions
Is GHSA-x7mm-9vvv-64w8 in your dependencies?
O3 Security finds GHSA-x7mm-9vvv-64w8 across npm dependencies, including transitive ones, and its impact-aware SCA ranks findings by whether your code actually calls the vulnerable path.