I recently reported a denial-of-service bug in Laravel where a single 790 KB JSON request could tie up a PHP-FPM worker until it timed out. Sending a few dozen of these in parallel from a laptop was enough to knock a fresh Laravel Cloud instance offline, with zero knowledge of the app's routes or auth setup.
Because the request stays under 1 MB, it sails right past Cloudflare, NGINX client_max_body_size, and default PHP post_max_size limits. Everything happens inside Laravel's global middleware before the router even checks if the URL exists.
The payload
The request body is valid JSON with a single ~395 KB key mapped to an array of 200,000 zeros:
{
"èèèè...(394,998 bytes)...èè": [0, 0, 0, 0, 0, ...]
}
On the wire, that comes out to roughly 790 KB. PHP decodes it quickly without complaining, and Laravel hands the parsed request off to its global middleware stack.
Where the amplification happens
Every default Laravel app runs TrimStrings and ConvertEmptyStringsToNull globally. Both extend Illuminate\Foundation\Http\Middleware\TransformsRequest, which walks the entire request payload recursively to normalize values.
Here is the relevant part of src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php before the fix:
protected function cleanArray(array $data, $keyPrefix = '')
{
foreach ($data as $key => $value) {
$data[$key] = $this->cleanValue($keyPrefix.$key, $value);
}
return $data;
}
protected function cleanValue($key, $value)
{
if (is_array($value)) {
return $this->cleanArray($value, $key.'.');
}
return $this->transform($key, $value);
}
When cleanValue() hits the array under that 395 KB key, it passes $key.'.' down as $keyPrefix to cleanArray(). For every single zero in the array, PHP allocates a brand-new concatenated string:
èèèè...èè.0
èèèè...èè.1
èèèè...èè.2
...
èèèè...èè.199999
Even though the values are integers and TrimStrings won't actually trim them, it still builds the full dotted key path and checks it against $except (Str::is()) on every iteration. Multiplying a 395 KB prefix across 200,000 items means PHP churns through roughly 78 GB of temporary string data for a single 790 KB HTTP request.
One request pins a worker until it hits max_execution_time. A handful of concurrent requests exhausts the entire PHP-FPM pool, and the server stops responding to real traffic.
The fix
Taylor patched this in commit 1b8b12d by tracking the cumulative byte length of processed keys across the request and capping it at 20 MiB inside TransformsRequest:
protected $maxKeyBytes = 20 * 1024 * 1024;
protected $keyBytes = 0;
protected function cleanArray(array $data, $keyPrefix = '')
{
$prefixLength = strlen($keyPrefix);
foreach ($data as $key => $value) {
$this->keyBytes += $prefixLength + strlen((string) $key);
if ($this->keyBytes > $this->maxKeyBytes) {
throw new PostTooLargeException('The cumulative size of the input keys is too large.');
}
$data[$key] = $this->cleanValue($keyPrefix.$key, $value);
}
return $data;
}
Once the cumulative key size crosses 20 MiB, Laravel aborts immediately with a 413 (PostTooLargeException) instead of burning CPU for the rest of the array. The counter resets on every handle() call so long-running processes like Octane don't carry state between requests, and the budget is shared across query, form, and JSON parameter bags.
Should you update?
Yes. The fix shipped in Laravel 13.38.0 on October 20, 2026, and no public CVE was assigned, so Dependabot and security scanners won't flag it for you. If you're running Laravel 13 below 13.38.0, bump laravel/framework and redeploy.