/

CVE-2026-42607

Severity:

CRITICAL RISK

(9.1)

Code Injection in Grav Direct Install

CVE-2026-42607

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.1)

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's Direct Install feature allows an authenticated administrator to upload a specially crafted ZIP archive that bypasses file extension checks and deploys a malicious plugin.

Once extracted, the plugin can execute arbitrary PHP code or install a persistent web shell, leading to full remote code execution on the server under administrative misuse or account compromise.

Affected context

This vulnerability occurs in Grav installations where:

  • The Direct Install tool is enabled for installing themes/plugins from ZIP archives
  • Administrative users can upload ZIP files directly to the server
  • Server-side validation focuses on top-level file extensions but does not recursively inspect archive contents

The issue becomes relevant when an attacker gains or abuses administrative access and can introduce untrusted ZIP packages into the environment.

Exploit preconditions

  • Attack surface: Web administration interface (Direct Install / ZIP upload endpoint)
  • Required access: Authenticated administrative account or equivalent privilege that can upload and install plugins/themes
  • Trigger point: Uploading and installing a malicious ZIP package via Direct Install, which is then extracted and loaded by the Grav runtime
  • Why exploitation is possible: The upload protection checks for disallowed extensions (such as .php) only on direct file uploads and does not analyze or enforce constraints on files inside ZIP archives. Malicious PHP code bundled as a plugin is therefore extracted into executable paths without adequate validation.

Why this happens

The underlying bug stems from incomplete server-side validation of uploaded content, specifically in the handling of compressed archives used for plugin installation.

While the platform attempts to prevent direct upload of dangerous file types (e.g., .php), it does not apply equivalent checks to files contained within ZIP archives. This allows an attacker to smuggle executable PHP code into the application as part of a plugin directory structure.

From a weakness taxonomy perspective, this maps to CWE-94: Improper Control of Generation of Code ('Code Injection') because the system loads and executes attacker-supplied PHP code as part of the application's plugin mechanism without adequately constraining what can be installed.

Potential impact

  • Remote execution of arbitrary PHP code in the context of the web server process
  • Installation of persistent web shells enabling long-term server compromise
  • Reading, modifying, or deleting application and user data stored on the server
  • Lateral movement within the hosting environment, depending on server configuration
  • Abuse of the compromised server to launch further attacks (spam, phishing, malware hosting)

General mitigation guidance

Effective mitigation generally focuses on hardening the plugin installation pipeline and reducing trust in uploaded packages:

  • Enforce strict validation of archive contents, including recursive checks for disallowed file types and executable code inside ZIP files.
  • Restrict plugin execution to a well-defined, minimal subset of files and forbid arbitrary PHP entry points or dynamic code loading where possible.
  • Permit installation only from trusted, signed, or otherwise verified sources instead of arbitrary ZIP uploads.
  • Apply least-privilege principles to the web server and application runtime, limiting filesystem write access and execution permissions in plugin directories.
  • Consider disabling direct ZIP-based installation in high-security environments and using controlled deployment processes (e.g., manual review and controlled file distribution).

How teams detect issues like this

Organizations can detect and monitor this class of issue using:

  • Static analysis or security review of the code paths responsible for file upload, archive extraction, and plugin loading, looking for missing validation on archive contents and executable file types.
  • Configuration and policy checks that flag or block plugin directories containing unexpected PHP files, writable executable paths, or non-standard entry points.
  • Runtime monitoring and intrusion detection focused on:
  • Creation of new PHP files in plugin or web-accessible directories
  • Unusual outbound connections or command execution originating from plugin code
  • Periodic file integrity monitoring (FIM) on plugin and webroot directories to detect unauthorized additions or modifications.
  • Use of automated application security testing tools (e.g., SAST/DAST) to identify unvalidated file upload and archive handling flows in custom extensions or integrations.

Sources

SourceLink
github.comgithub.com/getgrav/grav/commit/5a12f9be8314682c8713e569e330f11805d0a663
github.comgithub.com/getgrav/grav/security/advisories/GHSA-w48r-jppp-rcfw

Frequently asked

questions

Yes, but only if an attacker can authenticate as an administrator or otherwise obtain equivalent privileges to access the Direct Install feature. There is no unauthenticated remote exploit path described for this issue.

The attacker must have an administrative account or a role explicitly allowed to upload and install plugins or themes via ZIP archives. Compromised admin credentials or privilege escalation to such a role are typical preconditions.

The most robust fix is to treat archives as untrusted input: validate and sanitize all contents before extraction, block or strip executable file types within ZIPs, and ensure the plugin loader will not execute untrusted code. Where possible, restrict installation to vetted, signed packages rather than arbitrary uploads.

Design upload and installation mechanisms with a default-deny approach: assume all user-supplied content is hostile, validate based on strict allowlists, apply checks to nested structures like archives, and perform security reviews focused on plugin/extension loading paths. Combine these patterns with least-privilege deployment, monitoring, and secure coding standards for any dynamic code loading features.

Find out what's already
exploitable in your codebase.