Am I affected?

type your phoenix version to check

Description

Allocation of Resources Without Limits or Throttling vulnerability in phoenixframework phoenix allows a denial of service via the long-poll transport's NDJSON body handling.

In 'Elixir.Phoenix.Transports.LongPoll':publish/4, when a POST request is received with Content-Type: application/x-ndjson, the request body is split on newline characters using String.split/2 with no limit on the number of resulting segments. An attacker can send a body consisting entirely of newline bytes, causing a 1:1 amplification into a list of empty binaries — a 1 MB body produces approximately one million list elements, an 8 MB body approximately 8.4 million. Each element is then walked by Enum.map, materializing another list of the same size. This exhausts BEAM memory and schedulers, crashing the node and terminating all active sessions.

A session token required to reach the vulnerable endpoint is freely obtainable by any client via an unauthenticated GET request to the same URL with a matching Origin header, making this attack effectively unauthenticated.

This issue affects phoenix: from 1.7.0 before 1.7.22 and 1.8.6.

Weaknesses & attack patterns

Weakness

CWE-770 · Allocation of Resources Without Limits or Throttling in catalog → MITRE ↗

Attack patterns

CAPEC-130 · Excessive Allocation MITRE ↗

Affected — Hex / phoenix Hex.pm ↗ Repository ↗

1.7 series 1.7.0 < 1.7.22 affected
1.8 series 1.8.0 < 1.8.6 affected
every other version: unaffected
default status unaffected
cpe cpe:2.3:a:phoenixframework:phoenix:*:*:*:*:*:*:*:*
modules · source files · routines
modules 'Elixir.Phoenix.Transports.LongPoll'
source files lib/phoenix/transports/long_poll.ex
routines 'Elixir.Phoenix.Transports.LongPoll':publish/4

Affected — GitHub / phoenixframework/phoenix Repository ↗

2674c6e and up affected
1a67c61 not affected
912ea18 not affected
every other version: unaffected
default status unaffected
cpe cpe:2.3:a:phoenixframework:phoenix:*:*:*:*:*:*:*:*
modules · source files · routines
modules 'Elixir.Phoenix.Transports.LongPoll'
source files lib/phoenix/transports/long_poll.ex
routines 'Elixir.Phoenix.Transports.LongPoll':publish/4

Workarounds

Disable the longpoll transport on all Phoenix.Socket declarations, including the LiveView /live socket, by removing or setting longpoll: false. Note that this prevents clients that cannot use WebSockets from connecting.

Configurations

A Phoenix.Socket must be configured with the longpoll option enabled. Phoenix LiveView applications enable the longpoll transport by default via the /live socket.

References

Credits

Peter Ullrich Finder

CVSS breakdown

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
« All CVEs