/

CVE-2026-27148

Severity:

CRITICAL RISK

(9.6)

Input Injection & Cross-Site Scripting in Storybook Dev

CVE-2026-27148

Modified

Vulnerability type

Category:

Input Injection & Cross-Site Scripting

CWE:

CWE-74, CWE-79, CWE-346

Impact:

Persistent Cross-Site Scripting and Remote Code Execution in Development Environments

Severity:

CRITICAL RISK

(9.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Storybook's development server WebSocket handlers for creating and saving stories accept unsanitized input and do not validate the origin of incoming connections.

An attacker who can reach a running dev server can inject malicious paths and content that persist in story files, leading to stored cross-site scripting (XSS) or even remote code execution (RCE) in developer environments.

Affected context

This vulnerability occurs in Storybook's WebSocket-based dev server logic that handles "create story" and "save story" operations during active development.

It is relevant when:

  • A developer has a local Storybook dev server running and visits a malicious website, or
  • The Storybook dev server is intentionally exposed over a network (e.g., for demos or reviews), making it reachable by unauthenticated users.

The issue does not affect static Storybook production builds, but can impact any environment where the dev server is reachable over HTTP/WebSocket.

Exploit preconditions

  • Attack surface:
  • WebSocket endpoints exposed by the Storybook dev server responsible for handling story create/save messages.
  • Required access:
  • For local setups:
  • The developer must have the dev server running.
  • The developer must visit or be embedded into a malicious site (e.g., via iframe, script, or hidden frame) while the dev server is reachable (often on localhost).
  • For publicly exposed dev servers:
  • Any unauthenticated attacker who can reach the server endpoint over the network can send crafted WebSocket messages.
  • Trigger point:
  • Malicious WebSocket messages are sent to the dev server's story creation/update handlers, with crafted values in fields such as componentFilePath.
  • Why exploitation is possible:
  • The WebSocket implementation does not verify the Origin or otherwise authenticate the client, allowing browsers (and remote clients) to establish connections silently.
  • The server trusts incoming message data, using unsanitized values directly in file paths or story content generation.
  • This combination of missing origin validation (WebSocket hijacking) and unsanitized input (CWE-74 / CWE-79) allows injection of persistent script or code into Storybook artifacts.

Why this happens

At its core, the bug stems from the dev server treating WebSocket messages as trusted, structured commands without validating where they originate or sanitizing their contents.

Two classes of weaknesses interact:

  • CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component — The componentFilePath and related fields are inserted into file system paths or code templates without adequate neutralization, allowing crafted input to influence downstream processing and file generation logic.
  • CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting) — Story content derived from attacker-controlled data can be saved and later rendered in Storybook's UI, enabling stored XSS when other users or the same developer load those stories.

The absence of WebSocket origin checking further broadens the threat, because it allows arbitrary sites or remote clients to send these malformed messages as if they were legitimate, exploiting the overly permissive design of the dev server's message handlers.

Potential impact

  • Persistent XSS in Storybook's UI, where injected scripts execute whenever affected stories are viewed.
  • Remote Code Execution (RCE) in the development environment if injected content is interpreted or executed by developer tooling, build steps, or script loaders.
  • Unauthorized modification or creation of story files, components, or configuration under the dev server's control.
  • Compromise of developer workstations through malicious scripts that exfiltrate credentials, access tokens, or sensitive local data available in the browser context.
  • Lateral movement into internal services or repositories if a compromised dev environment holds privileged credentials or network access.

General mitigation guidance

Effective mitigation generally involves a combination of stricter WebSocket security controls and robust input handling patterns:

  • Enforce strict WebSocket origin checks:
  • Validate the Origin header against an allowlist of trusted origins.
  • Reject connections that do not originate from the expected Storybook UI or localhost development pages.
  • Require authentication or capability checks for state-changing WebSocket actions:
  • Treat WebSocket operations that create or modify files as privileged and protect them with tokens, sessions, or explicit dev-only capabilities.
  • Harden input validation and encoding:
  • Treat all values such as componentFilePath and story content as untrusted input.
  • Apply rigorous validation (e.g., allowed characters, directories, extensions) before using inputs in file paths or code generation.
  • Properly encode or escape user-supplied data wherever it may end up in HTML, JavaScript, or configuration to prevent XSS and code injection.
  • Constrain file system effects:
  • Limit where the dev server can write or modify files to a dedicated workspace, preventing escape into arbitrary paths.
  • Avoid directly interpolating user-controlled data into code files without intermediate normalization and review.
  • Reduce exposure of dev servers:
  • Keep Storybook dev servers bound to localhost by default and avoid exposing them directly to the internet.
  • When remote access is required, place dev servers behind VPNs, access controls, or reverse proxies with authentication.
  • Run with least privilege:
  • Ensure developer tools run with minimal filesystem and OS permissions necessary for development, limiting the blast radius if injections occur.

How teams detect issues like this

Detection efforts can combine code-centric analysis with runtime monitoring:

  • Static analysis and code scanning:
  • Search for WebSocket handlers that:
  • Do not validate Origin or authenticate clients.
  • Directly trust incoming JSON payload fields for file operations or story generation.
  • Flag string concatenation or templating where user-controllable fields (e.g., paths, story bodies) are written to disk or embedded into HTML/JS without escaping.
  • Code review practices:
  • Review dev tooling and internal web utilities with the same rigor as production code, especially where they write files, execute scripts, or manage dynamic imports.
  • Use checklists to ensure WebSocket endpoints:
  • Enforce origin checks or authentication.
  • Distinguish between read-only and state-changing operations.
  • Policy and linting rules:
  • Introduce lint rules or internal guidelines that disallow:
  • Path construction or code generation from unsanitized external data.
  • Unauthenticated, origin-less WebSocket access for privileged operations.
  • Runtime and behavioral monitoring (for shared dev infrastructure):
  • If dev environments are centralized, log WebSocket message sources, frequency, and payload characteristics to identify unusual activity (e.g., bursts of story creation from unfamiliar IPs).
  • Consider integrating with broader security monitoring platforms to detect suspicious file changes or scripts appearing in repositories or story directories.
  • Automated tooling:
  • Use application security testing tools (DAST/IAST) where feasible to probe dev endpoints in staging environments and identify missing origin checks and injection sinks earlier in the lifecycle.

Sources

SourceLink
github.comgithub.com/storybookjs/storybook/commit/0affdf928bd6fafbadfb1dfe22ce6104805e10e8
github.comgithub.com/storybookjs/storybook/commit/54689a8add18ea75d628c540f4bc677592a1e685
github.comgithub.com/storybookjs/storybook/commit/b8cfa77c73940c140acdcd8a06ab1ea913c44761
github.comgithub.com/storybookjs/storybook/commit/d34085f39c647f5c23c3a3b2d197c18602fcf876
github.comgithub.com/storybookjs/storybook/releases/tag/v10.2.10
github.comgithub.com/storybookjs/storybook/releases/tag/v7.6.23
github.comgithub.com/storybookjs/storybook/releases/tag/v8.6.17
github.comgithub.com/storybookjs/storybook/releases/tag/v9.1.19
github.comgithub.com/storybookjs/storybook/security/advisories/GHSA-mjf5-7g4m-gx5w
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-27148
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2442784
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-27148.json

Frequently asked

questions

Yes, if the Storybook dev server is exposed on a network (for example, for design reviews), any unauthenticated attacker who can reach the server can send malicious WebSocket messages directly. When the dev server is only on localhost, exploitation still becomes possible if a developer visits a malicious site that silently talks to the local server via WebSockets.

When the dev server is only locally bound, the attacker needs to lure a developer into visiting a malicious web page while the server is running. If the dev server is publicly reachable, no prior authentication or user interaction is required; the attacker only needs network access to the dev server endpoint.

The safest pattern is to treat the dev server like a production service for security-sensitive operations: enforce WebSocket origin validation and/or authentication, strictly validate and sanitize all user-controlled fields before using them for file or code generation, and confine file write operations to a controlled workspace with restricted capabilities.

Preventing similar vulnerabilities involves secure design for developer tooling: apply threat modeling to dev endpoints, mandate origin checks and auth for WebSocket-based state changes, enforce input validation and context-appropriate output encoding, limit file system privileges, and integrate static/dynamic security testing into CI so that dangerous patterns in dev servers and build tools are caught before release.

Find out what's already
exploitable in your codebase.