/

CVE-2026-56700

Severity:

CRITICAL RISK

(9.8)

Code Execution (CWE-78, CWE-502) in Grav CMS Core

CVE-2026-56700

Deferred

Vulnerability type

Category:

Remote Code Execution

CWE:

CWE-78, CWE-502

Impact:

Arbitrary Code Execution on the Grav CMS host

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Grav CMS before 2.0.0-beta.2 suffers from multiple code-execution flaws, including unsafe PHP deserialization, OS command injection in the installer, and a Twig template security blocklist bypass.

When an attacker can control serialized input or installation parameters, these issues can lead to full remote code execution under the web server context and complete site compromise.

Affected context

These vulnerabilities occur in Grav CMS components that process dynamic, application-controlled data:

  • Scheduler\JobQueue, Framework\Cache\Adapter\FileCache, and Session make unsafe unserialize() calls on data that may be influenced by users, plugins, or session mechanisms.
  • The InstallCommand feature executes git clone with user-specified branch, URL, and path values that are passed through a shell without robust escaping.
  • Twig template rendering in Grav uses a security blocklist that can be bypassed, allowing server-side template injection in certain configurations.

Risk is highest in deployments where administrators install plugins/themes from untrusted sources, where serialized data can be submitted or tampered with, or where templates are editable through the CMS or filesystem.

Exploit preconditions

  • Attack surface (unsafe deserialization):
  • Endpoints or workflows that read serialized payloads into Scheduler\JobQueue, FileCache, or Session.
  • Ability to supply or manipulate serialized data, such as crafted session cookies, cache keys, or job queue entries.
  • Attack surface (InstallCommand OS injection):
  • Access to the administrative interface or CLI used to install plugins/themes via git.
  • Ability to set branch, repository URL, or path values consumed by the InstallCommand.
  • Attack surface (Twig SSTI/blocklist bypass):
  • Ability to modify or inject Twig templates or data interpreted as Twig syntax (via theme editing, plugin configuration, or template-like fields).
  • Required access:
  • For deserialization attacks, typically user or attacker control over serialized data channels.
  • For InstallCommand injection, administrative access or compromise of an admin-controlled workflow.
  • For Twig SSTI, permission to edit templates or content that Grav treats as Twig.
  • Trigger points:
  • unserialize() is invoked by Grav's scheduler, caching, or session subsystems during normal request processing.
  • InstallCommand runs git clone by spawning a shell when installing or updating plugins/themes.
  • Twig rendering occurs whenever Grav processes dynamic views or template-based content.
  • Why exploitation is possible:
  • unserialize() is used without restricting allowed classes or validating the object graph, enabling PHP object injection and gadget-chain execution.
  • Shell commands are constructed using unescaped parameters, enabling command injection via crafted branch/URL/path strings.
  • Twig's blocklist-based security model can be bypassed, allowing invocation of dangerous template features and server-side template injection.

Why this happens

The underlying bug class aligns primarily with CWE-502: Unsafe Deserialization and CWE-78: OS Command Injection.

In Grav's Scheduler\JobQueue, FileCache, and Session components, serialized data is treated as trusted and passed directly into PHP's unserialize() without limiting permitted classes or verifying object structure. This pattern enables PHP object injection, where attacker-controlled payloads instantiate or rehydrate framework objects whose magic methods (e.g., __wakeup, __destruct) form gadget chains capable of executing arbitrary code or performing sensitive actions.

In InstallCommand, user-supplied parameters for git clone (branch, URL, path) are interpolated into a shell command without robust escaping or argument-level sanitization. This creates a classic command injection scenario in which embedded shell metacharacters are interpreted by the OS rather than treated as data.

The Twig blocklist bypass stems from relying on a denylist approach to template security, allowing certain dangerous constructs or functions to be reached via alternative code paths. This is a server-side template injection pattern, where templates are executed with more capabilities than intended.

Potential impact

  • Attackers may execute arbitrary PHP code via object injection and gadget chains.
  • Attackers could run arbitrary OS commands under the web server or Grav process account.
  • An adversary can fully compromise the Grav CMS instance, including configuration, content, and user data.
  • Remote persistence may be established through backdoored plugins, themes, or templates.
  • Lateral movement within the hosting environment or underlying server may be attempted, depending on privileges.

General mitigation guidance

Effective mitigation focuses on treating all dynamic data and execution paths as untrusted and reducing what they are allowed to do:

  • Replace generic unserialize() usage with safer, structured data formats (e.g., JSON) or, where deserialization is required, restrict allowed classes and enforce strict validation of object graphs.
  • Avoid constructing shell commands from user or admin-supplied strings; use safe process-spawning APIs that pass arguments as arrays and apply strict validation on repository, branch, and path values.
  • Harden template security by adopting an allowlist-based Twig configuration that only exposes benign functions and filters, and by segregating untrusted content from template execution paths.
  • Apply least-privilege principles to the Grav runtime, ensuring that even if code execution occurs, filesystem and system-level access are minimized.
  • Centralize input validation for administrative workflows, especially installation and update operations, and log or review high-risk actions.

How teams detect issues like this

Organizations can detect and manage these patterns through a mix of automated and manual techniques:

  • Use static analysis rules to flag calls to unserialize() on data that can originate from HTTP requests, sessions, or plugin-controlled inputs, and highlight dangerous magic methods that may act as gadgets.
  • Implement code review checklists that require scrutiny of any shell command construction, process execution, or template engine configuration, verifying that user-controlled data cannot reach execution sinks.
  • Apply security-focused tests for Twig templates, including fuzzing for server-side template injection and validating that denylist/allowlist logic matches policy.
  • Leverage application security tooling or CI-integrated scanners to identify unsafe deserialization, command injection sinks, and template injection patterns in Grav plugins or custom themes.
  • Monitor runtime logs and security telemetry for anomalous git clone arguments, unexpected template errors, or serialized data anomalies that could indicate exploit attempts.

Sources

SourceLink
github.comgithub.com/getgrav/grav/security/advisories/GHSA-vj3m-2g9h-vm4p
vulncheck.comvulncheck.com/advisories/grav-multiple-remote-code-execution-vulnerabilities-via-unsafe-unserialize-and-command-injection

Frequently asked

questions

Yes. If attackers can control serialized data, template content, or plugin installation parameters exposed via HTTP or admin interfaces, they can potentially achieve remote code execution without direct server access.

Unsafe deserialization and template injection may be reachable from lower-privilege user inputs or through compromised plugins, while command injection in InstallCommand generally requires administrative access or compromise of an admin account.

Replace unsafe deserialization with structured, validated formats; use parameterized process execution instead of shell string concatenation; and enforce an allowlist-based, locked-down configuration for template engines so only explicitly safe features are available.

Adopt secure coding standards that forbid unserialize() on untrusted data, prohibit building shell commands from user-controlled values, and require threat modeling and security review of plugin install/update workflows and template customization features before release.

Find out what's already
exploitable in your codebase.