The bug is the binary clause of attributes_markup/1
CVE-2026-8467 is twelve lines of Elixir. The function lives in lib/phoenix_storybook/rendering/component_renderer.ex at commit e35379d (the parent of the fix commit, 56ab846). It accepts a list of {name, value} tuples and returns a single string that becomes part of a HEEx template the renderer is about to compile and evaluate.
defp attributes_markup(attributes) do
Enum.map_join(attributes, " ", fn
{name, {:eval, val}} ->
~s|#{name}={#{val}}|
{name, val} when is_binary(val) ->
~s|#{name}="#{val}"|
{name, val} ->
~s|#{name}={#{inspect(val, structs: false, limit: :infinity, printable_limit: :infinity)}}|
end)
end
Three clauses, three destinations in HEEx's attribute grammar.
The first clause handles values the story author has tagged as {:eval, val} to mean "this is Elixir source." It emits name={val}. The string between the braces is parsed by HEEx as an inline Elixir expression. Authors opt into this clause by writing it in the story file; the value is author-controlled at story-definition time, not runtime.
The third clause is the catch-all. It runs inspect/2 over the value and emits name={...}, where the bytes between the braces are whatever inspect/2 returned. inspect/2 on a number returns the number's decimal form. inspect/2 on an atom returns the atom literal with a leading colon. inspect/2 on a list returns a bracket expression. Each of those is valid Elixir source that HEEx's expression slot accepts unmodified. The slot expects parseable Elixir; inspect/2 produces parseable Elixir; the round-trip works. inspect/2 would have worked on binaries too, returning a quoted Elixir string literal with " characters escaped, but binaries do not reach this clause because the second one matches first.
The second clause is the bug. It matches binary values, the only attribute type the playground's WebSocket caller can produce as raw text. It emits name="<val>". The two " characters are typed directly into the source string by ~s|...|. There is no escape over the value, no encoding pass, no call to a HEEx-attribute primitive of any kind. Whatever bytes are in val end up between two " that the source string declared.
Two clauses route the value through HEEx's expression slot. The binary clause typed the quotes into the literal slot.
The exploit primitive
The entry point is PhoenixStorybook.Story.PlaygroundPreviewLive.handle_event/3. The function is plain LiveView code with no auth guard and no on_mount hook that checks a session:
def handle_event("psb-assign", assign_params, socket = %{assigns: assigns}) do
variation_attributes =
for {variation_id, attributes} <- assigns.variations_attributes, into: %{} do
{new_variation_id, new_attributes} =
ExtraAssignsHelpers.handle_set_variation_assign(
assign_params,
assigns.variations_attributes,
assigns.story
)
if new_variation_id == variation_id do
{variation_id, new_attributes}
else
{variation_id, attributes}
end
end
send_variations_attributes(assigns.topic, variation_attributes)
{:noreply, assign(socket, variations_attributes: variation_attributes)}
end
handle_set_variation_assign/3 (in lib/phoenix_storybook/helpers/extra_assigns_helpers.ex) reads params["variation_id"], looks up the matching variation, iterates the rest of the params, and stores each attr => value pair in the variation's attribute map verbatim. The string value is now a binary attribute on the rendering context.
The renderer's next pass calls ComponentRenderer.render/1, which calls component_heex/5, which calls attributes_markup/1. The binary clause matches. The output is <attr_name>="<attacker bytes>". The renderer concatenates that string into a larger HEEx template, then:
defp render_component_heex(fun_or_mod, heex, opts) do
quoted_code =
EEx.compile_string(heex,
engine: TagEngine,
caller: __ENV__,
source: heex,
tag_handler: Phoenix.LiveView.HTMLEngine
)
# ... env with Kernel requires/macros ...
{evaluated, _, _} =
Code.eval_quoted_with_env(quoted_code, [assigns: %{}], env)
LiveViewEngine.live_to_iodata(evaluated)
end
EEx.compile_string/2 parses the HEEx template. When it reaches the attribute the bug controls, the grammar reads the opening ", scans bytes until the next unescaped ", and treats whatever follows that next " as a continuation of the tag, the next attribute, or the closing of the tag. The grammar's state machine does not know that the second " was inside the value's source bytes; in the compiled string, the byte and the delimiter are the same character.
The regression test the fix added documents the canonical payload as one line:
payload =
~s|safe" injected={send(Process.whereis(#{inspect(process_name)}), :rce)} bar="|
Walk that across the compiler. The attribute the LiveView is rendering becomes:
label="safe" injected={send(Process.whereis(:playground_rce_42), :rce)} bar=""
EEx.compile_string/2 sees: label set to the string "safe", then a second attribute injected whose value is an inline Elixir expression, then a third attribute bar set to the empty string. The second attribute's expression is compiled into the quoted tree. Code.eval_quoted_with_env/3 runs the tree with Kernel in scope. send/2 is in Kernel. The test process receives :rce.
send/2 is the regression test's payload because it is the smallest verifiable side effect. The same slot accepts System.cmd/2, File.write!/2, Code.eval_string/1, or anything else Kernel exposes. The advisory's CVSS of 9.5 is the runtime authority of the BEAM process the storybook mounts inside.
The whole chain runs over a LiveView socket. Phoenix LiveView's mount-time CSRF token is enforced once during the WebSocket handshake; the psb-assign event after that is a regular phx_event frame the client sends whenever it wants. There is no per-event re-authentication.
The fix does not add an escape function
The patch in commit 56ab846 deletes the three-clause body of attributes_markup/1 and replaces it with a version that splits the work between two destinations: the Elixir-source slot (for author-tagged {:eval, _} values, which stay compiled into the template) and a runtime data slot (for every other attribute, which is lifted out of the source string entirely).
defp attributes_markup(attributes, index, reserved_attrs \\ []) do
{eval_attrs, runtime_attrs} =
attributes
|> Enum.reject(fn {name, _val} -> name in reserved_attrs end)
|> Enum.split_with(fn
{_name, {:eval, _val}} -> true
_attr -> false
end)
eval_attrs_markup =
Enum.map_join(eval_attrs, " ", fn {name, {:eval, val}} ->
~s|#{name}={#{val}}|
end)
markup =
["{Map.fetch!(@psb_variation_attrs, #{index})}", eval_attrs_markup]
|> Enum.reject(&(&1 == ""))
|> Enum.join(" ")
{markup, Map.new(runtime_attrs)}
end
The runtime attrs are not interpolated into the source string at all. They are returned alongside the markup, eventually bound onto an assigns key called psb_variation_attrs, and the source string the compiler sees contains only this:
{Map.fetch!(@psb_variation_attrs, 0)}
That is HEEx's component-attribute spread syntax. At compile time, the source carries an assigns reference. At runtime, the renderer hands the values in via Code.eval_quoted_with_env(quoted_code, [assigns: assigns], env), where assigns.psb_variation_attrs is a plain map. The compiler never sees the attacker's bytes. The bytes never enter the source.
This is the part nobody else is going to explain.
The fix does not call a HEEx-attribute escape function over the binary value because no such function exists for the slot the binary clause was writing into. HEEx's attribute grammar offers two source-level slots: name="literal" and name={expr}. The literal slot expects a string between two " characters and provides no programmatic way to encode a " inside that string from Elixir source. The expression slot expects parseable Elixir and accepts whatever inspect/2 returns. The first clause and the third clause of the pre-patch function both routed values through the expression slot (the first with author-tagged source, the third with inspect/2) because that is the slot that admits a programmatic escape. The second clause routed through the literal slot and typed the " by hand because the literal slot has no other option to offer.
The patch generalises the safe pattern by lifting all runtime values out of the source string entirely and into the assigns map. The third runtime-data slot, HEEx's component-attribute spread, accepts the assigns reference and resolves the attributes at render time from data, not from source.
The patch does not add an escape function. The literal slot has no function to call. The other two clauses had already routed around its absence.
This is the fourth exhibit on this site of the pattern catalogued as Quote Wrap Is Not Escape. AVideo wrote three apostrophes around a PHP shell argument while forty-seven escapeshellarg calls lived elsewhere in the same tree. GL.iNet wrote two double quotes around a C string while execve and a known-safe argv array were already in the binary. browser-tools-mcp wrote quotes around a Node child_process argument while spawn with an array was one import away. Phoenix Storybook wrote " characters around an HEEx attribute on its binary clause while the other two clauses of the same function routed through HEEx's expression slot via inspect/2 and developer-tagged source. Same defender frame, fourth dialect: a typed delimiter byte in the surrounding source language is not an escape, the destination provides one (or in this case has none for the chosen slot and one for the adjacent slot), and the bug site reached for the byte while a known-safe path sat next to it in the same function.
The patch closes four bugs, not one
While the renderer fix is the headline, the same commit changes the WebSocket-side helper in three other ways the advisory's "vulnerability involves three components" sentence collapses into one bullet. Each of them is a separate BEAM-level bug.
Before the patch, ExtraAssignsHelpers.to_variation_id/2 resolved the caller-supplied variation_id like this:
defp to_variation_id(%{"variation_id" => [group_id, variation_id]}, _ctx),
do: {String.to_atom(group_id), String.to_atom(variation_id)}
defp to_variation_id(%{"variation_id" => variation_id}, _ctx),
do: {:single, String.to_atom(variation_id)}
String.to_atom/1 allocates a new entry in the global atom table for any string it has not seen before. The BEAM's atom table is capped at 1,048,576 entries by default and is never garbage-collected. Any WebSocket caller able to send psb-assign could enumerate a few hundred thousand variation_ids and exhaust the table, at which point the next allocation crashes the entire BEAM node. The routes that read this field accept the value through a frame the LiveView's handle_event/3 calls without checking whether the variation_id corresponds to anything that exists.
The pre-patch handle_set_variation_assign/3 then iterated the rest of the params and converted every attribute name through the same primitive:
for {attr, value} <- params, reduce: variation_extra_assigns do
acc ->
attr = String.to_atom(attr)
value = to_value(value, attr, story.attributes(), context)
Map.put(acc, attr, value)
end
That is one allocated atom per attribute name. A single psb-assign event can carry arbitrary fields and each unrecognised one is an entry into the table.
Then to_value resolved typed attributes:
defp to_value(val, attr_id, attributes, context) when is_binary(val) do
case declared_attr_type(attr_id, attributes) do
:atom -> val |> String.to_atom() |> check_type!(:atom, context)
:boolean -> val |> String.to_atom() |> check_type!(:boolean, context)
...
For any attribute the story declared as type :atom, the value gets allocated. For any attribute declared :boolean, the value gets allocated first and then checked against is_boolean/1, with the check happening after the table entry exists. A payload of {"boolean_attr": "psb_dos_000001"} produces a runtime error, and a permanent atom-table entry, on every send.
The patch replaces every one of those with String.to_existing_atom/1 wrapped in a rescue that raises a controlled error, and adds a regex (~r/^[A-Za-z_:][A-Za-z0-9_:\.-]*[!?]?$/) over attribute names before any conversion runs. It also reaches up into to_variation_id and changes it to look up the variation_id in the existing extra-assigns map rather than allocate a new atom for it.
Four bugs, one commit. The renderer's code injection is the worst of them. The other three exist because the same handler decided that the LiveView WebSocket would only ever be driven by the same developer's browser, that the developer would only send variation_ids and attribute names that already existed in the story, and that the BEAM's atom table was not a thing for the design to worry about. The advisory mentions atom creation in passing. The commit message lists it as a secondary point. It is three separate denial-of-service primitives on the same handler that takes the same input from the same network frame.
The playground was the production deployment
The advisory's Impact section opens with this:
"Any user able to reach the storybook endpoint, including unauthenticated internet users if the storybook is publicly deployed, can execute arbitrary operating system commands with the privileges of the server process."
"If the storybook is publicly deployed" reads like a hypothetical. The same project's README.md lists it as a feature:
## Storybook in production
A few storybooks running in production:
- [Phenix Groupe](https://storybook.phenixgroupe.com/)
- [SaladUI](https://salad-storybook.fly.dev/)
- [DaisyUI Components](https://daisy-ui-components-site.fly.dev/storybook)
- [Noora](https://storybook.noora.tuist.dev/)
- [Bloom](https://bloom-ui.fly.dev/storybook)
- [Doggo](https://doggo.wlyx.dev/)
- [Tremorx](https://tremorx.fly.dev/)
The router macro the library ships with mounts the storybook routes inside a live_session whose only on_mount hook is PhoenixStorybook.Mount. That module's entire body is:
def on_mount(:default, _params, session, socket) do
socket =
assign(socket,
backend_module: Map.fetch!(session, "backend_module"),
root_path: Map.fetch!(session, "root_path"),
assets_path: Map.fetch!(session, "assets_path"),
csp_nonces: Map.fetch!(session, "csp_nonces"),
csrf: Map.fetch!(session, "csrf"),
live_socket_path: Map.fetch!(session, "live_socket_path")
)
{:cont, socket}
end
It propagates configuration. It does not check a user. The router's installed pipeline is :accepts ["html"], :fetch_session, :protect_from_forgery. The canonical usage example in the macro's docstring mounts the storybook in a scope piped through :browser and nothing else:
scope "/" do
pipe_through :browser
live_storybook "/storybook", backend_module: MyAppWeb.Storybook
end
live_storybook does not accept an on_mount option for a host application's authenticated session. The library's data model for "who is talking to the playground" is "the developer running mix phx.server locally." The library's deployment story has seven URLs above it and a section heading saying production.
The same developer who treated the LiveView WebSocket as a local-only channel was also the developer who reached for String.to_atom/1 on every byte the channel delivered, and the developer who typed " around binary attribute values in the HEEx source. Three choices read as correct under a single threat model: "the only caller is me." Three choices read as four CVEs under the threat model the README is marketing.
CVE-2026-8467. GHSA-55hg-8qxv-qj4p. Patch commit 56ab846. Affected: phoenix_storybook 0.5.0 through 1.0.x. Patched in 1.1.0. Credit: ndelphit (finder), cblavier (remediation).
The fix does not add an escape function. The literal slot has none. The other two clauses had already routed around its absence by writing parseable Elixir into the expression form, which is what the patch generalises across every runtime attribute the playground accepts.