CVE-2026-128361: Unsanitized presence key crashes Presence tracker
Summary
Improper Input Validation vulnerability in phoenixframework phoenix (Phoenix.Presence) allows an attacker who can join a channel to cause a denial of service via a non-string presence key.
track/3,4 accepts any term as the presence key, such as a JSON object taken from a join payload. The key is converted with tostring/1 only later, in Phoenix.Presence.group/1, which raises Protocol.UndefinedError on a map. group/1 runs whenever presences are listed and when each presence diff is broadcast, together with the application's fetch/2, which can likewise raise on an unexpected key. Once such a key is tracked, every process that lists presences on the topic crashes, typically each channel that joins it, and presence diffs for the topic are lost.
From 1.7.0 the diff runs in a Task.Supervisor.async task linked to the tracker shard, and Phoenix.Presence.handleinfo/2 has no clause for its failure. The shard then terminates, taking down every channel and LiveView process tracked on it and erasing presence state for all its topics. Repeated joins exhaust the restart intensity and take down the application supervisor.
This issue affects phoenix: from 1.2.0 before 1.5.16, from 1.6.0-rc.0 before 1.6.18, from 1.7.0-rc.0 before 1.7.25, and from 1.8.0-rc.0 before 1.8.17.
Details
1. Key accepted. The track/3,4 injected by use Phoenix.Presence passes any term to Phoenix.Tracker.track, which returns {:ok, ref}. The documented pattern Presence.track(socket, name, meta) with name from the join payload lets a client choose a map as the key.
2. Deferred conversion. Phoenix.Presence.group/1 converts each key with tostring/1. It runs in Phoenix.Presence.list/2, in the calling process, and in handlediff/2 before the application's fetch/2. A map key raises Protocol.UndefinedError there, as does a fetch/2 such as the moduledoc's String.tointeger(key) on a non-numeric key.
3. Topic crash. While the key stays tracked, every list on the topic raises. The documented afterjoin that pushes Presence.list(socket) therefore crashes each later joiner's channel. Before 1.7.0, handlediff/2 runs in an unlinked Task.Supervisor.startchild task, so a failing diff only loses that batch of joins and leaves.
4. Shard crash (1.7.0 and later). handlediff/2 runs the diff in a Task.Supervisor.async task linked to the tracker shard, and Phoenix.Presence.handleinfo/2 matches only the task's success reply. The failure terminates the shard (FunctionClauseError), every tracked process linked to it dies, and presence state is wiped. Repeated joins exhaust the supervisor's restart intensity.
Proof of concept
1. Run a Phoenix endpoint with a channel whose join reads name from the join payload and then calls MyPresence.track(socket, name, %{onlineat: 1}). 2. Join the topic with 15 clients using string names, and confirm MyPresence.list(topic) returns 15 entries. 3. Join once more with the payload {"name": {"x": 1}}. 4. The log shows Protocol.UndefinedError from Phoenix.Presence.group/1, then the shard terminating. All 15 clients receive phxerror, and MyPresence.list(topic) returns 0 entries.
Impact
With one channel join an attacker makes the topic's presence unusable: every later join that lists presences crashes, and presence updates stop. From 1.7.0 the same join terminates every channel and LiveView process tracked on the Presence shard and erases presence state for all its topics, and repeating it brings down the application.
Workarounds
Validate every presence key before passing it to track/3,4, untrack/2,3 or update/3,4, so that only strings reach the tracker. For a key taken from client input, reject a join whose value is not a binary, or convert it explicitly:
elixir def join("room:" <> , %{"name" => name}, socket) when isbinary(name) do send(self(), {:afterjoin, name}) {:ok, socket} end
A fetch/2 callback must also not raise on any tracked key.
Configurations
The application must use Phoenix.Presence and either track presences under a key influenced by client input (such as a name taken from the channel join payload), or define a fetch/2 callback that can raise on a tracked key. Applications that track only server-controlled string keys and whose fetch/2 cannot raise are not affected.
Other sources
Improper Input Validation vulnerability in phoenixframework phoenix (Phoenix.Presence) allows an attacker who can join a channel to cause a denial of service via a non-string presence key.
track/3,4 accepts any term as the presence key, such as a JSON object taken from a join payload. The key is converted with tostring/1 only later, in Phoenix.Presence.group/1, which raises Protocol.UndefinedError on a map. group/1 runs whenever presences are listed and when each presence diff is broadcast, together with the application's fetch/2, which can likewise raise on an unexpected key. Once such a key is tracked, every process that lists presences on the topic crashes, typically each channel that joins it, and presence diffs for the topic are lost.
From 1.7.0 the diff runs in a Task.Supervisor.async task linked to the tracker shard, and Phoenix.Presence.handleinfo/2 has no clause for its failure. The shard then terminates, taking down every channel and LiveView process tracked on it and erasing presence state for all its topics. Repeated joins exhaust the restart intensity and take down the application supervisor.
This issue affects phoenix: from 1.2.0 before 1.5.16, from 1.6.0-rc.0 before 1.6.18, from 1.7.0-rc.0 before 1.7.25, and from 1.8.0-rc.0 before 1.8.17.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
erlang/phoenixto a version that resolves this vulnerability.Fixed in 1.5.16 - Upgrade
Upgrade
erlang/phoenixto a version that resolves this vulnerability.Fixed in 1.6.18 - Upgrade
Upgrade
erlang/phoenixto a version that resolves this vulnerability.Fixed in 1.7.25 - Upgrade
Upgrade
erlang/phoenixto a version that resolves this vulnerability.Fixed in 1.8.17 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 1.5.16 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 1.6.18 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 1.7.25 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 1.8.17 - Compensating control
Validate every presence key before passing it to track/3,4, untrack/2,3, or update/3,4 so only strings reach the tracker; reject client joins with non-binary keys or explicitly convert them, and ensure fetch/2 cannot raise for any tracked key.