CVE-2026-62672: Grav Denial of Service Vulnerability

MODERATE
Advisory Identifier: GHSA-37f3-6p89-6qr9
CWE-1333
Published
Advisory Summary

CVE-2026-62672 is a MODERATE denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Grav libraries in the Packagist ecosystem. The issue involves authenticated redos via regex_replace in twig sandbox. Remediation is available by upgrading affected packages to version 2.0.4.

CVE-2026-62672 at a Glance

CVE Identifier CVE-2026-62672
GHSA Identifier GHSA-37f3-6p89-6qr9
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-1333: Inefficient Regular Expression Complexity
Affected Product Grav
Package Ecosystem Packagist
Published Date
Last Updated

How to Fix CVE-2026-62672

To remediate this vulnerability, upgrade all affected Grav dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

getgrav/grav fixed: 2.0.4
Upgrade getgrav/grav to 2.0.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for getgrav/grav

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-62672, inspect your project dependencies for Grav:

inspect dependencies for getgrav/grav

Analyze the terminal output to locate any version of Grav in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0.4), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In Grav, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary The `regex_replace` filter and function are allowlisted in Grav's Twig content sandbox. When Twig processing in page content is enabled `security.twig_content.process_enabled: true`, authenticated page editors can supply a catastrophically backtracking PCRE pattern, causing unbounded CPU consumption and denying service to the entire web server process. --- ### Details The Twig sandbox allowlists, defined in `system/config/security.yaml`, explicitly include `regex_replace` in both the filter and function permission lists: **Source: `system/config/security.yaml`** ```yaml twig_sandbox: allowed_filters: # ... - regex_replace # user-controlled pattern allowed in sandbox allowed_functions: # ... - regex_replace # same ``` The underlying implementation passes the caller-controlled `$pattern` directly into PHP's `preg_replace()` without any pattern complexity validation: **Source: `system/src/Grav/Common/Twig/Extension/GravExtension.php:1317-1319`** ```php public function regexReplace($subject, $pattern, $replace, $limit = -1) { return preg_replace($pattern, $replace, $subject, $limit); } ``` When `twig_content.process_enabled` is `true`, page body content is sandboxed but can use any allowlisted filter. An editor who embeds a catastrophic backtracking pattern causes the PCRE engine to enter exponential time complexity, consuming 100% CPU until the PHP process is killed or the request times out. **Conditions required**: 1. `security.twig_content.process_enabled: true` (opt-in, `false` by default on fresh 2.0 installs) 2. `security.twig_sandbox.enabled: true` (default) - the function is reachable under sandbox 3. Attacker must have page edit access (authenticated contributor / editor role) --- ### PoC **Configuration prerequisite** - enable Twig in content: ```yaml # user/config/security.yaml twig_content: process_enabled: true ``` **Payload** — embed in any Grav page body with `process: { twig: true }` in frontmatter: ``` --- title: Test process: twig: true --- {{ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab'|regex_replace('/^(a+)+$/', '') }} ``` Or as a function call in a page where the editor has Twig access: ```twig {{ regex_replace('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', '/^(a+)+$/', '') }} ``` **Result**: The PHP-FPM worker (or CLI server process) enters catastrophic PCRE backtracking. On a 2 GHz host, a 32-character string with the above pattern will exhaust one CPU core for seconds to minutes. With a slightly longer string, the time grows exponentially. --- ### Impact **Vulnerability type**: Regular Expression Denial of Service - ReDoS **Who is impacted**: Server availability. Any Grav installation where: - An editor-role account exists (or has been compromised), AND - The operator has enabled `twig_content.process_enabled: true` An attacker with page-edit access can render the site unresponsive for all visitors by publishing a page with a catastrophic regex. On single-worker PHP configurations this is a complete outage. On multi-worker setups, multiple concurrent page renders of the malicious page can saturate all workers. ---

CVE-2026-62672 Affected Grav Versions

1 component(s)
Fixed Versions:
2.0.4
Product / Package Ecosystem Affected Versions Fixed Version
getgrav/grav
Packagist
< 2.0.4
2.0.4

References

Frequently Asked Questions

What is CVE-2026-62672?
CVE-2026-62672 is a security vulnerability in Grav involving Authenticated ReDoS via regex_replace in Twig Sandbox under CWE-1333: Inefficient Regular Expression Complexity.
Which Grav versions are affected?
Affected versions include releases prior to 2.0.4 across affected packages: getgrav/grav.
What version fixes CVE-2026-62672?
Upgrading to 2.0.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is getgrav/grav affected?
Yes, getgrav/grav is affected in releases prior to 2.0.4. Upgrade your dependency to 2.0.4 or later.
What CWE is associated with CVE-2026-62672?
CVE-2026-62672 is classified under CWE-1333: Inefficient Regular Expression Complexity (The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.).
How can I check Packagist dependencies for CVE-2026-62672?
Run the dependency tree command: 'inspect dependencies for getgrav/grav'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-37f3-6p89-6qr9",
  "modified" : "2026-09-17T16:34:43Z",
  "published" : "2026-09-02T14:50:57Z",
  "aliases" : [ "CVE-2026-62672" ],
  "summary" : "Grav: Authenticated ReDoS via regex_replace in Twig Sandbox",
  "details" : "### Summary\n\nThe `regex_replace` filter and function are allowlisted in Grav's Twig content sandbox. When Twig processing in page content is enabled `security.twig_content.process_enabled: true`, authenticated page editors can supply a catastrophically backtracking PCRE pattern, causing unbounded CPU consumption and denying service to the entire web server process.\n\n---\n\n### Details\n\nThe Twig sandbox allowlists, defined in `system/config/security.yaml`, explicitly include `regex_replace` in both the filter and function permission lists:\n\n**Source: `system/config/security.yaml`**\n\n```yaml\ntwig_sandbox:\n  allowed_filters:\n    # ...\n    - regex_replace    #  user-controlled pattern allowed in sandbox\n  allowed_functions:\n    # ...\n    - regex_replace    #  same\n```\n\nThe underlying implementation passes the caller-controlled `$pattern` directly into PHP's `preg_replace()` without any pattern complexity validation:\n\n**Source: `system/src/Grav/Common/Twig/Extension/GravExtension.php:1317-1319`**\n\n```php\npublic function regexReplace($subject, $pattern, $replace, $limit = -1)\n{\n    return preg_replace($pattern, $replace, $subject, $limit);\n}\n```\n\nWhen `twig_content.process_enabled` is `true`, page body content is sandboxed but can use any allowlisted filter. An editor who embeds a catastrophic backtracking pattern causes the PCRE engine to enter exponential time complexity, consuming 100% CPU until the PHP process is killed or the request times out.\n\n**Conditions required**:\n1. `security.twig_content.process_enabled: true` (opt-in, `false` by default on fresh 2.0 installs)\n2. `security.twig_sandbox.enabled: true` (default) - the function is reachable under sandbox\n3. Attacker must have page edit access (authenticated contributor / editor role)\n\n---\n\n### PoC\n\n**Configuration prerequisite** - enable Twig in content:\n\n```yaml\n# user/config/security.yaml\ntwig_content:\n  process_enabled: true\n```\n\n**Payload** — embed in any Grav page body with `process: { twig: true }` in frontmatter:\n\n```\n---\ntitle: Test\nprocess:\n  twig: true\n---\n{{ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab'|regex_replace('/^(a+)+$/', '') }}\n```\n\nOr as a function call in a page where the editor has Twig access:\n\n```twig\n{{ regex_replace('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', '/^(a+)+$/', '') }}\n```\n\n**Result**: The PHP-FPM worker (or CLI server process) enters catastrophic PCRE backtracking. On a 2 GHz host, a 32-character string with the above pattern will exhaust one CPU core for seconds to minutes. With a slightly longer string, the time grows exponentially.\n\n---\n\n### Impact\n\n**Vulnerability type**: Regular Expression Denial of Service - ReDoS\n\n**Who is impacted**: Server availability. Any Grav installation where:\n- An editor-role account exists (or has been compromised), AND\n- The operator has enabled `twig_content.process_enabled: true`\n\nAn attacker with page-edit access can render the site unresponsive for all visitors by publishing a page with a catastrophic regex. On single-worker PHP configurations this is a complete outage. On multi-worker setups, multiple concurrent page renders of the malicious page can saturate all workers.\n\n---",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:H/AT:P/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "getgrav/grav"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.0.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/getgrav/grav/security/advisories/GHSA-37f3-6p89-6qr9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-62672"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/getgrav/grav/commit/907116268ad4f48be7472c57f64981918578599a"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/getgrav/grav"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/getgrav/grav/releases/tag/2.0.4"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-02T14:50:57Z",
    "nvd_published_at" : "2026-08-19T16:18:20Z"
  }
}