Miggo Logo

CVE-2025-61771: Rack: Multipart parser buffers large non‑file fields entirely in memory, enabling DoS (memory exhaustion)

7.5

CVSS Score
3.1

Basic Information

EPSS Score
-
Published
10/7/2025
Updated
10/7/2025
KEV Status
No
Technology
TechnologyRuby

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Package NameEcosystemVulnerable VersionsFirst Patched Version
rackrubygems< 2.2.192.2.19
rackrubygems>= 3.1, < 3.1.173.1.17
rackrubygems>= 3.2, < 3.2.23.2.2

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The analysis of the provided patches reveals that the vulnerability lies within the Rack::Multipart::Parser class, specifically in two methods that handle the initial parsing of a multipart request. The provided commits address unbounded memory allocation vulnerabilities in handle_fast_forward and handle_mime_head.

The vulnerability description provided (GHSA-w9pc-fmgc-vxvw) focuses on the buffering of large non-file fields, which is a slightly different issue (related to CVE-2025-61771). However, the provided patches are for CVE-2025-61770 (unbounded preamble buffering) and CVE-2025-61772 (unbounded header buffering). The task is to analyze the provided patches, so the identified vulnerable functions are the ones fixed in those commits.

  1. Rack::Multipart::Parser.handle_fast_forward: This function was vulnerable because it lacked a size limit on the data buffered while searching for the first multipart boundary. An attacker could send a request without a boundary, causing the application to run out of memory.

  2. Rack::Multipart::Parser.handle_mime_head: Similarly, this function was vulnerable due to the absence of a size limit on the data buffered for a part's headers. An attacker could send a part with an extremely large header to cause memory exhaustion.

During exploitation, a profiler would show these functions being executed repeatedly as they consume the malicious request body, leading to increased memory usage until the process crashes. Therefore, these two functions are the key runtime indicators for this vulnerability.

Vulnerable functions

Rack::Multipart::Parser.handle_fast_forward
lib/rack/multipart/parser.rb
This function is responsible for parsing the multipart request until the first boundary is found. Prior to the patch, it would continuously buffer data from the input stream into the `@sbuf` variable without any size limit if the boundary was not present. This allows an attacker to send a stream of data without a boundary, causing the server to exhaust its memory, leading to a denial of service.
Rack::Multipart::Parser.handle_mime_head
lib/rack/multipart/parser.rb
This function is responsible for parsing the headers of a MIME part in a multipart request. Before the patch, it would buffer data from the input stream while waiting for the end of the headers (`\r\n\r\n`). If an attacker sent a part with a very large header (or no header termination), the server would buffer the entire header in memory, leading to memory exhaustion and a denial of service.

WAF Protection Rules

WAF Rule

## Summ*ry `R**k::Multip*rt::P*rs*r` stor*s non-*il* *orm *i*l*s (p*rts wit*out * `*il*n*m*`) *ntir*ly in m*mory *s Ru*y `Strin*` o*j**ts. * sin*l* l*r** t*xt *i*l* in * multip*rt/*orm-**t* r*qu*st (*un*r**s o* m****yt*s or mor*) **n *onsum* *quiv*l

Reasoning

T** *n*lysis o* t** provi*** p*t***s r*v**ls t**t t** vuln*r**ility li*s wit*in t** `R**k::Multip*rt::P*rs*r` *l*ss, sp**i*i**lly in two m*t*o*s t**t **n*l* t** initi*l p*rsin* o* * multip*rt r*qu*st. T** provi*** *ommits ***r*ss un*oun*** m*mory *ll