ZeroHour

CVE-2026-85604

large

Authenticated sandbox-escape RCE via Twig sort filter in Grav CMS

CVSS 4.0
8.7 high
EPSS
<1%p40
Published
()
Modified
AI analysis

Grav CMS before 2.0.18 contains a remote code execution flaw in its Twig sandbox: the sortFunc wrapper in GravExtension.php hardcodes Twig's isSandboxed argument to false, so unlike |map, |filter, and |reduce, the |sort filter accepts a plain PHP function name inside the sandbox, and the function denylist omits spl_autoload, which performs a PHP include. An authenticated user holding only page-write rights (admin.pages or api.pages.write) can plant a crafted payload, for example in form frontmatter rendered by the Email plugin, that invokes spl_autoload through the sort filter. Successful invocation yields arbitrary PHP execution as the web server user on the host, effectively a full code-execution foothold on the site. Any Grav deployment running 2.0.17 or earlier in which such limited-privilege users or API tokens can write page content is affected. There is no public proof-of-concept, the issue is not in CISA's KEV, and EPSS puts 30-day exploitation risk at about 0.5% (40th percentile), so no exploitation is currently known.

What to do: Upgrade Grav to 2.0.18 or later. Until patched, restrict admin.pages and api.pages.write to fully trusted users and API credentials, and review form frontmatter rendered by the Email plugin for unexpected Twig |sort payloads; check logs for calls to spl_autoload originating from Twig templates.

Affected
Grav CMS<= 2.0.17 (fixed in 2.0.18)
Estimated exposure
largeon the order of tens of thousands of self-hosted Grav sites, with a smaller exploitable subset (sites granting page-write to untrusted editors or API tokens) — Public web-technology trackers and Grav's flat-file CMS community footprint indicate live deployments in the low tens of thousands; the flaw additionally requires an authenticated page-write user, so the realistically attackable population…

Order-of-magnitude estimate by the model from install counts, market share and public scan data it knows; verify before quoting.

Description

Grav before 2.0.18 (affected versions <= 2.0.17) contains a remote code execution vulnerability in the Twig sort filter. The sortFunc wrapper in GravExtension.php hardcodes Twig's isSandboxed argument to false, so unlike |map/|filter/|reduce, |sort accepts a plain function name inside the sandbox; the remaining denylist misses spl_autoload, which performs a PHP include. An authenticated user with only page-write rights (admin.pages or api.pages.write) can supply a crafted payload (e.g., via form frontmatter rendered by the Email plugin) that invokes spl_autoload through the sort filter, resulting in arbitrary PHP execution as the web server user.

Weakness
CWE-94
Vector
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X

In the news

No ingested article mentions this CVE yet.