Vulnerability DatabaseGHSA-6r92-h7v8-c87r

GHSA-6r92-h7v8-c87r: 
JavaScript vulnerability analysis and mitigation

Summary

The streaming SSR plugin in unhead interpolates its framework option directly into generated client JavaScript without validation or escaping. buildStreamingPluginOptions({ framework }) passes the value to buildClientStub(), which embeds it raw inside a single-quoted ES module import in packages/unhead/src/stream/unplugin.ts. A framework value containing a single quote breaks out of the import string literal and injects attacker-chosen code into the virtual client module that is bundled and served to every visitor's browser. This mirrors the previously fixed streamKey injection, but framework is a separate parameter on a separate code path that no release validates.

Root Cause

The generated client bootstrap is assembled with a template literal that places framework inside a single-quoted string without quoting, escaping, or identifier validation. The sibling streamKey value in the same function is protected both by parseStreamKey() identifier validation and by JSON.stringify() serialization, but framework receives neither. Any single quote in framework terminates the import string early, and the remainder of the value is parsed as live JavaScript rather than as a package specifier.

packages/unhead/src/stream/unplugin.ts
  line 135: const key = JSON.stringify(streamKey)            // streamKey escaped
  line 148: return `import{createHead}from'${framework}/client'  // framework raw
  line 172: const streamKey = parseStreamKey(rawStreamKey)    // streamKey validated; framework not
Affected function: buildClientStub (packages/unhead/src/stream/unplugin.ts:131)

Impact

An integration that constructs the streaming plugin through the public createStreamingPlugin or buildStreamingPluginOptions API and sources the framework option from untrusted input (for example an environment variable, a configuration file, or a build argument) emits attacker-controlled JavaScript into the client bundle. The injected code executes in the browser of every user who loads the application, giving the attacker the standard cross-site scripting capabilities within the application origin: reading accessible cookies and page content and modifying the DOM. The four shipped framework wrappers (Vue, React, Solid, Svelte) hardcode a safe framework constant and do not expose the option, so default usage through those wrappers is not affected. This is the same configuration-sink threat model under which the streamKey variant was accepted.

Proof of Concept

Requires the unhead streaming plugin constructed via the lower-level public API with a
framework value derived from untrusted input. The snippet below shows the generated module
content produced by buildClientStub for a malicious framework value.
import { buildStreamingPluginOptions } from 'unhead/stream/unplugin'
// framework sourced from untrusted input by a custom integration
const options = buildStreamingPluginOptions({
  framework: "@unhead/vue';globalThis.XSS=1;//",
})
// The plugin's load hook for the client virtual module returns buildClientStub(framework, ...)
// whose first line becomes the code below.
import{createHead}from'@unhead/vue';globalThis.XSS=1;///client'

The import resolves to a real module, globalThis.XSS=1 runs as standalone statement, and // comments out the trailing /client'. The result is syntactically valid JavaScript that executes the injected statement in the browser.

Attack Chain

  1. Exposure: A custom integration builds the streaming plugin through the public createStreamingPlugin (packages/unhead/src/stream/unplugin.ts:480) or buildStreamingPluginOptions (packages/unhead/src/stream/unplugin.ts:163) API, which accept the full options interface including framework.
  2. Control: The attacker influences the framework string. The option is typed only as string (packages/unhead/src/stream/unplugin.ts:20) with no constraint.
  3. Path: buildStreamingPluginOptions destructures framework without validation (packages/unhead/src/stream/unplugin.ts:165) and the client-module load hook calls buildClientStub(framework, streamKey, warnEnabled()) (packages/unhead/src/stream/unplugin.ts:350).
  4. Guard: No validation or escaping is applied to framework; parseStreamKey() and JSON.stringify() cover only streamKey.
  5. Primitive: buildClientStub interpolates framework raw into a single-quoted import string (packages/unhead/src/stream/unplugin.ts:148), and the load hook returns the generated code as the virtual:@unhead/streaming-client module served to the client bundle.
  6. Result: Arbitrary JavaScript executes in the browser of every user loading the application, within the application origin.

Bypass Evidence

The relevant protections are the two guards applied to the sibling streamKey value in the same function: parseStreamKey() identifier validation (packages/unhead/src/stream/key.ts:3) and JSON.stringify() escaping (packages/unhead/src/stream/unplugin.ts:135). Searching the streaming module for any equivalent treatment of framework returns nothing: framework is never passed to parseStreamKey() or wrapped by JSON.stringify() and reaches the sink at line 148 unchanged. The strongest challenge was whether the single-quote break could still yield loadable, syntactically valid module code; the payload @unhead/vue';globalThis.XSS=1;// demonstrates that it can, producing a valid import followed by an executable statement and a line comment. The seed fix (parseStreamKey(), introduced for streamKey in v3.0.1) predates the unplugin.ts file and does not cover this parameter.

Affected Versions

  • Ecosystem: npm
  • Package: unhead
  • Confirmed affected range: >= 3.4.0, <= 3.4.3
  • Latest release checked: 3.4.3 (npm registry)
  • Fix status: not fixed in any published release The packages/unhead/src/stream/unplugin.ts file and its buildClientStub function were first introduced in v3.4.0 and remain unchanged with respect to framework handling through v3.4.3, the latest published version.

Suggested Fix

Enforce that framework is a safe module specifier before it reaches code generation, at the point where options are resolved in buildStreamingPluginOptions. Validate it against a strict allowlist or package-specifier pattern and reject invalid values, or serialize it with JSON.stringify() at the interpolation site in buildClientStub so it can only ever be a string literal rather than inline code. The fix should cover the single-quote break shown here as well as any other character that can terminate or escape the generated string literal. As an interim mitigation, integrations should hardcode framework to a trusted constant and never source it from untrusted input, matching the shipped framework wrappers.

Reported by zx.


Source: NVD

Related JavaScript vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-vqxq-2wvm-wwq5MEDIUM6.1
  • JavaScript logoJavaScript
  • unhead
NoYesNov 23, 2026
GHSA-cw38-r4mr-qh2vMEDIUM6.1
  • JavaScript logoJavaScript
  • unhead
NoYesNov 23, 2026
GHSA-hx39-7p87-p6mvMEDIUM4.7
  • JavaScript logoJavaScript
  • unhead
NoYesNov 23, 2026
GHSA-43vv-qp67-mww8MEDIUM4.7
  • JavaScript logoJavaScript
  • unhead
NoYesNov 23, 2026
GHSA-6r92-h7v8-c87rLOW2
  • JavaScript logoJavaScript
  • unhead
NoYesNov 23, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management