{"id":"EEF-CVE-2026-128361","summary":"Unsanitized presence key crashes Presence tracker","details":"## Summary\n\nImproper 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.\n\n`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 `to_string/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.\n\nFrom 1.7.0 the diff runs in a `Task.Supervisor.async` task linked to the tracker shard, and `Phoenix.Presence.handle_info/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.\n\nThis 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.\n\n## Details\n\n**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.\n\n**2. Deferred conversion.** `Phoenix.Presence.group/1` converts each key with `to_string/1`. It runs in `Phoenix.Presence.list/2`, in the calling process, and in `handle_diff/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.to_integer(key)` on a non-numeric key.\n\n**3. Topic crash.** While the key stays tracked, every `list` on the topic raises. The documented `after_join` that pushes `Presence.list(socket)` therefore crashes each later joiner's channel. Before 1.7.0, `handle_diff/2` runs in an unlinked `Task.Supervisor.start_child` task, so a failing diff only loses that batch of joins and leaves.\n\n**4. Shard crash (1.7.0 and later).** `handle_diff/2` runs the diff in a `Task.Supervisor.async` task linked to the tracker shard, and `Phoenix.Presence.handle_info/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.\n\n## Proof of concept\n\n1. Run a Phoenix endpoint with a channel whose join reads `name` from the join payload and then calls `MyPresence.track(socket, name, %{online_at: 1})`.\n2. Join the topic with 15 clients using string names, and confirm `MyPresence.list(topic)` returns 15 entries.\n3. Join once more with the payload `{\"name\": {\"x\": 1}}`.\n4. The log shows `Protocol.UndefinedError` from `Phoenix.Presence.group/1`, then the shard terminating. All 15 clients receive `phx_error`, and `MyPresence.list(topic)` returns 0 entries.\n\n## Impact\n\nWith 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.\n\n## Workarounds\n\nValidate 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:\n\n```elixir\ndef join(\"room:\" \u003c\u003e _, %{\"name\" =\u003e name}, socket) when is_binary(name) do\n  send(self(), {:after_join, name})\n  {:ok, socket}\nend\n```\n\nA `fetch/2` callback must also not raise on any tracked key.\n\n## Configurations\n\nThe 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.","aliases":["GHSA-pvfx-rx4x-phrr","CVE-2026-128361"],"modified":"2026-11-21T11:15:02.497045959Z","published":"2026-11-21T11:09:51.800Z","database_specific":{"capec_ids":["CAPEC-153"],"cpe_ids":["cpe:2.3:a:phoenixframework:phoenix:*:*:*:*:*:*:*:*"],"cwe_ids":["CWE-20"]},"references":[{"type":"ADVISORY","url":"https://github.com/phoenixframework/phoenix/security/advisories/GHSA-pvfx-rx4x-phrr"},{"type":"WEB","url":"https://cna.erlef.org/cves/CVE-2026-128361.html"},{"type":"WEB","url":"https://github.com/phoenixframework/phoenix/commit/44e7618370629df93711cd6169789fd0d8f3678e"},{"type":"FIX","url":"https://github.com/phoenixframework/phoenix/commit/39c1c6bfd0c817f1223c121f61c60a25f66b76cb"},{"type":"FIX","url":"https://github.com/phoenixframework/phoenix/commit/6609595fb3e37f545c4ac636a369f14b0084bc3d"},{"type":"FIX","url":"https://github.com/phoenixframework/phoenix/commit/81bc0278c7a4e6204f7e2e0a3b3200e9f1ee5a4b"},{"type":"FIX","url":"https://github.com/phoenixframework/phoenix/commit/edb702804aeab3a29543668a8be8ea61291c4b75"},{"type":"PACKAGE","url":"https://hex.pm/packages/phoenix"}],"affected":[{"package":{"name":"phoenix","ecosystem":"Hex","purl":"pkg:hex/phoenix"},"ranges":[{"type":"SEMVER","events":[{"introduced":"1.2.0"},{"fixed":"1.5.16"}]},{"type":"SEMVER","events":[{"introduced":"1.6.0-rc.0"},{"fixed":"1.6.18"}]},{"type":"SEMVER","events":[{"introduced":"1.7.0-rc.0"},{"fixed":"1.7.25"}]},{"type":"SEMVER","events":[{"introduced":"1.8.0-rc.0"},{"fixed":"1.8.17"}]}],"versions":["1.2.0","1.2.1","1.2.2","1.2.3","1.2.4","1.2.5","1.3.0","1.3.0-rc.0","1.3.0-rc.1","1.3.0-rc.2","1.3.0-rc.3","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.4.0","1.4.0-rc.0","1.4.0-rc.1","1.4.0-rc.2","1.4.0-rc.3","1.4.1","1.4.10","1.4.11","1.4.12","1.4.13","1.4.14","1.4.15","1.4.16","1.4.17","1.4.18","1.4.2","1.4.3","1.4.4","1.4.5","1.4.6","1.4.7","1.4.8","1.4.9","1.5.0","1.5.0-rc.0","1.5.1","1.5.10","1.5.11","1.5.12","1.5.13","1.5.14","1.5.15","1.5.2","1.5.3","1.5.4","1.5.5","1.5.6","1.5.7","1.5.8","1.5.9","1.6.0","1.6.0-rc.0","1.6.0-rc.1","1.6.1","1.6.10","1.6.11","1.6.12","1.6.13","1.6.14","1.6.15","1.6.16","1.6.17","1.6.2","1.6.3","1.6.4","1.6.5","1.6.6","1.6.7","1.6.8","1.6.9","1.7.0","1.7.0-rc.0","1.7.0-rc.1","1.7.0-rc.2","1.7.0-rc.3","1.7.1","1.7.10","1.7.11","1.7.12","1.7.13","1.7.14","1.7.15","1.7.16","1.7.17","1.7.18","1.7.19","1.7.2","1.7.20","1.7.21","1.7.22","1.7.23","1.7.24","1.7.3","1.7.4","1.7.5","1.7.6","1.7.7","1.7.8","1.7.9","1.8.0","1.8.0-rc.0","1.8.0-rc.1","1.8.0-rc.2","1.8.0-rc.3","1.8.0-rc.4","1.8.1","1.8.10","1.8.11","1.8.12","1.8.13","1.8.14","1.8.15","1.8.16","1.8.2","1.8.3","1.8.4","1.8.5","1.8.6","1.8.7","1.8.8","1.8.9"],"database_specific":{"source":"https://cna.erlef.org/osv/EEF-CVE-2026-128361.json"}},{"ranges":[{"type":"GIT","repo":"https://github.com/phoenixframework/phoenix","events":[{"introduced":"44e7618370629df93711cd6169789fd0d8f3678e"},{"fixed":"39c1c6bfd0c817f1223c121f61c60a25f66b76cb"},{"fixed":"6609595fb3e37f545c4ac636a369f14b0084bc3d"},{"fixed":"81bc0278c7a4e6204f7e2e0a3b3200e9f1ee5a4b"},{"fixed":"edb702804aeab3a29543668a8be8ea61291c4b75"}]}],"versions":["v1.5.15","v1.6.17","v1.7.24","v1.8.16","v1.8.15","v1.8.14","v1.8.13","v1.8.12","v1.8.11","v1.8.9","v1.5.13","v1.6.16","v1.7.23","v1.8.8","v1.8.7","v1.8.6","v1.7.22","v1.8.5","v1.8.4","v1.8.3","v1.8.2","v1.8.1","v1.8.0","v1.8.0-rc.4","v1.8.0-rc.3","v1.8.0-rc.2","v1.8.0-rc.1","v1.8.0-rc.0","v1.7.20","v1.7.19","v1.7.18","v1.7.16","v1.7.15","v1.7.14","v1.7.13","v1.7.12","v1.7.11","v1.7.10","v1.7.9","v1.7.8","v1.7.7","v1.7.6","v1.7.5","v1.7.4","v1.7.3","v1.7.2","v1.7.1","v1.7.0","v1.7.0-rc.3","v1.7.0-rc.2","v1.7.0-rc.1","v1.7.0-rc.0","v1.6.15","v1.6.14","v1.6.13","v1.6.12","v1.6.11","v1.6.10","v1.6.7","v1.6.6","v1.6.5","v1.6.4","v1.6.3","v1.6.2","v1.6.1","v1.6.0","v1.6.0-rc.1","v1.6.0-rc.0","v1.5.12","v1.5.11","v1.5.10","v1.5.9","v1.5.8","v1.5.7","v1.5.6","v1.5.5","v1.5.4","v1.5.3","v1.5.2","v1.5.1","v1.5.0","v1.5.0-rc.0","v1.4.0","v1.4.0-rc.3","v1.4.0-rc.2","v1.4.0-rc.1","v1.4.0-rc.0","v1.3.0","v1.3.0-rc.3","v1.3.0-rc.2","v1.3.0-rc.1","v1.3.0-rc.0","v1.2.0"],"database_specific":{"source":"https://cna.erlef.org/osv/EEF-CVE-2026-128361.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","source":"CNA"}],"credits":[{"name":"Peter Ullrich","type":"FINDER"},{"name":"Peter Ullrich","type":"REPORTER"},{"name":"Steffen Deusch","type":"REMEDIATION_DEVELOPER"},{"name":"José Valim","type":"REMEDIATION_REVIEWER"}]}