Summary
A code injection vulnerability in Grav CMS allows an authenticated user to upload an archive containing PHP code through the Flex Objects plugin settings workflow. If the uploaded archive is extracted into a web-accessible location, the PHP files may be executed by the server, resulting in remote code execution.
Affected context
The vulnerability occurs in Grav CMS deployments that enable the Flex Objects plugin and expose its settings validation and archive-handling functionality to authenticated users. Risk increases when an account can upload or influence archive contents, when routine-name validation accepts unexpected input structures, and when extracted files can be written beneath a web-accessible directory.
Exploit preconditions
- Attack surface: Authenticated administrative or plugin settings functionality exposed by the Grav CMS application
- Required access: A valid account with permission to reach the affected Flex Objects settings workflow and submit an archive
- Trigger point: Processing and extraction of a user-supplied ZIP file by the plugin's archive-handling routine
- Why exploitation is possible: Validation can be bypassed through unexpected input structure, allowing a malicious archive to be processed and PHP files to be written where the application server may execute them
Why this happens
The underlying flaw is insufficient validation of structured request data combined with unsafe handling of uploaded archives. The application expects a routine name in one representation, but alternate array-form input can bypass routine validation and reach a file extraction operation without adequately constraining archive contents or destination paths. When server-executable files can be placed in a web-accessible location, attacker-controlled content may be interpreted as PHP code. This behavior maps to CWE-94: Improper Control of Generation of Code, because untrusted input can influence executable code placed into the application runtime.
Potential impact
- An attacker may execute arbitrary PHP or operating-system commands with the web server's privileges.
- The application could be modified, defaced, or used to access sensitive data.
- Compromised credentials or configuration data may be exposed.
- The server could be used for lateral movement or additional attacks.
- Persistent malicious files could remain in the web-accessible application directory.
General mitigation guidance
Mitigation generally focuses on reducing trust in authenticated uploads, enforcing consistent validation of scalar and structured input, and preventing archive extraction from creating executable content.
Common defensive patterns include:
- Accepting only explicitly defined input types and rejecting unexpected array or object representations.
- Applying allowlist validation to operation names, archive members, file extensions, and destination paths.
- Extracting uploads into isolated, non-web-accessible storage and preventing uploaded files from being interpreted as server-side code.
- Treating archives as untrusted containers by checking path traversal, symbolic links, duplicate names, and resource limits.
- Separating upload and extraction privileges from the web-serving process where practical.
- Enforcing least-privilege permissions for the application service account and using secure-by-default upload policies.
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules that identify archive extraction into web roots or executable directories.
- Code review checks for validation that handles strings but not arrays, objects, or repeated parameters.
- Searches for upload workflows that fail to constrain archive member names, extensions, or extraction paths.
- Runtime monitoring for unexpected PHP files, archive extraction events, or changes beneath web-accessible directories.
- Web application policies that restrict administrative uploads and alert on unusual archive submissions.
- Automated security review tools that flag executable content handling and path-validation weaknesses.

