/

CVE-2026-61457

Severity:

HIGH RISK

(8.8)

File Upload Extension Bypass (CWE-434) in Grav API

CVE-2026-61457

Deferred

Vulnerability type

Category:

Unrestricted File Upload

CWE:

CWE-434

Impact:

Remote Code Execution via Malicious File Upload

Severity:

HIGH RISK

(8.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

The Grav API plugin contains a file upload validation flaw that allows bypassing the dangerous extensions blocklist by using double extensions such as shell.php.jpg.

When combined with permissive web server configuration and api.media.write privileges, this can result in arbitrary PHP code execution on the server.

Affected context

This vulnerability affects Grav installations that use the Grav API plugin with media write capabilities exposed to users or integrated services.

It is most relevant where uploaded media is stored in a web-accessible directory and the HTTP server is configured to interpret files based on inner or actual executable extensions.

Environments that rely solely on file name extension checks without additional content-type or storage segregation controls are at increased risk.

Exploit preconditions

  • Attack surface: Grav API media upload endpoint in the API plugin.
  • Required access: Valid account or API client with api.media.write permission.
  • Trigger point: Uploading a file whose name includes a dangerous extension before a benign extension, e.g., payload.php.jpg.
  • Why exploitation is possible: The validation routine inspects only the final extension using pathinfo($filename, PATHINFO_EXTENSION), so inner dangerous extensions remain unfiltered while the server may still treat the file as executable.

Why this happens

The core issue is an overly simplistic and extension-focused validation check for uploaded files.

The plugin's HandlesMediaUploads::validateFileExtension() function inspects only the last extension segment, assuming that PATHINFO_EXTENSION represents the true risk-bearing type.

This design overlooks filenames with multiple dots where an inner extension corresponds to a server-executable type such as .php.

Conceptually, this maps to CWE-434: Unrestricted File Upload, where insufficient validation of uploaded content, naming, and handling allows attackers to introduce executable or otherwise dangerous files into web-accessible locations.

Potential impact

  • Remote execution of arbitrary PHP code on the server.
  • Full compromise of the Grav application and its configuration.
  • Access to sensitive data stored or managed by the CMS.
  • Privilege escalation within the hosting environment depending on server configuration.
  • Use of the compromised server as a pivot for further attacks in the network.

General mitigation guidance

Effective mitigation focuses on treating file uploads as untrusted input and constraining both what can be uploaded and how uploads are served.

Defensive patterns include:

  • Enforcing strict allowlists of safe, non-executable extensions and rejecting filenames containing multiple extensions or suspicious patterns.
  • Validating file content type and structure in addition to extension, avoiding reliance on path-based checks alone.
  • Storing uploaded media outside web-executable directories or on a segregated domain that does not interpret server-side code.
  • Configuring the web server to disallow execution of dynamic scripts from upload directories.
  • Applying least-privilege to accounts and API keys so only trusted principals have media write capabilities.

These measures reduce the risk that a malformed or malicious upload can become an executable payload.

How teams detect issues like this

Detection approaches typically combine code-level inspection and runtime monitoring:

  • Static analysis or manual review to flag upload handlers that depend solely on PATHINFO_EXTENSION or similar filename-based checks without enforcing strict allowlists.
  • Reviewing routes and controllers associated with media uploads for missing server-side validation and lack of storage segregation.
  • Log analysis to identify unusual upload patterns, such as files containing multiple dots or inner executable extensions (.php, .phtml, .asp) followed by benign ones.
  • Security policies in CI/CD that require secure upload handling patterns, including content-type verification and deployment checks ensuring upload directories are non-executable.

Automated tooling can assist by scanning for common unrestricted file upload antipatterns across PHP projects and CMS plugins.

Sources

SourceLink
github.comgithub.com/getgrav/grav/security/advisories/GHSA-66v2-vxxf-xc3v
vulncheck.comvulncheck.com/advisories/grav-before-remote-code-execution-via-file-upload-extension-bypass

Frequently asked

questions

Exploitability depends on how broadly api.media.write permissions are granted and how uploaded files are served. If many users or integrations can upload media and uploads land in an executable directory, the exposure can be significant.

An attacker needs valid access with media write permissions through the Grav API plugin. Anonymous users cannot exploit this directly unless the API is misconfigured to grant write access without proper authentication.

The safest approach is to implement strict allowlist-based extension checks, reject suspicious multi-extension filenames, validate file content types, and ensure upload directories are configured as non-executable by the web server.

Future development should treat file uploads as high-risk input, enforce layered validation (extension, content type, and storage location), integrate security reviews for upload-related code, and codify policies that upload directories must never execute server-side code.

Find out what's already
exploitable in your codebase.