{"id":"CVE-2026-53653","aliases":["GHSA-4x9g-vw65-vvf9"],"url":"https://o3.security/vulnerability/CVE-2026-53653","summary":"Grav: Unauthenticated denial of service via unbounded image derivative dimensions","details":"### Summary\nAn unauthenticated visitor exhausts server memory and CPU by requesting an image with oversized resize dimensions. One request drives a worker to several gigabytes of RAM and tens of seconds of CPU. A few concurrent requests take the host down.\n\n### Details\n`Grav::fallbackUrl()` (system/src/Grav/Common/Grav.php:800-804) loops over every query parameter and, when the name matches `ImageMedium::$magic_actions`, calls that method on the medium with the comma-split value as arguments:\n\n```php\nforeach ($uri->query(null, true) as $action => $params) {\n    if (in_array($action, ImageMedium::$magic_actions, true)) {\n        call_user_func_array([&$medium, $action], explode(',', $params));\n    }\n}\n```\n\n`forceResize` runs with `force=true`, so it sets the output size to the attacker's values with no clamp against the source or any ceiling. The `getgrav/image` GD adapter then calls `imagecreatetruecolor($w, $h)`. libgd allocates that buffer outside PHP's `emalloc`, so `memory_limit` does not cap it. Grav exposes no `system.images.max_width`/`max_height` setting.\n\n### PoC\nAny page that serves an image works. With a 200x150 source image:\n\n```\nGET /home/test.png?forceResize=20000,20000\n```\n\nMeasured on PHP 8.4.21 with `memory_limit=128M`:\n\n- peak worker RSS 3,109 MB\n- 21.9 s CPU\n- HTTP 200, 1.6 MB response\n\n`8000x8000` already needs ~244 MB. The cache key includes the dimensions, so varying them forces fresh work on every request.\n\n### Impact\nUnauthenticated denial of service against any Grav site that serves images. No account, plugin, or non-default config required.\n\n## Fix\nClamp the request-derived dimensions before dispatch, behind a configurable cap. The image library is the wrong layer; bound the arguments at the request boundary.\n\n```diff\n--- a/system/src/Grav/Common/Grav.php\n+++ b/system/src/Grav/Common/Grav.php\n@@ public function fallbackUrl($path)\n                 foreach ($uri->query(null, true) as $action => $params) {\n                     if (in_array($action, ImageMedium::$magic_actions, true)) {\n-                        call_user_func_array([&$medium, $action], explode(',', $params));\n+                        $args = explode(',', $params);\n+                        $max = (int) $config->get('system.images.max_dimension', 8000);\n+                        if ($max > 0\n+                            && in_array($action, ['resize', 'forceResize', 'cropResize', 'cropZoom', 'zoomCrop', 'crop'], true)) {\n+                            foreach ($args as $a) {\n+                                if (is_numeric($a) && (int) $a > $max) {\n+                                    return false; // reject oversized derivative request\n+                                }\n+                            }\n+                        }\n+                        call_user_func_array([&$medium, $action], $args);\n                     }\n                 }\n```\n\nDocument `system.images.max_dimension` (default 8000) so operators can tune it. A total-pixel ceiling (`width * height`) is a stricter alternative.","published":"2026-07-10T16:12:01.576Z","modified":"2026-08-12T03:51:45.285494746Z","cvss":null,"epss":{"score":0.00524,"percentile":0.43226,"asOf":"2026-09-17"},"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"Packagist","name":"getgrav/grav","fixedVersion":"2.0.0-rc.8"},{"ecosystem":"Packagist","name":"getgrav/grav","fixedVersion":"1.7.53"}],"fix":{"url":"https://github.com/getgrav/grav/commit/d9f9f0369a07ae5c96cde700c7949e1237b29cf6","label":"getgrav/grav@d9f9f03"},"references":[{"type":"WEB","url":"https://github.com/getgrav/grav/releases/tag/1.7.53"},{"type":"WEB","url":"https://github.com/getgrav/grav/releases/tag/2.0.0-rc.8"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/53xxx/CVE-2026-53653.json"},{"type":"ADVISORY","url":"https://github.com/getgrav/grav/security/advisories/GHSA-4x9g-vw65-vvf9"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-53653"},{"type":"FIX","url":"https://github.com/getgrav/grav/commit/d9f9f0369a07ae5c96cde700c7949e1237b29cf6"},{"type":"FIX","url":"https://github.com/getgrav/grav/commit/f4c0f42eea755cedad6f626b342c88d4cba72174"},{"type":"PACKAGE","url":"https://github.com/getgrav/grav"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:45.285494746Z"}}