EEF-CVE-2026-120287: Multipart `:length` limit not charged for part and header framing in Plug.Parsers.MULTIPART

Published Nov 17, 2026
·
Updated

Summary

Allocation of Resources Without Limits or Throttling vulnerability in Plug.Parsers.MULTIPART in elixir-plug plug allows an unauthenticated remote attacker to exhaust memory via a multipart request body built from parts without headers, or from header lines without a name and a value. The parser charges the :length limit only with the name and value bytes of each part header and the bytes of each part body. The part delimiter, the header separator, and the line endings cost nothing.

In lib/plug/parsers/multipart.ex, Plug.Parsers.MULTIPART.parsemultipartheaders/5 keeps an entry for every part without a content-disposition header, together with its header list, until the whole body is read. A request made of such parts does not reach the limit at any size, and the parser process holds a multiple of the request size in memory until parsing completes. Any endpoint that uses Plug.Parsers with the :multipart parser is reachable.

This issue affects plug: from 1.13.0 before 1.20.4.

Details

1. What the limit counts. Plug.Parsers.MULTIPART.parsemultipartheaders/5 subtracts the result of headerssize/1 from the remaining :length limit. headerssize/1 sums bytesize(key) + bytesize(value) for each header. The part delimiter, the colon and CRLF of each header line, and the blank line that ends the header block are not counted.

2. Inputs that cost zero. A part without headers has an empty header list, so its charge is 0. A header line that holds only : followed by CRLF also costs 0, because :plugmultipart.parsehdname/3 accepts the empty name and returns the header {"", ""}.

3. Retention. multiparttype/1 returns {:binary, nil} for a part without a content-disposition header. The parser then prepends {nil, headers, body} to its accumulator for that part. Plug.Parsers.MULTIPART.multiparttoparams/3 drops these entries, but only after the whole request body is read.

4. Limits that stay in effect. Plug.Conn.readpartheaders/2 limits one header block to the smaller of :length and :readlength. No limit applies to the sum over all parts.

On plug 1.20.3 with length: 100000, a 4.5 MB body of 500,001 parts without headers parsed successfully with a peak of 92 MiB in the parser process. A 4.5 MB body of 50 parts with 30,000 : header lines each peaked at 283 MiB.

Proof of concept

1. Build a multipart body with the boundary b that holds 500,001 parts without headers: the opening --b\r\n\r\n, then \r\n--b\r\n\r\n repeated 500,000 times, then \r\n--b--\r\n. The body is 4.5 MB. 2. Create a connection with Plug.Test.conn(:post, "/", body) and the request header content-type: multipart/form-data; boundary=b. 3. Call Plug.Parsers.MULTIPART.parse/5 with the options from Plug.Parsers.MULTIPART.init(length: 100000). 4. Observe that the call returns {:ok, %{}, conn} and not {:error, :toolarge, conn}, and that the memory of the calling process rises to about 20 times the body size during the call. 5. Repeat with 50 parts that each hold 30,000 header lines of :\r\n. The result is the same, with about 65 times the body size.

Impact

One request makes the process that parses it hold many times the request size in memory until parsing completes, and concurrent requests add up. An application that accepts multipart requests from unauthenticated clients can run out of memory.

Workarounds

Limit the request body size in a reverse proxy in front of the application, for example with clientmaxbodysize in nginx. The proxy rejects a larger body before it reaches the parser. This limits the memory that one request can hold but does not remove the multiplication: a body below the proxy limit still passes the :length limit.

Other sources

Allocation of Resources Without Limits or Throttling vulnerability in Plug.Parsers.MULTIPART in elixir-plug plug allows an unauthenticated remote attacker to exhaust memory via a multipart request body built from parts without headers, or from header lines without a name and a value. The parser charges the :length limit only with the name and value bytes of each part header and the bytes of each part body. The part delimiter, the header separator, and the line endings cost nothing.

In lib/plug/parsers/multipart.ex, Plug.Parsers.MULTIPART.parsemultipartheaders/5 keeps an entry for every part without a content-disposition header, together with its header list, until the whole body is read. A request made of such parts does not reach the limit at any size, and the parser process holds a multiple of the request size in memory until parsing completes. Any endpoint that uses Plug.Parsers with the :multipart parser is reachable.

This issue affects plug: from 1.13.0 before 1.20.4.

— OSV

Affected Software

1 affected componentFixes available
erlang/plug>=1.13.0<1.20.4
1.20.4

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade erlang/plug to a version that resolves this vulnerability.

    Fixed in 1.20.4
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 1.20.4
  3. Configuration

    Set a request-body size limit in the reverse proxy so oversized multipart requests are rejected before reaching the application.

    nginx client_max_body_size

Event History

Nov 17, 2026
CVE Published
via OSV·04:53 PM
Data Sourced
via OSV·04:53 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which deployments are exposed to this issue?

Any endpoint that uses Plug.Parsers with the :multipart parser is reachable. Affected Plug versions are 1.13.0 through versions before 1.20.4.

2

Does exploitation require authentication or user interaction?

No. The issue can be exploited by an unauthenticated remote attacker, and the supplied severity vector indicates no user interaction or privileges are required.

3

What kind of multipart request triggers the memory exhaustion?

An attacker can send a multipart body made from parts without headers, or from header lines that lack both a name and a value. Framing bytes such as part delimiters, header separators, and line endings are not charged against the configured :length limit.

4

Why might the configured :length limit fail to protect the application?

The parser charges only part-header name and value bytes and part-body bytes. For malformed parts that avoid those charged fields, the request does not reach the limit regardless of size, while parser state is retained until the complete body is read.

5

What is the available remediation?

Update Plug to version 1.20.4 or later. The provided data does not specify a workaround for deployments that cannot update immediately.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203