[CVE-2024-25126] Denial of Service Vulnerability in Rack Content-Type Parsing
Rack's media type parser can take much longer than expected when given carefully crafted Content-Type headers, which could lead to a denial of service. The report is a brief advisory that points to a full security advisory.
- Triaged in 40 hours
- Fixed in 19 days
- Paid in 19 days
- Disclosed after 49 days
Summary by the program
Denial of Service Vulnerability in Rack Content-Type Parsing
There is a possible denial of service vulnerability in the content type parsing component of Rack. This vulnerability has been assigned the CVE identifier CVE-2024-25126.
Versions Affected: >= 0.4 Not affected: < 0.4 Fixed Versions: 3.0.9.1, 2.2.8.1
Impact Carefully crafted content type headers can cause Rack’s media type parser to take much longer than expected, leading to a possible denial of service vulnerability.
Impacted code will use Rack’s media type parser to parse content type headers. Some frameworks (including Rails) call this code internally, so upgrading is recommended!
All users running an affected release should either upgrade or use one of the workarounds immediately.
Credits Thanks to @ byroot and @ jeremyevans for the patch, also thank you to svalkanov 14 for reporting this issue!
Full Security Advisory: https://discuss.rubyonrails.org/t/denial-of-service-vulnerability-in-rack-content-type-parsing/84941
The report
I've made a report https://discuss.rubyonrails.org/t/denial-of-service-vulnerability-in-rack-content-type-parsing/84941
Impact
Carefully crafted content type headers can cause Rack’s media type parser to take much longer than expected, leading to a possible denial of service vulnerability.
Context
Rack is the Ruby web server interface that sits between Ruby web frameworks and the application server. One of the things it does on every request is parse the Content-Type header into a media type and its parameters, using its media type parser. Frameworks built on Rack, including Rails, call this parser internally, so the parsing path is reachable on ordinary requests rather than only through a dedicated API.
The issue described here is a denial of service in that content type parsing component, tracked as CVE-2024-25126 and classified as uncontrolled resource consumption. The affected asset is the Rack repository at https://github.com/rack/rack.
Setup
The advisory states the following version ranges:
| Item | Value |
|---|---|
| Versions affected | >= 0.4 |
| Not affected | < 0.4 |
| Fixed versions | [redacted], [redacted] |
No accounts, roles or special tooling are involved. The precondition is simply that the target runs an affected Rack release and that some reachable code path passes a client-supplied Content-Type header to Rack's media type parser. Because frameworks such as Rails call this code internally, that precondition is common.
Finding it
The researcher's report is short: it points to the public security advisory at https://discuss.rubyonrails.org/t/denial-of-service-vulnerability-in-rack-content-type-parsing/84941. The substance of the finding, as recorded in the advisory, is that carefully crafted content type headers can cause Rack's media type parser to take much longer than expected. That unexpected increase in parsing time is what turns into a possible denial of service.
The report does not include the specific header values that trigger the slowdown, nor any timing measurements, so the exact shape of the crafted input is not documented in the material available here.
Exploitation
The advisory does not publish a request, payload or reproduction script. What it establishes is the attack surface and the effect:
- The attacker controls the
Content-Typeheader of a request to an application running an affected Rack version. - The application, directly or through a framework such as Rails, hands that header to Rack's media type parser.
- A carefully crafted value makes the parser take much longer than expected.
- Repeated or concurrent requests carrying such values consume server resources, which is the denial of service condition.
No sample header, response or timing figure is given, so there is nothing further to reproduce verbatim from the report.
Root cause
The advisory attributes the behaviour to the content type parsing component: carefully crafted content type headers can make the media type parser take much longer than expected. The report does not describe the internal algorithm or the precise input pattern responsible, so the exact parsing weakness is not stated.
Impact
An attacker who can send requests to an application running an affected release can cause the media type parser to take much longer than expected, leading to a possible denial of service. The advisory hedges this as a possible denial of service, and the platform records the severity as low. The impact applies to any deployment where impacted code uses Rack's media type parser to parse content type headers, which includes frameworks that call it internally. The report gives no amplification factor, request rate or measured outage, so the practical scale is not quantified.
Fix
The fix is to upgrade to one of the fixed versions: [redacted] or 2.2.8.1. The advisory states that all users running an affected release should either upgrade or use one of the workarounds immediately, but the workarounds themselves are not reproduced in the report text available here. The patch is credited to @byroot and @jeremyevans. The report does not describe what the patch changes in the parser.
Variants to test
Because the exact crafted input is not published, the practical approach is to probe the parser's behaviour on inputs that stress its structure:
- Send
Content-Typevalues with many parameters or repeated delimiters and compare response time against a simpletext/plainbaseline. A positive result is response time that grows disproportionately with header length or parameter count. - Try values with unbalanced or nested quoting and separators. A positive result is parsing time that scales worse than linearly as the input grows.
- Test through a framework endpoint rather than a bare Rack app, since Rails and similar frameworks call the parser internally. A positive result is the same slowdown on an ordinary application route.
- Vary header size incrementally and record timings to distinguish a genuine algorithmic slowdown from ordinary large-header cost.
Hunting notes
This class of bug hides in parsers that run on attacker-controlled headers before any application logic: content negotiation, media type and parameter parsing, and anything a framework invokes implicitly on every request. During recon, the signal is a stack that includes Rack (or a framework built on it) at an affected version, since the vulnerable code is reached without any special endpoint. Demonstrating impact means showing that a crafted header makes parsing take much longer than expected, ideally with timings that scale badly as the input grows; The issue was assigned CVE-2024-25126, with the advisory crediting svalkanov for the report.
What happened, in plain words
A security researcher found a way to make a piece of software called Rack do a lot of unnecessary work. Rack is a building block used by many websites written in the Ruby programming language. When a browser or any other program sends a request to such a website, it includes a small label called a Content-Type header that says what kind of data is being sent, for example that it is plain text or a form submission. Rack reads that label and breaks it into pieces so the website can understand it.
The researcher discovered that a specially crafted version of that label can make Rack's reading step take much longer than it should. If an attacker sends many such requests, the server may spend its time doing this slow reading instead of serving real visitors, which could make the site slow or unavailable. That kind of attack is called a denial of service: the goal is not to steal data but to stop the service from working.
The problem was given the identifier CVE-2024-25126. The platform that recorded the report lists the severity as low. The issue was fixed in Rack versions [redacted] and 2.2.8.1.
Context
To understand the issue you need three ideas: what Rack is, what a header is, and what a parser is.
Rack is a piece of software that sits between a Ruby web framework (the toolkit a developer uses to build a website) and the application server (the program that actually listens for requests). Think of it as a translator at a reception desk: the framework and the server speak slightly different languages, and Rack makes sure a request gets passed from one to the other in a shape both understand. Because many Ruby websites use Rack underneath, a problem in Rack can affect many sites.
A header is a small line of text that travels with every web request and response. When your browser asks for a page, it sends headers saying things like which browser it is and what kind of answer it can accept. One of these headers is Content-Type, which describes the format of any data being sent along with the request. A simple example value is text/plain, meaning plain text.
A parser is a piece of code that takes a piece of text and works out its structure. If you receive the string text/plain; charset=utf-8, a parser splits it into the media type (text/plain) and a parameter (charset=utf-8). A useful comparison is a postal worker sorting mail: they read the address line and separate street, number and postcode. Normally this takes a fraction of a second.
Rack does exactly this on every request: it parses the Content-Type header into a media type and its parameters using its media type parser. Frameworks built on Rack, including Rails, call this parser internally. That means the parsing code runs on ordinary requests, not only through some special endpoint that a developer deliberately created. The affected asset named in the report is the Rack repository at https://github.com/rack/rack.
The issue is a denial of service in that content type parsing component, classified as uncontrolled resource consumption. Uncontrolled resource consumption means the software uses more of a resource (here, processing time) than it should, because nothing puts a limit on the work it does.
Setup
The advisory states the following version ranges:
| Item | Value |
|---|---|
| Versions affected | >= 0.4 |
| Not affected | < 0.4 |
| Fixed versions | [redacted], [redacted] |
What the table means in plain words:
- Versions affected: >= 0.4. Every Rack release from 0.4 onwards contains the problem. The
>=symbol means "greater than or equal to". - Not affected: < 0.4. Releases older than 0.4 do not have the problem. The
<symbol means "less than". - Fixed versions: [redacted], 2.2.8.1. If you upgrade to one of these two releases, the problem is gone. There are two because Rack maintains two lines of releases at the same time, a newer major line (3.x) and an older one (2.2.x), and both needed a fix.
No accounts, roles or special tooling are involved. There is no login to obtain and no particular permission to hold. The only precondition is that the target runs an affected Rack release and that some reachable code path passes a client-supplied Content-Type header to Rack's media type parser. Because frameworks such as Rails call this code internally, that precondition is common: a normal website built on Rails will do it without the developer writing any extra code.
Finding it
The researcher's report is short: it points to the public security advisory at https://discuss.rubyonrails.org/t/denial-of-service-vulnerability-in-rack-content-type-parsing/84941. An advisory is the official notice a project publishes to tell its users about a security problem and what to do about it.
The substance of the finding, as recorded in the advisory, is that carefully crafted content type headers can cause Rack's media type parser to take much longer than expected. That unexpected increase in parsing time is what turns into a possible denial of service. In everyday terms: the postal worker normally sorts an address in a second, but a deliberately strange address makes them stand there for minutes working it out, and the queue behind them grows.
The report does not include the specific header values that trigger the slowdown, nor any timing measurements, so the exact shape of the crafted input is not documented in the material available here.
Exploitation
The advisory does not publish a request, payload or reproduction script. What it establishes is the attack surface and the effect. The attack surface is simply the part of the system an attacker can reach, here the Content-Type header of any request. The effect is the slowdown. The steps are:
- The attacker controls the
Content-Typeheader of a request to an application running an affected Rack version. Anyone who can send a request can set this header; it is ordinary text chosen by the client. - The application, directly or through a framework such as Rails, hands that header to Rack's media type parser. The developer does not have to do anything special for this to happen; it is part of normal request handling.
- A carefully crafted value makes the parser take much longer than expected. The crafted value is the strange address that keeps the postal worker busy.
- Repeated or concurrent requests carrying such values consume server resources, which is the denial of service condition. "Concurrent" means several requests arriving at the same time. A server has a limited number of workers or threads, so if each one is stuck on a slow parse, new visitors wait or are turned away.
No sample header, response or timing figure is given, so there is nothing further to reproduce verbatim from the report.
Root cause
The advisory attributes the behaviour to the content type parsing component: carefully crafted content type headers can make the media type parser take much longer than expected. "Does not bound the work" means there is no ceiling on how much effort the parser will spend; a well-written parser would give up or finish quickly regardless of the input.
The report does not describe the internal algorithm or the precise input pattern responsible, so the exact parsing weakness is not stated. In other words, there was no gatekeeper checking the header before the slow work began.
Impact
An attacker who can send requests to an application running an affected release can cause the media type parser to take much longer than expected, leading to a possible denial of service. The advisory hedges this as a possible denial of service, and the platform records the severity as low. "Low" severity generally means the issue is real but limited in how easily it can be exploited or how much damage it can do.
The impact applies to any deployment where impacted code uses Rack's media type parser to parse content type headers, which includes frameworks that call it internally. The report gives no amplification factor, request rate or measured outage, so the practical scale is not quantified. An amplification factor would be how much server effort one cheap request buys the attacker; without it, we cannot say how many requests would be needed to take a site down.
Fix
The fix is to upgrade to one of the fixed versions: [redacted] or 2.2.8.1. Upgrading means replacing the copy of Rack your application uses with the newer release, usually by changing the version number in the project's dependency file and reinstalling. The advisory states that all users running an affected release should either upgrade or use one of the workarounds immediately, but the workarounds themselves are not reproduced in the report text available here.
The patch is credited to @byroot and @jeremyevans. The report does not describe what the patch changes in the parser.
Variants to test
Because the exact crafted input is not published, the practical approach is to probe the parser's behaviour on inputs that stress its structure. "Probing" means sending test inputs and watching how the system responds, rather than reading the code. Each test below compares a strange input against a normal one:
- Send
Content-Typevalues with many parameters or repeated delimiters and compare response time against a simpletext/plainbaseline. A baseline is a normal measurement you compare against, like timing a straight walk before timing a walk through an obstacle course. A positive result is response time that grows disproportionately with header length or parameter count: doubling the input should not quadruple the time. - Try values with unbalanced or nested quoting and separators. Unbalanced quoting means an opening quote with no closing quote, and nested quoting means quotes inside quotes. A positive result is parsing time that scales worse than linearly as the input grows. "Worse than linearly" means that if you double the input, the time more than doubles.
- Test through a framework endpoint rather than a bare Rack app, since Rails and similar frameworks call the parser internally. An endpoint is a specific address on a website that accepts requests. A positive result is the same slowdown on an ordinary application route, which shows the problem is reachable in real deployments, not just in a minimal test setup.
- Vary header size incrementally and record timings to distinguish a genuine algorithmic slowdown from ordinary large-header cost. A large header naturally takes a little longer to read, just as a longer letter takes a little longer to read aloud; the point is to separate that normal cost from the disproportionate slowdown caused by the bug.
Hunting notes
This class of bug hides in parsers that run on attacker-controlled headers before any application logic: content negotiation, media type and parameter parsing, and anything a framework invokes implicitly on every request. "Implicitly" means without the developer writing a line of code for it; it happens as part of the framework's normal behaviour. Content negotiation is the process of the client and server agreeing on a format, for example the client saying it prefers JSON and the server choosing accordingly.
During recon, the signal is a stack that includes Rack (or a framework built on it) at an affected version, since the vulnerable code is reached without any special endpoint. Recon, short for reconnaissance, is the early stage of looking at a target to learn what it is built from. A stack here means the collection of software layers the site runs on. If you see Rack at an affected version in that stack, the slow parser is present and reachable.
Demonstrating impact means showing that a crafted header makes parsing take much longer than expected, ideally with timings that scale badly as the input grows. The issue was assigned CVE-2024-25126, with the advisory crediting svalkanov for the report.
Glossary
- Advisory: an official public notice from a software project describing a security problem, who is affected and how to fix it.
- Amplification factor: how much server effort one cheap attacker request produces; a high factor means few requests cause a lot of work.
- Application server: the program that listens for incoming web requests and passes them to the application code.
- Baseline: a normal measurement taken for comparison, so you can tell whether a test input is unusually slow.
- Concurrent: happening at the same time; concurrent requests arrive together rather than one after another.
- Content negotiation: the process by which a client and server agree on the format of the data exchanged.
- Content-Type header: a line of text sent with a request or response that states the format of the data, for example
text/plain. - CVE: Common Vulnerabilities and Exposures, a public catalogue that gives each known security issue a unique identifier such as CVE-2024-25126.
- Denial of service (DoS): an attack that aims to make a service slow or unavailable rather than to steal data.
- Endpoint: a specific address on a website or API that accepts requests.
- Framework: a collection of ready-made code that developers build an application on top of, such as Rails.
- Header: a small line of text sent alongside a web request or response carrying metadata such as the data format or browser type.
- Implicitly: happening automatically as part of normal behaviour, without the developer writing code for it.
- Linear scaling: when doubling the input doubles the work; worse than linear means the work grows faster than the input.
- Media type: the formal name for a data format, such as
text/plainorapplication/json. - Media type parser: the code that reads a media type string and splits it into the type and its parameters.
- Parameter: an extra piece of information attached to a media type, such as
charset=utf-8. - Parser: code that reads a piece of text and works out its structure.
- Patch: the code change that fixes a bug.
- Payload: the input an attacker sends to trigger a vulnerability.
- Precondition: something that must be true before an attack can work, such as running an affected version.
- Rack: a Ruby web server interface that sits between Ruby frameworks and the application server and handles common request processing.
- Rails: a popular Ruby web framework built on Rack.
- Recon (reconnaissance): the early information-gathering stage of examining a target.
- Release: a published version of a piece of software.
- Severity: a rating of how serious a vulnerability is, often low, medium, high or critical.
- Stack: the collection of software layers a site runs on.
- Uncontrolled resource consumption: a weakness where software uses more of a resource, such as processing time, than it should because nothing limits the work.
- Upgrade: replacing the version of a piece of software you use with a newer one.
- Workaround: a temporary measure that reduces the risk without applying the official fix.