CVE-2024-29186 Slow String Operations via MultiPart Requests in Event-Driven Functions

Medium 5.3 Published Updated

Attackers can cause excessive CPU usage and billing costs in Bref PHP serverless functions by sending crafted multipart requests that trigger slow string operations.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2024-29186?

CVE-2024-29186 is a medium-severity denial of service vulnerability in brefphp bref, published on 22 Mar 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

Bref is an open-source project that helps users go serverless on Amazon Web Services with PHP. When Bref prior to version 2.1.17 is used with the Event-Driven Function runtime and the handler is a `RequestHandlerInterface`, then the Lambda event is converted to a PSR7 object. During the conversion process, if the request is a MultiPart, each part is parsed. In the parsing process, the `Content-Type` header of each part is read using the `Riverline/multipart-parser` library.

The library, in the `StreamedPart::parseHeaderContent` function, performs slow multi-byte string operations on the header value. Precisely, the `mb_convert_encoding` function is used with the first (`$string`) and third (`$from_encoding`) parameters read from the header value.

An attacker could send specifically crafted requests which would force the server into performing long operations with a consequent long billed duration.

The attack has the following requirements and limitations: The Lambda should use the Event-Driven Function runtime and the `RequestHandlerInterface` handler and should implement at least an endpoint accepting POST requests; the attacker can send requests up to 6MB long (this is enough to cause a billed duration between 400ms and 500ms with the default 1024MB RAM Lambda image of Bref); and if the Lambda uses a PHP runtime <= php-82, the impact is higher as the billed duration in the default 1024MB RAM Lambda image of Bref could be brought to more than 900ms for each request. Notice that the vulnerability applies only to headers read from the request body as the request header has a limitation which allows a total maximum size of ~10KB.

Version 2.1.17 contains a fix for this issue.

Weakness: CWE-400

Which versions are affected by CVE-2024-29186?

2 open source packages ship an affected version, including bref/bref. It affects 1 product.

PackageAffectedFixed in
bref/bref PackagistAll versions2.1.17
bref/bref PackagistAll versions2.1.17

Products include Mnapoli Bref.

How do I fix CVE-2024-29186?

Upgrade bref/bref to 2.1.17 or later.

Upgrade, then put limits on request size, rate and nesting depth so one client cannot exhaust the service. More about Denial of service.

Is CVE-2024-29186 being exploited?

There is no known exploitation of CVE-2024-29186 in the wild and no public exploit code.

Sources

Also known as GHSA-j4hq-f63x-f39r.

Is CVE-2024-29186 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free